You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by as...@apache.org on 2026/08/26 11:23:16 UTC
(maka) branch main updated: fix(desktop): name the session in the usage request log task column (#3833)
This is an automated email from the ASF dual-hosted git repository.
Astro-Han pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/maka.git
The following commit(s) were added to refs/heads/main by this push:
new 4dddb0f25 fix(desktop): name the session in the usage request log task column (#3833)
4dddb0f25 is described below
commit 4dddb0f25e622bc070008e8ae186d296f4b6c13f
Author: Xiao Liu <li...@qq.com>
AuthorDate: Wed Aug 26 19:23:10 2026 +0800
fix(desktop): name the session in the usage request log task column (#3833)
The 使用统计 request log's 任务 column sliced the first 8 characters of the
desktop composite session key (`["<hostId>","<sessionId>"]`), so every row
collapsed to the constant `["<hostId>` prefix instead of naming its session.
Carry the session name (`SessionHeader.name`) through the usage stats
pipeline and render it as a link, falling back to the untitled label plus a
short real session id (parsed out of the composite key) for unnamed sessions.
Trim the Time/Task column widths so the Status column is no longer clipped,
and align the Task link flush with its header.
Generated-by: Claude Code (claude-opus-4-8)
---
.../src/renderer/locales/settings-usage-copy.ts | 6 ++--
.../src/renderer/settings/usage-settings-page.tsx | 34 +++++++++++++++++++---
.../desktop/src/renderer/styles/settings/usage.css | 23 +++++++++++++++
.../stories/settings/settings-pages.stories.tsx | 8 ++++-
packages/core/src/settings.ts | 2 ++
packages/storage/src/usage-stats-store.ts | 7 ++++-
6 files changed, 71 insertions(+), 9 deletions(-)
diff --git a/apps/desktop/src/renderer/locales/settings-usage-copy.ts b/apps/desktop/src/renderer/locales/settings-usage-copy.ts
index 5d26a59ed..303a86963 100644
--- a/apps/desktop/src/renderer/locales/settings-usage-copy.ts
+++ b/apps/desktop/src/renderer/locales/settings-usage-copy.ts
@@ -29,7 +29,7 @@ export type UsageSettingsCopy = {
tables: {
providersAria: string; modelsAria: string; toolsAria: string; pricingAria: string; requestsAria: string;
providerHeaders: string[]; modelHeaders: string[]; toolHeaders: string[]; pricingHeaders: string[]; requestHeaders: string[];
- noPricing: string; modelKind: string; toolKind: string; openSession(label: string): string; success: string; error: string;
+ noPricing: string; modelKind: string; toolKind: string; openSession(label: string): string; untitledSession: string; success: string; error: string;
providerEmptyTitle: string; providerEmptyBody: string; modelEmptyTitle: string; modelEmptyBody: string;
toolEmptyTitle: string; toolEmptyBody: string; pricingEmptyBody: string;
};
@@ -49,7 +49,7 @@ const SETTINGS_USAGE_COPY = {
providersAria: '使用统计供应商统计表', modelsAria: '使用统计模型统计表', toolsAria: '使用统计工具统计表', pricingAria: '使用统计定价配置表', requestsAria: '使用统计请求日志表',
providerHeaders: ['供应商', '请求', 'Token', '费用'], modelHeaders: ['模型', '请求', 'Token', '费用'], toolHeaders: ['工具', '调用', '成功', '错误', '平均耗时'],
pricingHeaders: ['供应商', '模型', '输入 / 1M', '输出 / 1M'], requestHeaders: ['时间', '类型', '对象', '任务', 'Token', '费用', '延迟', '状态'],
- noPricing: '暂无定价覆盖配置', modelKind: '模型', toolKind: '工具', openSession: (label) => `打开 ${label}`, success: '成功', error: '错误',
+ noPricing: '暂无定价覆盖配置', modelKind: '模型', toolKind: '工具', openSession: (label) => `打开会话「${label}」`, untitledSession: '未命名会话', success: '成功', error: '错误',
providerEmptyTitle: '暂无供应商用量', providerEmptyBody: '完成一次模型请求后,这里会按供应商聚合请求数、Token 与费用。',
modelEmptyTitle: '暂无模型用量', modelEmptyBody: '完成一次模型请求后,这里会按模型聚合请求数、Token 与费用。',
toolEmptyTitle: '暂无工具调用', toolEmptyBody: '智能体调用工具后,这里会按工具聚合调用次数、成功、错误与平均耗时。',
@@ -69,7 +69,7 @@ const SETTINGS_USAGE_COPY = {
providersAria: 'Usage by provider', modelsAria: 'Usage by model', toolsAria: 'Usage by tool', pricingAria: 'Usage pricing configuration', requestsAria: 'Usage request log',
providerHeaders: ['Provider', 'Requests', 'Tokens', 'Cost'], modelHeaders: ['Model', 'Requests', 'Tokens', 'Cost'], toolHeaders: ['Tool', 'Calls', 'Success', 'Errors', 'Average duration'],
pricingHeaders: ['Provider', 'Model', 'Input / 1M', 'Output / 1M'], requestHeaders: ['Time', 'Type', 'Target', 'Task', 'Tokens', 'Cost', 'Latency', 'Status'],
- noPricing: 'No pricing overrides', modelKind: 'Model', toolKind: 'Tool', openSession: (label) => `Open ${label}`, success: 'Success', error: 'Error',
+ noPricing: 'No pricing overrides', modelKind: 'Model', toolKind: 'Tool', openSession: (label) => `Open session "${label}"`, untitledSession: 'Untitled session', success: 'Success', error: 'Error',
providerEmptyTitle: 'No provider usage', providerEmptyBody: 'After a model request, provider request counts, tokens, and costs appear here.',
modelEmptyTitle: 'No model usage', modelEmptyBody: 'After a model request, request counts, tokens, and costs appear here by model.',
toolEmptyTitle: 'No tool calls', toolEmptyBody: 'After an agent calls a tool, calls, successes, errors, and average duration appear here by tool.',
diff --git a/apps/desktop/src/renderer/settings/usage-settings-page.tsx b/apps/desktop/src/renderer/settings/usage-settings-page.tsx
index 89d8e8dd5..feb1d93ac 100644
--- a/apps/desktop/src/renderer/settings/usage-settings-page.tsx
+++ b/apps/desktop/src/renderer/settings/usage-settings-page.tsx
@@ -32,6 +32,7 @@ import {
proportional,
} from '@astryxdesign/core';
import { uiLocaleToIntlLocale } from '@maka/core/ui-locale';
+import { parseDesktopSessionKey } from '../../shared/runtime-host-identity.js';
import {
type AppSettings,
type UpdateAppSettingsResult,
@@ -324,10 +325,10 @@ function UsageRequestsPanel(props: {
<UsageStatsTable
ariaLabel={props.copy.tables.requestsAria}
columns={[
- { header: props.copy.tables.requestHeaders[0], width: 192 },
+ { header: props.copy.tables.requestHeaders[0], width: 168 },
{ header: props.copy.tables.requestHeaders[1], width: 72 },
{ header: props.copy.tables.requestHeaders[2], grow: true },
- { header: props.copy.tables.requestHeaders[3] },
+ { header: props.copy.tables.requestHeaders[3], width: 168 },
{ header: props.copy.tables.requestHeaders[4], numeric: true },
{ header: props.copy.tables.requestHeaders[5], numeric: true },
{ header: props.copy.tables.requestHeaders[6], numeric: true },
@@ -442,13 +443,38 @@ function usageRequestTarget(row: UsageStats['logs'][number]) {
}
function usageRequestSessionCell(row: UsageStats['logs'][number], copy: UsageSettingsCopy, onOpenSession?: (sessionId: string) => void) {
- const label = shortUsageSessionId(row.sessionId);
+ const label = usageSessionDisplayLabel(row, copy);
if (!onOpenSession) return label;
return (
- <Button variant="ghost" size="sm" onClick={() => onOpenSession(row.sessionId)} label={copy.tables.openSession(label)} />
+ <Button
+ className="settingsUsageSessionCell"
+ variant="ghost"
+ size="sm"
+ onClick={() => onOpenSession(row.sessionId)}
+ label={label}
+ tooltip={copy.tables.openSession(label)}
+ />
);
}
+// The Task column names the session (conversation) each request belongs to.
+// The name is the real title; untitled sessions fall back to a short slice of
+// their *real* session id (parsed out of the desktop composite key) so rows
+// stay distinguishable instead of collapsing onto the shared host-id prefix.
+function usageSessionDisplayLabel(row: UsageStats['logs'][number], copy: UsageSettingsCopy) {
+ const name = row.sessionName?.trim();
+ if (name) return name;
+ return `${copy.tables.untitledSession} · ${shortRealSessionId(row.sessionId)}`;
+}
+
+function shortRealSessionId(sessionKey: string) {
+ try {
+ return shortUsageSessionId(parseDesktopSessionKey(sessionKey).sessionId);
+ } catch {
+ return shortUsageSessionId(sessionKey);
+ }
+}
+
function shortUsageSessionId(sessionId: string) {
return sessionId.length > 8 ? sessionId.slice(0, 8) : sessionId;
}
diff --git a/apps/desktop/src/renderer/styles/settings/usage.css b/apps/desktop/src/renderer/styles/settings/usage.css
index a9c05464f..84197a415 100644
--- a/apps/desktop/src/renderer/styles/settings/usage.css
+++ b/apps/desktop/src/renderer/styles/settings/usage.css
@@ -95,6 +95,29 @@
min-width: 0;
}
+/* 任务 column: the session-name link truncates inside its fixed column width and
+ surfaces the full name via the button tooltip. StyleX owns the button's own
+ layout; these rules only cap its width and ellipsis the label text (descendant
+ specificity outranks StyleX's single-class atoms), so row height and the
+ neighbouring columns stay aligned no matter how long a session name is. */
+.settingsUsageSessionCell {
+ max-width: 100%;
+ min-width: 0;
+ justify-content: flex-start;
+ /* Align the session-name link flush with the 任务 header and the other
+ left-aligned text columns by neutralising the ghost button's leading inline
+ padding. !important because Astryx's StyleX size padding is unlayered and
+ otherwise wins on source order (same escape hatch as sidebar.css). */
+ padding-inline-start: 0 !important;
+}
+
+.settingsUsageSessionCell span {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
/* Empty tab: the shared EmptyState card, nudged to the density of the
stats surface rather than the full page hero. */
.settingsUsageEmpty {
diff --git a/apps/desktop/stories/settings/settings-pages.stories.tsx b/apps/desktop/stories/settings/settings-pages.stories.tsx
index ae7910e74..b3609bdd0 100644
--- a/apps/desktop/stories/settings/settings-pages.stories.tsx
+++ b/apps/desktop/stories/settings/settings-pages.stories.tsx
@@ -205,12 +205,14 @@ function makeUsageLog(input: {
toolName?: string;
status?: 'success' | 'error';
minutesAgo: number;
+ sessionName?: string;
}): UsageStats['logs'][number] {
return {
id: input.id,
ts: NOW - input.minutesAgo * 60_000,
kind: input.kind,
sessionId: `b0efaaf9-9e58-46c1-bfea-${input.id.padStart(12, '0')}`,
+ sessionName: input.sessionName ?? '',
turnId: `turn-${input.id}`,
provider: 'zai-coding-plan',
model: input.model,
@@ -228,6 +230,8 @@ const usageLogs: UsageStats['logs'] = [
id: '1',
kind: 'model',
model: 'anthropic/claude-sonnet-4-5-20250929-preview-extended-thinking',
+ // A long session name exercises the 任务 column's truncate-plus-tooltip path.
+ sessionName: '重构使用统计页请求日志的任务列,改为显示会话名称并处理超长标题的截断',
minutesAgo: 4,
}),
makeUsageLog({
@@ -235,10 +239,12 @@ const usageLogs: UsageStats['logs'] = [
kind: 'tool',
model: 'glm-4.7',
toolName: 'mcp__cloud_workspace__list_repository_branch_protection_rules',
+ sessionName: '排查 MCP 分支保护规则拉取失败',
minutesAgo: 9,
}),
+ // No sessionName → renders the "未命名会话 · <short id>" fallback.
makeUsageLog({ id: '3', kind: 'model', model: 'glm-4.7', status: 'error', minutesAgo: 16 }),
- makeUsageLog({ id: '4', kind: 'tool', model: 'glm-4.7', toolName: 'Bash', minutesAgo: 25 }),
+ makeUsageLog({ id: '4', kind: 'tool', model: 'glm-4.7', toolName: 'Bash', sessionName: 'Bash 环境探查', minutesAgo: 25 }),
];
const usageStats: UsageStats = {
diff --git a/packages/core/src/settings.ts b/packages/core/src/settings.ts
index e3467dad0..0cf43357b 100644
--- a/packages/core/src/settings.ts
+++ b/packages/core/src/settings.ts
@@ -383,6 +383,8 @@ export interface UsageRequestLog {
ts: number;
kind: 'model' | 'tool';
sessionId: string;
+ /** Human-readable session title (SessionHeader.name); may be empty for untitled sessions. */
+ sessionName: string;
turnId: string;
provider: string;
model: string;
diff --git a/packages/storage/src/usage-stats-store.ts b/packages/storage/src/usage-stats-store.ts
index 69296c2d9..8db371465 100644
--- a/packages/storage/src/usage-stats-store.ts
+++ b/packages/storage/src/usage-stats-store.ts
@@ -26,7 +26,7 @@ import {
} from './operational-state-store.js';
import { createSqliteSessionMetadataStore } from './sqlite-session-metadata-store.js';
-type UsageSessionHeader = Pick<SessionHeader, 'id' | 'llmConnectionSlug' | 'model'>;
+type UsageSessionHeader = Pick<SessionHeader, 'id' | 'name' | 'llmConnectionSlug' | 'model'>;
type UsageAssistantMessage = {
type: 'assistant';
@@ -92,6 +92,7 @@ export async function readUsageStats(
ts: message.ts,
kind: 'model' as const,
sessionId: header.id,
+ sessionName: header.name,
turnId: message.turnId,
provider: header.llmConnectionSlug,
model: assistantByTurn.get(message.turnId) ?? header.model,
@@ -158,6 +159,7 @@ async function readStoredSessions(
sessions.push({
header: {
id: header.id,
+ name: header.name,
llmConnectionSlug: header.llmConnectionSlug,
model: header.model,
},
@@ -175,10 +177,12 @@ async function readStoredSessions(
function normalizeUsageSessionHeader(value: unknown, sessionId: string): UsageSessionHeader | null {
if (!isRecord(value)) return null;
if (value.id !== sessionId) return null;
+ if (typeof value.name !== 'string') return null;
if (typeof value.llmConnectionSlug !== 'string') return null;
if (typeof value.model !== 'string') return null;
return {
id: value.id,
+ name: value.name,
llmConnectionSlug: value.llmConnectionSlug,
model: value.model,
};
@@ -365,6 +369,7 @@ function toolLogRowsFromMessages(
ts,
kind: 'tool' as const,
sessionId: header.id,
+ sessionName: header.name,
turnId: call.turnId,
provider: header.llmConnectionSlug,
model: header.model,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org