Repository navigation
fix(agents): stop agent rows showing pasted data as their name - #37551
Conversation
The card only shows task when no "You" line exists, so the label never rendered.
Findings
|
| const trimmed = prompt.trim() | ||
| if (!trimmed || isTerseAgentFollowUpPrompt(trimmed)) { | ||
| const title = getAgentRowPrimaryText({ prompt }) | ||
| if (!title || (!isOrcaDispatchPrompt(prompt) && isTerseAgentFollowUpPrompt(title))) { |
There was a problem hiding this comment.
Do not revive a stale orchestration label for pasted data.
If a worker has moved to a new task and then receives a JSON prompt, this returns null. orchestrationLabelForEntry then selects the old dispatch label before the newer task in history. Use the prompt and history to distinguish a filtered prompt from a terse follow-up before retaining sticky metadata. (raw.githubusercontent.com)
| const ATTACHED_FILE_LEAD = /^<file name="([^"]+)/ | ||
| const ATTACHED_FILE_CLOSER = '</file>' | ||
| // Openers people don't type: a keyed object, an array of objects or strings, an XML or HTML document. | ||
| const PASTED_DATA_LEAD = /^(?:\{\s*"[^"]*"\s*:|\[\s*\{\s*"|\[\s*"[^"]*"\s*,|<\?xml\s|<!doctype\s)/i |
There was a problem hiding this comment.
Handle complete JSON arrays without trailing instructions.
A pasted array such as [1, 2, 3] or ["only"] does not match this pattern, so the row still displays raw pasted data. Detect complete arrays while preserving prompts such as [1, 2, 3] should come back sorted. (raw.githubusercontent.com)
| const text = prompt.trim() | ||
| const attachedFile = ATTACHED_FILE_LEAD.exec(text) | ||
| if (attachedFile) { | ||
| const closer = text.lastIndexOf(ATTACHED_FILE_CLOSER) |
There was a problem hiding this comment.
Stop scanning at the end of the attachments.
For <file name="/a.txt">x</file> Explain the </file> tag, this selects the marker in the typed instruction and returns only tag. Parse consecutive attachment blocks without searching the remaining instruction text. (raw.githubusercontent.com)
ELI5
If you paste a chunk of JSON into Pi, or start Pi with a file attached, the agent's row in the sidebar used that paste as its name. It now shows the file's name, or the agent's state when there is nothing better. Prompts you actually typed read the same as before.
What Changed
Before, on a pane with no terminal title, a row read
{ "tool": "orca diagnostics", "takenAt": "2026-…or<file name="/home/….After:
report.txtDoneorWorking, with the agent's reply on the line belowLabels now go through
getAgentPromptLabelinagent-row-primary-text.ts, called fromgetAgentRowPrimaryText. That covers the sidebar, dashboard rows, the review notes send menu and the activity summary. Three routes that read the prompt themselves now use it too:entry.promptitself is not changed, so turn tracking, search and what goes over the wire behave as before.Why
Labels treated the prompt preview as a name, but nothing makes a preview start with what the user wrote. Fixing it where the label is chosen keeps the stored prompt intact. Stripping pasted data out of
entry.promptwould make different prompts compare equal where the status store compares them (promptInteractionKey,sessionBoundary, done-row updates), and JSON-only prompts would become empty.Detection only matches openers people don't type: a quoted key and colon, an array of objects or strings,
<?xml,<!doctype, and Pi's exact<file name=".{foo} is undefined,[WIP] fix loginand<my-custom-element> render thisstay as written.Linked Issue
Fixes #29842
STA-10874
Visual Proof
Real Pi 1.5.0 in a hidden dev build, with one attached-file session, one pasted-JSON session and one typed prompt.
Testing
Reproduced on macOS with real Pi 1.5.0 against a local fake model endpoint. Before matches the report, and after shows the table above.
A stock local Pi sets its own terminal title, so those rows read
Pi - <folder>and never reach this fallback, before or after this change. To get the state the report describes (the host gives no title), I used a throwaway Pi extension that strips title sequences. A second one delays Pi's startup so the CLI's first prompt reaches the row (see Notes).The new assertions fail without the fix and pass with it. Dependent tests pass on desktop and mobile.
Mobile is covered by unit test only, not run on a device. SSH, paired hosts, Linux and Windows were not run; the change is string handling in shared code with no platform branches.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Risk
The riskiest part is detection hiding a real prompt. A typed prompt that opens with real JSON, such as
{"a": 1} why is b missing?, shows the state label instead of the words, because the preview can't reliably tell where the JSON ends. The transcript and the board's "You" line still show it.Other known limits: a file whose contents include
</file>inside the preview can label as file text, and a generated tab title from an attached file keeps only the part before the first dot, soreport.txtbecomes "Report".No saved data or wire format changes. Older phones keep showing the raw prompt until they update. A plain revert backs it out.
Level: Low
AI Disclosure
Review
Needs blessing, because what a row shows for pasted data is a judgment call.
To try it, run
pnpm devfrom/Users/kelvinamoaba/orca/workspaces/orca/sta-10874-pi-row-pasted-promptand set the sidebar agent activity to full rows. A stock local Pi showsPi - <folder>, so hide the title first by saving this asno-title.ts:Then run
pi -e no-title.ts, paste a JSON object and press Enter. The row readsWorking, thenDone. Type a normal prompt and the row reads that prompt.Agent skill upstream boundary
Notes
Security: labels stay plain text. Cross-platform: file names handle both
/and\. Remote SSH: no host or path decisions. Mobile: uses the shared function, andsrc/sharedstill reaches nonode:*import. Backwards compatibility: no wire change. Performance: anchored regexes on a preview of at most 200 characters, or 512 for titles.Found while reproducing, not fixed here:
Pi - <folder>, because that title is accepted as the row's name. So this fix only shows up where the title is missing, and local rows never show the prompt at all.pi @file "..."launch often loses its first prompt. Pi firesbefore_agent_startandagent_start1 ms apart, and ifsession_start's post is still in flight, the extension's latest-only post queue overwrites the prompt. I saw this in a real run through a hook tap./namereaches the row only through the terminal title, so a pane with no title doesn't get it.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)