From 399bd62383840a6064b859c731c07698bdf14720 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sun, 1 Nov 2026 22:46:35 -0800 Subject: [PATCH 1/3] docs(d215): draw the reply trace page, s-run-trace A new person who follows "How this reply was made" lands on a page titled "Run trace" that opens with a storage note and raw ids. The frame draws today's page and the fix: the h1 matches the link, the summary names the agent by its roster display name, the status reads in plain words, counts are plural and grouped, and the retention sentence and run id move to a muted foot after the turns. Turns and tool calls are unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015AKgpMD6Qh13f7fj6mbGT3 --- docs/design/artboards/d215/index.html | 31 ++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/design/artboards/d215/index.html b/docs/design/artboards/d215/index.html index 8141ff0283..5c4e309793 100644 --- a/docs/design/artboards/d215/index.html +++ b/docs/design/artboards/d215/index.html @@ -921,6 +921,24 @@ .app.m .v2-artifacts .v2-artifacts__name { white-space: normal; overflow-wrap: anywhere; } .app.m .v2-artifacts .v2-artifacts__open { display: flex; width: 100%; height: 44px; font-size: 14px; } /* artifacts:end */ +/* run trace: the live v2-run-trace__* names (V2RunTrace.tsx), redrawn with the page's own rules. + Scoped to .v2-run-trace, the page's root. New name: __foot. */ +.v2-run-trace { max-width: 880px; min-width: 0; color: var(--ink); font-size: 14px; line-height: 20px; } +.v2-run-trace h1 { font: 700 32px/1.1 var(--f-display); letter-spacing: -0.03em; margin: 16px 0; } +.v2-run-trace h2 { font: 700 20px/1.2 var(--f-display); margin: 0; } +.v2-run-trace p { margin: 0; } +.v2-run-trace__back { color: var(--ink); min-height: 32px; display: inline-flex; align-items: center; } +.v2-run-trace__retention { color: var(--mu); font-size: 12px; margin: 0 0 12px !important; } +.v2-run-trace__summary, .v2-run-trace__call { display: grid; gap: 8px; border: 1px solid var(--b); border-radius: 6px; padding: 16px; margin: 12px 0; min-width: 0; } +.v2-run-trace__meta, .v2-run-trace code { font: 12px/16px var(--f-mono); } +.v2-run-trace code, .v2-run-trace__call strong { overflow-wrap: anywhere; } +.v2-run-trace__turns { list-style: none; margin: 24px 0; padding: 0; } +.v2-run-trace__turns > li { border-top: 1px solid var(--d); padding-top: 16px; margin-top: 16px; display: grid; gap: 8px; } +.v2-run-trace__foot { display: grid; gap: 4px; border-top: 1px solid var(--d); padding-top: 12px; margin-top: 24px; color: var(--mu); font-size: 12px; line-height: 16px; } +.v2-run-trace__foot code { color: var(--mu); } +.app.m .mbody2--trace { padding: 0 16px 16px; overflow: hidden; display: block; } +.app.m .v2-run-trace__back { min-height: 44px; } +/* run-trace:end */ /* first run: the live v2-first-run__* and v2-chat__start* names. The dialog sits inside .app, over the pod. */ .v2-chat__starts { display: grid; grid-template-columns: minmax(0, max-content); gap: 6px; margin: 2px 0 6px 48px; } .v2-chat__start { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; min-height: 32px; padding: 6px 12px; border-radius: 10px; font: 500 13px/1.35 var(--f-body); color: var(--ink); background: linear-gradient(180deg, var(--key-a), var(--key-b)); box-shadow: inset 0 0 0 1px var(--key-edge), var(--sh-key); } @@ -1124,7 +1142,7 @@

Same look. Less said.

  • One screen firstRepeated blocks become a table; rare settings collapse.
  • @@ -1613,6 +1631,17 @@

    Same look. Less said.

    • Class names are the page's own (v2-artifacts__*), so the build copies them. New names: __zero (the card) and __open (its ink key).
    • Day zero has nothing to filter, so it shows no filters. It applies when the total is 0 and no kind, pod or search filter is set, and the page is not loading and has no error. Then the kind segment, the pod segment, the search box and the head's count all drop, and one bordered card (not dashed) takes their place.
    • The card is the only act on the page. Its key opens the account's oldest pod (signup creates My Workspace first), labelled with that pod's name. An account with no pods gets the card without the key.
    • A filtered empty result keeps the controls. With a kind, pod or search set, the page keeps prod's dashed line, Nothing matches. Clear a filter or the search., under the controls, so the way out stays on screen.
    • At 390 the key is full width and 44px tall. Busy is prod's table, unchanged: the pod folds under the name as a mono line, and pod, shared by and size hide.

    Each state, one line

    Day zeroDrawn at 1440 and 390. Total 0, no kind, pod or search set, not loading, no error: no controls, no count, the card.
    BusyDrawn at 1440 and 390. Prod's table and foot, unchanged.
    Filtered, emptyNot drawn. Controls stay; prod's dashed emptyFiltered line under them.
    No podsNot drawn. The day-zero card without its key.
    Loading, errorNot drawn. They keep prod's spinner and __error line.
    +
    +

    How this reply was made

    /v2/pods/:podId/runs/:runId
    +
    +
    After · 1440no pods sidebar, no header: the page owns its h1
    Back to pod

    How this reply was made

    ScoutSucceeded · answered a mention2 turns · 13,951 tokens

    This stored trace was size-limited. Large content fields are capped.

    1. Turn 1

      deepseek-v4-flash · 4210 ms · 9120 tokens

      commonly_agent_statusok · 312 ms

      Built-in tool. No connector credential.

    2. Turn 2

      deepseek-v4-flash · 2890 ms · 4831 tokens

      No tool calls.

    Cards have a 30-day default retention. Pod policy and storage limits can change it. This trace persists after the card expires.

    Run 6a1f3c9e8b2d4f7a1c0e5b93
    +
    +
    +
    Before · 390walk 11-02: “Run trace”, a storage note, raw ids
    Back to pod

    Run trace

    Cards have a 30-day default retention. Pod policy and storage limits can change it. This trace persists after the card expires.

    scoutSucceeded · MentionRecorded turns: 2 · 13951 tokens6a1f3c9e8b2d4f7a1c0e5b93

    This stored trace was size-limited. Large content fields are capped.

    1. Turn 1

      deepseek-v4-flash · 4210 ms · 9120 tokens

      commonly_agent_statusok · 312 ms

      Built-in tool. No connector credential.

    2. Turn 2

      deepseek-v4-flash · 2890 ms · 4831 tokens

      No tool calls.

    Pods
    Needs you
    Team
    Settings
    +
    After · 390display name, plain words, details at the foot
    Back to pod

    How this reply was made

    ScoutSucceeded · answered a mention2 turns · 13,951 tokens

    This stored trace was size-limited. Large content fields are capped.

    1. Turn 1

      deepseek-v4-flash · 4210 ms · 9120 tokens

      commonly_agent_statusok · 312 ms

      Built-in tool. No connector credential.

    2. Turn 2

      deepseek-v4-flash · 2890 ms · 4831 tokens

      No tool calls.

    Cards have a 30-day default retention. Pod policy and storage limits can change it. This trace persists after the card expires.

    Run 6a1f3c9e8b2d4f7a1c0e5b93
    Pods
    Needs you
    Team
    Settings
    +
    • Class names are the page's own (v2-run-trace__*, V2RunTrace.tsx). One new name: __foot. __retention goes, because its sentence moves into the foot.
    • The h1 matches the link the person clicked. runTrace.title reads How this reply was made, the same words as runTrace.view under the reply (zh: 这条回复是怎么来的).
    • The first line is the agent's display name. The page reads the pod roster, GET /api/registry/pods/:podId/agents, the same call the pod chat uses. It matches the run to a roster entry with the shared agentKeyFor (agent name plus instance, the key the chat byline and inspector use) and shows that entry's displayName.
    • No match shows the raw name. While the roster loads, when it fails, or when no entry matches (an agent since removed from the pod), the line shows agentName as recorded, e.g. scout. The roster never blocks the page.
    • The trigger reads as a phrase after the status: mention → answered a mention; heartbeat → ran on its schedule; task.assigned → picked up a task; chat.message → replied in chat; pod.join → welcomed someone to the pod; first_contact → said hello for the first time; manual → was run by hand. A value we do not know shows raw.
    • Counts are plural and grouped: 1 turn · 900 tokens, 2 turns · 13,951 tokens, numbers formatted for the reader's language.
    • The foot carries the record details, muted and small, under a hairline: the retention sentence, then Run <id> in mono. A first-time reader meets the answer before the storage policy.
    • Unchanged: the size-limit notice, every turn, its model line and every tool call with its broker trail (grant, credential owner). Those belong to the connector lane.

    Each state, one line

    Loaded, roster matchedDrawn at 390 and 1440. Display name, plain status line, grouped counts, foot after the turns.
    BeforeDrawn at 390. Today's page: “Run trace”, retention first, raw id lowercase, raw run id in the card.
    Roster loading / failed / no matchNot drawn. Same page; the first line shows the recorded agentName.
    Unknown triggerNot drawn. Succeeded · future-trigger, the raw value.
    Loading, error, runningNot drawn. They keep prod's status line, alert with Try again, and Refresh trace.
    +
    +

    First run

    /v2/pods/:id · Scout welcome + Guide dialog
    helper words welcome – → 16dialog – → 68scroll 390 – → 1.0×
    From df3183dade45a77b9ea5dc3c3465d373b7d2bd65 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Mon, 2 Nov 2026 00:03:37 -0800 Subject: [PATCH 2/3] feat(run-trace): the page a reply links to says how it was made, names the agent, and keeps record details at the foot Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015AKgpMD6Qh13f7fj6mbGT3 --- frontend/src/i18n/locales/en.json | 22 ++-- frontend/src/i18n/locales/zh-CN.json | 21 ++-- frontend/src/v2/__tests__/V2RunTrace.test.tsx | 108 ++++++++++++++++-- frontend/src/v2/components/V2RunTrace.css | 6 +- frontend/src/v2/components/V2RunTrace.tsx | 41 ++++++- 5 files changed, 160 insertions(+), 38 deletions(-) diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index a4a36eea72..e49c55e52c 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -1,14 +1,16 @@ { "runTrace": { - "title": "Run trace", + "title": "How this reply was made", "back": "Back to pod", "view": "How this reply was made", "retention": "Cards have a 30-day default retention. Pod policy and storage limits can change it. This trace persists after the card expires.", + "runId": "Run {{id}}", "loading": "Loading run trace…", "access": "This trace is unavailable, or you no longer have access to its pod.", "error": "Could not load the run trace. Try again.", "retry": "Try again", - "counts": "Recorded turns: {{turns}} · {{tokens}} tokens", + "counts_one": "{{count}} turn · {{tokens}} tokens", + "counts_other": "{{count}} turns · {{tokens}} tokens", "stopped": "Stopped: {{kind}}", "running": "This run is still in progress.", "refresh": "Refresh trace", @@ -31,14 +33,14 @@ "failed": "Failed", "interrupted": "Interrupted" }, - "trigger": { - "mention": "Mention", - "heartbeat": "Heartbeat", - "task.assigned": "Task assignment", - "chat.message": "Chat message", - "pod.join": "Pod join", - "first_contact": "First contact", - "manual": "Manual" + "triggerPhrase": { + "mention": "answered a mention", + "heartbeat": "ran on its schedule", + "task.assigned": "picked up a task", + "chat.message": "replied in chat", + "pod.join": "welcomed someone to the pod", + "first_contact": "said hello for the first time", + "manual": "was run by hand" }, "outcomes": { "ok": "ok", diff --git a/frontend/src/i18n/locales/zh-CN.json b/frontend/src/i18n/locales/zh-CN.json index 58440aede7..e7a0ec2a82 100644 --- a/frontend/src/i18n/locales/zh-CN.json +++ b/frontend/src/i18n/locales/zh-CN.json @@ -1,14 +1,15 @@ { "runTrace": { - "title": "运行轨迹", + "title": "这条回复是怎么来的", "back": "返回 Pod", "view": "这条回复是怎么来的", "retention": "卡片默认保留30天,Pod 策略和存储限制可能改变期限。卡片过期后,运行轨迹仍会保留。", + "runId": "运行 {{id}}", "loading": "正在加载运行轨迹…", "access": "此轨迹不可用,或你已无权访问对应的 Pod。", "error": "无法加载运行轨迹,请重试。", "retry": "重试", - "counts": "已记录{{turns}}轮 · {{tokens}}个 token", + "counts_other": "{{count}}轮 · {{tokens}}个 token", "stopped": "停止原因:{{kind}}", "running": "此运行尚未结束。", "refresh": "刷新轨迹", @@ -31,14 +32,14 @@ "failed": "失败", "interrupted": "已中断" }, - "trigger": { - "mention": "提及", - "heartbeat": "心跳", - "task.assigned": "任务分配", - "chat.message": "聊天消息", - "pod.join": "加入 Pod", - "first_contact": "首次联系", - "manual": "手动" + "triggerPhrase": { + "mention": "回应了一次@提及", + "heartbeat": "按计划运行", + "task.assigned": "领取了一项任务", + "chat.message": "在聊天中回复", + "pod.join": "欢迎新成员加入 Pod", + "first_contact": "第一次打招呼", + "manual": "由人手动运行" }, "outcomes": { "ok": "成功", diff --git a/frontend/src/v2/__tests__/V2RunTrace.test.tsx b/frontend/src/v2/__tests__/V2RunTrace.test.tsx index 780988281a..3818aa719f 100644 --- a/frontend/src/v2/__tests__/V2RunTrace.test.tsx +++ b/frontend/src/v2/__tests__/V2RunTrace.test.tsx @@ -18,10 +18,21 @@ const trace = { toolCalls: [{ name: 'vendor.read', elapsedMs: 5, callId: 'call-1', outcome: 'ok', trail: { grantId: 'grant-1', credentialOwnerId: 'owner-1', outcome: 'ok' } }] }], }; +const ROSTER_URL = `/api/registry/pods/${POD}/agents`; +// The page makes two GETs; route the roster away from the trace mocks so each +// test's mockResolvedValue / mockRejectedValueOnce sequence stays about the trace. +const mockRoster = jest.fn(); +const routeGet = () => mockGet.mockImplementation((url: string) => (url === ROSTER_URL ? mockRoster(url) : mockTrace(url))); +const mockTrace = jest.fn(); const setup = () => render( } /> ); -beforeEach(async () => { mockGet.mockReset(); await i18n.changeLanguage('en'); }); +beforeEach(async () => { + mockGet.mockReset(); mockTrace.mockReset(); mockRoster.mockReset(); + mockRoster.mockResolvedValue({ agents: [] }); + routeGet(); + await i18n.changeLanguage('en'); +}); afterEach(async () => { await i18n.changeLanguage('en'); }); test('server-bound link derives its destination from IDs and refuses arbitrary URLs', () => { const { rerender } = render(); @@ -37,7 +48,7 @@ test('the link reads plainly in Chinese too', async () => { expect(screen.getByRole('link', { name: '这条回复是怎么来的' })).toHaveAttribute('href', `/v2/pods/${POD}/runs/${RUN}`); }); test('reads recorded turns and PG attribution, with honest retention wording', async () => { - mockGet.mockResolvedValue({ run: trace }); + mockTrace.mockResolvedValue({ run: trace }); setup(); await screen.findByText('vendor.read'); expect(mockGet).toHaveBeenCalledWith(`/api/pods/${POD}/runs/${RUN}`); @@ -46,9 +57,82 @@ test('reads recorded turns and PG attribution, with honest retention wording', a expect(screen.getByText(/30-day default retention/)).toBeInTheDocument(); expect(screen.getByText(/This trace persists after the card expires/)).toBeInTheDocument(); }); +test('the h1 repeats the link the person clicked', async () => { + mockTrace.mockResolvedValue({ run: trace }); + setup(); + await screen.findByText('vendor.read'); + expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent(/^How this reply was made$/); + expect(screen.getByRole('region', { name: 'How this reply was made' })).toBeInTheDocument(); +}); +const summaryName = () => document.querySelector('.v2-run-trace__summary strong')?.textContent; +test('the summary names the agent by its roster display name', async () => { + mockRoster.mockResolvedValue({ agents: [ + { name: 'scout', instanceId: 'other', displayName: 'Not this one' }, + { name: 'scout', instanceId: 'default', displayName: 'Scout' }, + ] }); + mockTrace.mockResolvedValue({ run: { ...trace, agentName: 'scout', instanceId: 'default' } }); + setup(); + await waitFor(() => expect(summaryName()).toBe('Scout')); + expect(mockGet).toHaveBeenCalledWith(ROSTER_URL); +}); +test('a named instance matches on name and instance, the way the pod chat keys it', async () => { + mockRoster.mockResolvedValue({ agents: [ + { name: 'openclaw', instanceId: 'default', displayName: 'Wrong' }, + { name: 'openclaw', instanceId: 'nova', displayName: 'Engineer (Nova)' }, + ] }); + mockTrace.mockResolvedValue({ run: { ...trace, agentName: 'openclaw', instanceId: 'nova' } }); + setup(); + await waitFor(() => expect(summaryName()).toBe('Engineer (Nova)')); +}); +test.each([ + ['the roster call fails', () => mockRoster.mockRejectedValue(new Error('boom'))], + ['no roster entry matches', () => mockRoster.mockResolvedValue({ agents: [{ name: 'ada', instanceId: 'default', displayName: 'Ada Lovelace' }] })], +])('the raw agent name shows when %s', async (_label, arrange) => { + arrange(); + mockTrace.mockResolvedValue({ run: { ...trace, agentName: 'scout' } }); + setup(); + await screen.findByText('vendor.read'); + await waitFor(() => expect(mockRoster).toHaveBeenCalled()); + await act(async () => { await Promise.resolve(); }); + expect(summaryName()).toBe('scout'); +}); +test.each([ + ['mention', 'Succeeded · answered a mention'], + ['task.assigned', 'Succeeded · picked up a task'], + ['future-trigger', 'Succeeded · future-trigger'], +])('the status line says the trigger in plain words (%s)', async (trigger, expected) => { + mockTrace.mockResolvedValue({ run: { ...trace, trigger } }); + setup(); + expect(await screen.findByText(expected)).toBeInTheDocument(); +}); +test.each([ + [2, 13951, '2 turns · 13,951 tokens'], + [1, 900, '1 turn · 900 tokens'], +])('counts are plural with grouped tokens (%i turns)', async (turns, tokens, expected) => { + mockTrace.mockResolvedValue({ run: { ...trace, totalTokens: tokens, + turns: Array.from({ length: turns }, (_, turnIndex) => ({ ...trace.turns[0], turnIndex })) } }); + setup(); + expect(await screen.findByText(expected)).toBeInTheDocument(); +}); +test('the retention sentence and run id sit in a foot after the turns', async () => { + mockTrace.mockResolvedValue({ run: trace }); + const { container } = setup(); + await screen.findByText('vendor.read'); + const turns = container.querySelector('.v2-run-trace__turns') as Element; + const retention = screen.getByText(/30-day default retention/); + const runId = screen.getByText(`Run ${RUN}`); + expect(runId.tagName).toBe('CODE'); + for (const node of [retention, runId]) { + // eslint-disable-next-line no-bitwise + expect(turns.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + expect(turns.contains(node)).toBe(false); + } + expect(container.querySelector('.v2-run-trace__summary')).not.toHaveTextContent(RUN); + expect(container.querySelector('.v2-run-trace__foot')).toContainElement(retention); +}); test.each(['en', 'zh-CN'])('withheld authorization identities have no labels or missing-record claims (%s)', async (language) => { await act(async () => { await i18n.changeLanguage(language); }); - mockGet.mockResolvedValue({ run: { ...trace, turns: [{ ...trace.turns[0], toolCalls: [{ + mockTrace.mockResolvedValue({ run: { ...trace, turns: [{ ...trace.turns[0], toolCalls: [{ ...trace.turns[0].toolCalls[0], trail: { outcome: 'ok' }, }] }] } }); setup(); @@ -61,7 +145,7 @@ test.each(['en', 'zh-CN'])('withheld authorization identities have no labels or test.each(['en', 'zh-CN'])('a turn another model answered names both; a normal turn names one (%s)', async (language) => { await act(async () => { await i18n.changeLanguage(language); }); const nemotron = 'openrouter/nvidia/nemotron-3-super-120b-a12b:free'; - mockGet.mockResolvedValue({ run: { ...trace, turns: [ + mockTrace.mockResolvedValue({ run: { ...trace, turns: [ { ...trace.turns[0], model: nemotron, servedModel: 'deepseek-v4-flash', fallbacks: 1 }, { ...trace.turns[0], turnIndex: 1, model: 'deepseek-v4-flash', servedModel: 'deepseek-v4-flash' }, { ...trace.turns[0], turnIndex: 2, model: 'older-turn' }, @@ -76,7 +160,7 @@ test.each(['en', 'zh-CN'])('a turn another model answered names both; a normal t expect(meta[2]).toBe(`older-turn · 12 ms · 123 ${i18n.t('runTrace.tokens')}`); }); test('refusal can retry and never presents an empty successful trace', async () => { - mockGet.mockRejectedValueOnce({ response: { status: 404 } }).mockResolvedValueOnce({ run: trace }); + mockTrace.mockRejectedValueOnce({ response: { status: 404 } }).mockResolvedValueOnce({ run: trace }); setup(); await screen.findByRole('alert'); expect(screen.queryByText('No turns recorded yet.')).not.toBeInTheDocument(); @@ -85,7 +169,7 @@ test('refusal can retry and never presents an empty successful trace', async () await waitFor(() => expect(screen.queryByRole('alert')).not.toBeInTheDocument()); }); test('discloses truncation and missing broker rows without inventing attribution', async () => { - mockGet.mockResolvedValue({ run: { ...trace, traceTruncated: true, omittedTurns: 2, omittedToolCalls: 3, + mockTrace.mockResolvedValue({ run: { ...trace, traceTruncated: true, omittedTurns: 2, omittedToolCalls: 3, turns: [{ ...trace.turns[0], toolCalls: [{ name: 'vendor.read', callId: 'gone', outcome: 'unavailable', trail: null, elapsedMs: 1 }] }] } }); setup(); await screen.findByText('Broker trail unavailable.'); @@ -97,23 +181,25 @@ test.each([ [2, 0, '2 turns are omitted', '0 tool calls'], [0, 0, 'Large content fields are capped', 'are omitted'], ])('size disclosure omits empty counts (%i turns, %i calls)', async (turns, calls, expected, absent) => { - mockGet.mockResolvedValue({ run: { ...trace, traceTruncated: true, omittedTurns: turns, omittedToolCalls: calls } }); + mockTrace.mockResolvedValue({ run: { ...trace, traceTruncated: true, omittedTurns: turns, omittedToolCalls: calls } }); setup(); await screen.findByText(new RegExp(expected)); expect(screen.queryByText(new RegExp(absent))).not.toBeInTheDocument(); }); test('Chinese status, trigger, region label and nonzero truncation clause are localized', async () => { await act(async () => { await i18n.changeLanguage('zh-CN'); }); - mockGet.mockResolvedValue({ run: { ...trace, traceTruncated: true, omittedToolCalls: 2 } }); + mockTrace.mockResolvedValue({ run: { ...trace, traceTruncated: true, omittedToolCalls: 2 } }); setup(); - await screen.findByText('已完成 · 提及'); + await screen.findByText('已完成 · 回应了一次@提及'); + expect(screen.getByText('1轮 · 123个 token')).toBeInTheDocument(); + expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('这条回复是怎么来的'); expect(screen.getByText('成功 · 5 ms')).toBeInTheDocument(); - expect(screen.getByRole('region', { name: '运行轨迹' })).toBeInTheDocument(); + expect(screen.getByRole('region', { name: '这条回复是怎么来的' })).toBeInTheDocument(); expect(screen.getByText(/省略了2次工具调用/)).toBeInTheDocument(); expect(screen.queryByText(/0轮/)).not.toBeInTheDocument(); }); test('future enum values remain visible instead of showing translation keys', async () => { - mockGet.mockResolvedValue({ run: { ...trace, status: 'future-status', trigger: 'future-trigger' } }); + mockTrace.mockResolvedValue({ run: { ...trace, status: 'future-status', trigger: 'future-trigger' } }); setup(); await screen.findByText('future-status · future-trigger'); }); diff --git a/frontend/src/v2/components/V2RunTrace.css b/frontend/src/v2/components/V2RunTrace.css index bfd0ec90de..de1f50a02a 100644 --- a/frontend/src/v2/components/V2RunTrace.css +++ b/frontend/src/v2/components/V2RunTrace.css @@ -1,15 +1,17 @@ .v2-run-trace { max-width: 880px; min-width: 0; color: var(--v2-text-primary); } -.v2-run-trace h1 { font-family: var(--v2-font-display); font-size: 32px; letter-spacing: -0.03em; margin: 16px 0; } +.v2-run-trace h1 { font-family: var(--v2-font-display); font-size: 32px; line-height: 1.1; letter-spacing: -0.03em; margin: 16px 0; overflow-wrap: anywhere; } .v2-run-trace h2 { font-family: var(--v2-font-display); font-size: 20px; margin: 0; } .v2-run-trace__back { color: var(--v2-text-primary); min-height: 32px; display: inline-flex; align-items: center; } /* Under an agent reply: as quiet as a timestamp (d215 s-chat, trace link). */ .v2-run-trace-link a { color: var(--v2-text-secondary); font-size: 12.5px; text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; } .v2-run-trace-link a:hover { color: var(--v2-text-primary); text-decoration: underline; } -.v2-run-trace__retention { color: var(--v2-text-muted); font-size: 12px; } .v2-run-trace__summary, .v2-run-trace__call { display: grid; gap: 8px; border: 1px solid var(--v2-border); border-radius: var(--v2-radius-lg); padding: 16px; margin: 12px 0; min-width: 0; } .v2-run-trace__meta, .v2-run-trace code, .v2-run-trace dd { font-family: var(--v2-font-mono); font-size: 12px; } .v2-run-trace code, .v2-run-trace dd, .v2-run-trace__call strong { overflow-wrap: anywhere; } .v2-run-trace__turns { list-style: none; margin: 24px 0; padding: 0; } +.v2-run-trace__foot { display: grid; gap: 4px; border-top: 1px solid var(--v2-border-soft); padding-top: 12px; margin-top: 24px; color: var(--v2-text-muted); font-size: 12px; line-height: 16px; } +.v2-run-trace__foot p { margin: 0; } +.v2-run-trace__foot code { color: var(--v2-text-muted); } .v2-run-trace__turns > li { border-top: 1px solid var(--v2-border-soft); padding-top: 16px; margin-top: 16px; } .v2-run-trace dl { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px; margin: 8px 0; } .v2-run-trace dd { margin: 0; } diff --git a/frontend/src/v2/components/V2RunTrace.tsx b/frontend/src/v2/components/V2RunTrace.tsx index b72eb22bba..1a2ab52e0f 100644 --- a/frontend/src/v2/components/V2RunTrace.tsx +++ b/frontend/src/v2/components/V2RunTrace.tsx @@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Link, useParams } from 'react-router-dom'; import { useV2Api } from '../hooks/useV2Api'; +import { agentKeyFor } from '../utils/agentKey'; import './V2RunTrace.css'; export interface RunTrace { @@ -18,6 +19,9 @@ export interface RunTrace { }>; } +interface RosterAgent { name?: string; agentName?: string; instanceId?: string; displayName?: string; profile?: { displayName?: string } } + + const V2RunTrace: React.FC = () => { const { t, i18n } = useTranslation(); const { podId, runId } = useParams<{ podId: string; runId: string }>(); @@ -25,6 +29,7 @@ const V2RunTrace: React.FC = () => { const [trace, setTrace] = useState(null); const [error, setError] = useState(''); const [attempt, setAttempt] = useState(0); + const [roster, setRoster] = useState([]); const retry = useCallback(() => setAttempt((value) => value + 1), []); useEffect(() => { let live = true; @@ -37,23 +42,45 @@ const V2RunTrace: React.FC = () => { }); return () => { live = false; }; }, [api, podId, runId, attempt, t]); + // The pod roster only names the agent; the trace renders without it. + useEffect(() => { + let live = true; + setRoster([]); + api.get<{ agents?: RosterAgent[] }>(`/api/registry/pods/${encodeURIComponent(podId || '')}/agents`) + .then((data) => { if (live && Array.isArray(data?.agents)) setRoster(data.agents); }) + .catch(() => undefined); + return () => { live = false; }; + }, [api, podId]); - const enumLabel = (group: 'status' | 'trigger' | 'outcomes', value: string) => t(`runTrace.${group}.${value}`, { defaultValue: value }); + const enumLabel = (group: 'status' | 'outcomes', value: string) => t(`runTrace.${group}.${value}`, { defaultValue: value }); + // Trigger values carry dots (task.assigned), so look them up in the object, not by key path. + const triggerPhrase = (value: string) => { + const phrases = t('runTrace.triggerPhrase', { returnObjects: true }) as unknown; + const phrase = phrases && typeof phrases === 'object' ? (phrases as Record)[value] : undefined; + return typeof phrase === 'string' ? phrase : value; + }; + const agentLabel = (run: RunTrace) => { + // The same composite key the chat byline and inspector use (utils/agentKey). + const key = agentKeyFor(run); + const match = roster.find((agent) => agentKeyFor(agent) === key); + return match?.displayName || match?.profile?.displayName || run.agentName; + }; const limitedKey = trace?.omittedTurns && trace?.omittedToolCalls ? 'limitedBoth' : trace?.omittedTurns ? 'limitedTurns' : trace?.omittedToolCalls ? 'limitedCalls' : 'limitedContent'; return
    {t('runTrace.back')}

    {t('runTrace.title')}

    -

    {t('runTrace.retention')}

    {!trace && !error &&

    {t('runTrace.loading')}

    } {error &&

    {error}

    } {trace && <>
    - {trace.agentName}{enumLabel('status', trace.status)} · {enumLabel('trigger', trace.trigger)} - {t('runTrace.counts', { turns: trace.turns.length, tokens: trace.totalTokens })} + {agentLabel(trace)}{enumLabel('status', trace.status)} · {triggerPhrase(trace.trigger)} + {t('runTrace.counts', { + count: trace.turns.length, + tokens: new Intl.NumberFormat(i18n.resolvedLanguage).format(trace.totalTokens), + })} - {trace.id} {trace.errorKind && {t('runTrace.stopped', { kind: trace.errorKind })}} {['queued', 'running'].includes(trace.status) &&

    {t('runTrace.running')}

    }
    @@ -77,6 +104,10 @@ const V2RunTrace: React.FC = () => { )} )} +
    +

    {t('runTrace.retention')}

    + {t('runTrace.runId', { id: trace.id })} +
    }
    ; }; From d80fd66409b37227102aff55ea2f6621f574980a Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Mon, 2 Nov 2026 00:07:22 -0800 Subject: [PATCH 3/3] fix(run-trace): keep the retention rule the task record intro uses; ignore malformed roster entries Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015AKgpMD6Qh13f7fj6mbGT3 --- docs/design/artboards/d215/index.html | 2 +- frontend/src/v2/__tests__/V2RunTrace.test.tsx | 1 + frontend/src/v2/__tests__/v2-layout-invariants.test.ts | 10 ++++++++++ frontend/src/v2/components/V2RunTrace.css | 2 ++ frontend/src/v2/components/V2RunTrace.tsx | 6 +++++- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/design/artboards/d215/index.html b/docs/design/artboards/d215/index.html index 5c4e309793..c703aa0663 100644 --- a/docs/design/artboards/d215/index.html +++ b/docs/design/artboards/d215/index.html @@ -1639,7 +1639,7 @@

    Same look. Less said.

    Before · 390walk 11-02: “Run trace”, a storage note, raw ids
    Back to pod

    Run trace

    Cards have a 30-day default retention. Pod policy and storage limits can change it. This trace persists after the card expires.

    scoutSucceeded · MentionRecorded turns: 2 · 13951 tokens6a1f3c9e8b2d4f7a1c0e5b93

    This stored trace was size-limited. Large content fields are capped.

    1. Turn 1

      deepseek-v4-flash · 4210 ms · 9120 tokens

      commonly_agent_statusok · 312 ms

      Built-in tool. No connector credential.

    2. Turn 2

      deepseek-v4-flash · 2890 ms · 4831 tokens

      No tool calls.

    Pods
    Needs you
    Team
    Settings
    After · 390display name, plain words, details at the foot
    Back to pod

    How this reply was made

    ScoutSucceeded · answered a mention2 turns · 13,951 tokens

    This stored trace was size-limited. Large content fields are capped.

    1. Turn 1

      deepseek-v4-flash · 4210 ms · 9120 tokens

      commonly_agent_statusok · 312 ms

      Built-in tool. No connector credential.

    2. Turn 2

      deepseek-v4-flash · 2890 ms · 4831 tokens

      No tool calls.

    Cards have a 30-day default retention. Pod policy and storage limits can change it. This trace persists after the card expires.

    Run 6a1f3c9e8b2d4f7a1c0e5b93
    Pods
    Needs you
    Team
    Settings
    -
    • Class names are the page's own (v2-run-trace__*, V2RunTrace.tsx). One new name: __foot. __retention goes, because its sentence moves into the foot.
    • The h1 matches the link the person clicked. runTrace.title reads How this reply was made, the same words as runTrace.view under the reply (zh: 这条回复是怎么来的).
    • The first line is the agent's display name. The page reads the pod roster, GET /api/registry/pods/:podId/agents, the same call the pod chat uses. It matches the run to a roster entry with the shared agentKeyFor (agent name plus instance, the key the chat byline and inspector use) and shows that entry's displayName.
    • No match shows the raw name. While the roster loads, when it fails, or when no entry matches (an agent since removed from the pod), the line shows agentName as recorded, e.g. scout. The roster never blocks the page.
    • The trigger reads as a phrase after the status: mention → answered a mention; heartbeat → ran on its schedule; task.assigned → picked up a task; chat.message → replied in chat; pod.join → welcomed someone to the pod; first_contact → said hello for the first time; manual → was run by hand. A value we do not know shows raw.
    • Counts are plural and grouped: 1 turn · 900 tokens, 2 turns · 13,951 tokens, numbers formatted for the reader's language.
    • The foot carries the record details, muted and small, under a hairline: the retention sentence, then Run <id> in mono. A first-time reader meets the answer before the storage policy.
    • Unchanged: the size-limit notice, every turn, its model line and every tool call with its broker trail (grant, credential owner). Those belong to the connector lane.

    Each state, one line

    Loaded, roster matchedDrawn at 390 and 1440. Display name, plain status line, grouped counts, foot after the turns.
    BeforeDrawn at 390. Today's page: “Run trace”, retention first, raw id lowercase, raw run id in the card.
    Roster loading / failed / no matchNot drawn. Same page; the first line shows the recorded agentName.
    Unknown triggerNot drawn. Succeeded · future-trigger, the raw value.
    Loading, error, runningNot drawn. They keep prod's status line, alert with Try again, and Refresh trace.
    +
    • Class names are the page's own (v2-run-trace__*, V2RunTrace.tsx). One new name: __foot. __retention stays: this page no longer uses it, but the task record page renders its intro with it.
    • The h1 matches the link the person clicked. runTrace.title reads How this reply was made, the same words as runTrace.view under the reply (zh: 这条回复是怎么来的).
    • The first line is the agent's display name. The page reads the pod roster, GET /api/registry/pods/:podId/agents, the same call the pod chat uses. It matches the run to a roster entry with the shared agentKeyFor (agent name plus instance, the key the chat byline and inspector use) and shows that entry's displayName.
    • No match shows the raw name. While the roster loads, when it fails, or when no entry matches (an agent since removed from the pod), the line shows agentName as recorded, e.g. scout. The roster never blocks the page.
    • The trigger reads as a phrase after the status: mention → answered a mention; heartbeat → ran on its schedule; task.assigned → picked up a task; chat.message → replied in chat; pod.join → welcomed someone to the pod; first_contact → said hello for the first time; manual → was run by hand. A value we do not know shows raw.
    • Counts are plural and grouped: 1 turn · 900 tokens, 2 turns · 13,951 tokens, numbers formatted for the reader's language.
    • The foot carries the record details, muted and small, under a hairline: the retention sentence, then Run <id> in mono. A first-time reader meets the answer before the storage policy.
    • Unchanged: the size-limit notice, every turn, its model line and every tool call with its broker trail (grant, credential owner). Those belong to the connector lane.

    Each state, one line

    Loaded, roster matchedDrawn at 390 and 1440. Display name, plain status line, grouped counts, foot after the turns.
    BeforeDrawn at 390. Today's page: “Run trace”, retention first, raw id lowercase, raw run id in the card.
    Roster loading / failed / no matchNot drawn. Same page; the first line shows the recorded agentName.
    Unknown triggerNot drawn. Succeeded · future-trigger, the raw value.
    Loading, error, runningNot drawn. They keep prod's status line, alert with Try again, and Refresh trace.
    diff --git a/frontend/src/v2/__tests__/V2RunTrace.test.tsx b/frontend/src/v2/__tests__/V2RunTrace.test.tsx index 3818aa719f..2be414cd09 100644 --- a/frontend/src/v2/__tests__/V2RunTrace.test.tsx +++ b/frontend/src/v2/__tests__/V2RunTrace.test.tsx @@ -87,6 +87,7 @@ test('a named instance matches on name and instance, the way the pod chat keys i test.each([ ['the roster call fails', () => mockRoster.mockRejectedValue(new Error('boom'))], ['no roster entry matches', () => mockRoster.mockResolvedValue({ agents: [{ name: 'ada', instanceId: 'default', displayName: 'Ada Lovelace' }] })], + ['the roster carries a null entry', () => mockRoster.mockResolvedValue({ agents: [null, 'x', { name: 'ada', instanceId: 'default', displayName: 'Ada Lovelace' }] })], ])('the raw agent name shows when %s', async (_label, arrange) => { arrange(); mockTrace.mockResolvedValue({ run: { ...trace, agentName: 'scout' } }); diff --git a/frontend/src/v2/__tests__/v2-layout-invariants.test.ts b/frontend/src/v2/__tests__/v2-layout-invariants.test.ts index 46ca3314bd..0537e4df7b 100644 --- a/frontend/src/v2/__tests__/v2-layout-invariants.test.ts +++ b/frontend/src/v2/__tests__/v2-layout-invariants.test.ts @@ -5693,6 +5693,16 @@ describe('run trace layout', () => { const phone = css.slice(css.indexOf('@media (max-width: 760px)')); expect(phone).toMatch(/[,{]\s*\.v2-run-trace-link a[,\s][^{]*\{[^}]*min-height: 44px/); }); + test('every run-trace class the task record page renders keeps a rule in the sheet it imports', () => { + // V2TaskRecord imports V2RunTrace.css; a class it still renders must not lose its rule when the run + // trace page stops using it (#3322 review: __retention dropped, the record intro went full size). + const record = read('../components/V2TaskRecord.tsx'); + expect(record).toContain("import './V2RunTrace.css'"); + const used = [...new Set([...record.matchAll(/v2-run-trace__[a-z-]+/g)].map((m) => m[0]))]; + expect(used.length).toBeGreaterThan(0); + used.forEach((name) => expect(css).toContain(`.${name}`)); + expect(ruleBody(css, '.v2-run-trace__retention')).toContain('color: var(--v2-text-muted)'); + }); test('task record downloads wrap at 390 rather than push the page sideways (TASK-562)', () => { expect(ruleBody(css, '.v2-task-record__downloads')).toContain('flex-wrap: wrap'); expect(ruleBody(css, '.v2-task-record__entries')).toContain('list-style: none'); diff --git a/frontend/src/v2/components/V2RunTrace.css b/frontend/src/v2/components/V2RunTrace.css index de1f50a02a..4c90ee0858 100644 --- a/frontend/src/v2/components/V2RunTrace.css +++ b/frontend/src/v2/components/V2RunTrace.css @@ -5,6 +5,8 @@ /* Under an agent reply: as quiet as a timestamp (d215 s-chat, trace link). */ .v2-run-trace-link a { color: var(--v2-text-secondary); font-size: 12.5px; text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; } .v2-run-trace-link a:hover { color: var(--v2-text-primary); text-decoration: underline; } +/* The task record page's intro line (V2TaskRecord imports this sheet). */ +.v2-run-trace__retention { color: var(--v2-text-muted); font-size: 12px; } .v2-run-trace__summary, .v2-run-trace__call { display: grid; gap: 8px; border: 1px solid var(--v2-border); border-radius: var(--v2-radius-lg); padding: 16px; margin: 12px 0; min-width: 0; } .v2-run-trace__meta, .v2-run-trace code, .v2-run-trace dd { font-family: var(--v2-font-mono); font-size: 12px; } .v2-run-trace code, .v2-run-trace dd, .v2-run-trace__call strong { overflow-wrap: anywhere; } diff --git a/frontend/src/v2/components/V2RunTrace.tsx b/frontend/src/v2/components/V2RunTrace.tsx index 1a2ab52e0f..1a9bf58327 100644 --- a/frontend/src/v2/components/V2RunTrace.tsx +++ b/frontend/src/v2/components/V2RunTrace.tsx @@ -47,7 +47,11 @@ const V2RunTrace: React.FC = () => { let live = true; setRoster([]); api.get<{ agents?: RosterAgent[] }>(`/api/registry/pods/${encodeURIComponent(podId || '')}/agents`) - .then((data) => { if (live && Array.isArray(data?.agents)) setRoster(data.agents); }) + .then((data) => { + if (live && Array.isArray(data?.agents)) { + setRoster(data.agents.filter((agent): agent is RosterAgent => Boolean(agent) && typeof agent === 'object')); + } + }) .catch(() => undefined); return () => { live = false; }; }, [api, podId]);