Repository navigation
fix(native-chat): name and mark the expired attachment when a send is refused - #37552
Conversation
The claim step knew which uploads were gone but threw a bare error, so the refusal could only say "This attachment expired". It now carries each expired upload's id and file name: every client names them, and desktop marks those image chips. Older hosts and clients keep today's generic words.
|
No actionable comments were generated in the recent review.
|
| const recognizable = expired | ||
| .map(({ name }) => name) | ||
| .filter((name) => !isNativeChatPastedImagePath(name) && !isNativeChatPastedTextPath(name)) | ||
| return [...new Set(recognizable)] |
There was a problem hiding this comment.
Keep upload IDs out of the expired-file notice.
If a message references a missing upload without a filename, agentSessionAttachmentReferenceNames sets name to its upload ID. This filter treats that ID as a recognizable filename. The notice then displays a UUID followed by “expired” instead of the generic attachment warning. Keep the ID in expiredAttachments for identification, but exclude fallback IDs when selecting notice names. The existing reference-name test covers the filename-free input. (raw.githubusercontent.com)
ELI5
When a chat message has several files and one has expired on the computer running the chat, Orca now says which one, and desktop marks that image in the composer. Before, it said "This attachment expired" and every image looked fine.
What Changed
Before: on a paired server, a draft with one expired image and one fresh image came back with "This attachment expired. Your message was not sent. Remove it and attach it again." Both thumbnails looked the same, so the user had to guess.
After:
orca-paste-…pngis left out of the words, since nobody would recognise it. If only pastes expired, the notice keeps the old wording, and desktop still marks an expired pasted image's chip.Mechanism:
claimAgentSessionAttachmentsInTransactionalready checked each upload, but it stopped at the first missing one and threw an error with no facts. It now collects every expired upload and throws them with their ids and file names, read from the message because the files are gone. The refusal carries them as an optionaldetails.expiredAttachments, and the shared notice words read it. The whole send still rolls back, and the message still returns to the composer.Why
The host is the only side that knows what expired: a paired client doesn't re-check its chips before Send. So the fact has to come from the host's refusal, which also gives desktop, phone and paired clients the same answer from one change.
Upload ids identify the chips because two uploads can share a file name, and matching by name could mark the fresh one. The chip reuses
unavailableNamerather than adding a new state, so holding Send and filling the slot on re-attach already work.Linked Issue
Linear: STA-13095
Visual Proof
Paired server, one image past the 7-day limit and removed by the real sweep, one fresh image, real Send.
Before (host built from main):
(screenshot removed: contained real product data)
After:
(screenshot removed: contained real product data)
After, an image and a dropped file both expired:
(screenshot removed: contained real product data)
After removing the marked chip: the fresh image sends and the agent answers.
(screenshot removed: contained real product data)
Testing
macOS, two hidden dev builds paired over the LAN. I dropped real files onto the composer, aged an upload's folder past 7 days, restarted the host so its real sweep removed it, and pressed Send.
Phone: covered by tests only (
mobile/src/session/agent-session-write-notice-copy.test.ts), not run on a device or simulator. Linux, Windows and SSH were not run; the name parsing test runs on the Linux path form, and the Windows forms were checked with a read-only probe during review.To try it: pair a client with a dev host, attach two images in a chat, run
touch -t 202610200000 <userData>/agent-session-attachments/<one upload id>, restart the host, wait about a minute for the sweep, then press Send on the client.Risk
Level: Low
The riskiest part is the new optional refusal field crossing versions and being saved. Older clients drop it and older hosts don't send it, and both show today's words. A receipt or journal row carrying it would read as unreadable or newer on a downgraded build; the journal schema declares it, and I found no journal writer that stores this refusal. If name parsing goes wrong, the user sees a wrong name in the notice; the send is still refused as before. A plain revert backs this out.
Known limits, unchanged by this PR:
@"…path…"text rather than a pill after any refused send.AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
agent-session-legacy-refusal-fields.tsis a move out ofagent-session-refusal-details.tsto stay under the line cap, with no behaviour change. New strings are in all 11 locale catalogs on desktop and mobile. The name is read from the client's own message and passed throughsanitizeAgentSessionAttachmentName, and the list is capped at 32 entries.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)