Skip to content

fix(native-chat): name and mark the expired attachment when a send is refused - #37552

Merged
AmoabaKelvin merged 2 commits into
mainfrom
fix/expired-attachment-names-file
Nov 3, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
fix/expired-attachment-names-file

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​151 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​146
Prod 50 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​447 $\color{#cf222e}{\Huge{\mathbf{−}}}$​138 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​309

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:

  • The notice names the file: "old-diagram.png expired. Your message was not sent. Remove it and attach it again." Up to three names are listed, then "…". Several files read "Remove them and attach them again."
  • On desktop, the expired image's chip turns into the existing "Attach again" chip and holds Send. The fresh image stays as it was and sends once the other is removed.
  • Phone: the notice names the file, and that name matches the file card, which already shows the host's stored name. Phone images don't use this store, so they never get this refusal.
  • A generated paste name such as orca-paste-…png is 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: claimAgentSessionAttachmentsInTransaction already 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 optional details.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 unavailableName rather 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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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.

  • New client and new host: named notice and marked chip, as in the captures. After removing the chip, the fresh image reached Claude.
  • New client and a host built from main: the old wording and plain chips, so mixed versions fall back cleanly.
  • Older client and new host: not run. By code, the reader rebuilds only the fields it lists, so the new field is dropped.

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:

  • A file reference comes back as raw @"…path…" text rather than a pill after any refused send.
  • Editing a queued message names the file but doesn't mark its chip.
  • A new chat's launch prompt treats this refusal as an unknown outcome, so it shows the "couldn't confirm" wording. Its uploads are made at launch, so they shouldn't be 7 days old.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

agent-session-legacy-refusal-fields.ts is a move out of agent-session-refusal-details.ts to 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 through sanitizeAgentSessionAttachmentName, and the list is capped at 32 entries.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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.
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2d66034b-14ac-4048-9f76-eb02d5bf845b
Commits

Reviewing files that changed from the base of the PR and between a2842cd and 29ac461.

Files selected for processing: 1
  • src/shared/agent-session/failures/agent-session-refusal-notice.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Walkthrough

Expired attachment errors now carry attachment IDs and names through refusal details. Refusal notices can identify expired files and provide remove-and-reattach instructions. When a refused message returns to the composer, expired images are marked unavailable. English, mobile, and renderer translations were added, with tests covering name extraction, refusal details, notices, and composer hand-back.

Merge Risk: Low · up to 29ac4

Some expired attachments may show an opaque UUID instead of a helpful generic notice; the issue is confusing but does not block recovery.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.87% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: naming and marking expired attachments when a native-chat send is refused.
Description check Passed The description is complete and focused. It includes the ELI5 summary, user-visible behavior, implementation details, rationale, linked issue identifier, visual proof, testing results and limitations,…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is complete and focused. It includes the ELI5 summary, user-visible behavior, implementation details, rationale, linked issue identifier, visual proof, testing results and limitations, risk assessment, AI disclosure section, compatibility notes, and checklist.

Full details: Docstring Coverage

Explanation

Docstring coverage is 60.87% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 23 functions across 32 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Comment on lines +47 to +50
const recognizable = expired
.map(({ name }) => name)
.filter((name) => !isNativeChatPastedImagePath(name) && !isNativeChatPastedTextPath(name))
return [...new Set(recognizable)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

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)

@AmoabaKelvin
AmoabaKelvin merged commit 4e841b7 into main Nov 3, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant