Skip to content

fix(app): drop removed queued attachment references - #55180

Closed
dakjdakd wants to merge 1 commit into
anomalyco:devfrom
dakjdakd:queued-attachments
Closed

dakjdakd wants to merge 1 commit into
anomalyco:devfrom
dakjdakd:queued-attachments

Conversation

@dakjdakd

Copy link
Copy Markdown

Issue for this PR

Closes #55179

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes the replacement prompt sent when a queued message with ordinary text and a path attachment is edited. Removing the attachment card now removes its generated path reference from the replacement text. Keeping the card while changing the prompt text produces one reference instead of two. Review and browser comment notes attached to the original queued message continue to accompany the edit.

The composer restores the original message's display text separately from its attachment cards. The full model-visible text contains more than that display text: buildPromptRequest appends path references and comment notes. Before this change, editedPromptInput rebuilt the replacement request from the editor, then copied the original text's entire suffix back as retained notes. That suffix included the original path references. As a result, a removed attachment survived in the request text even though its metadata was empty, while a retained attachment appeared both in the newly built request and in the copied suffix.

For a concrete example, editing summarize data with /repo/confidential.csv to Use only public data and removing the card previously submitted the new instruction followed by the old file reference. With this change, the old reference is absent. If the card remains, the replacement still refers to /repo/confidential.csv, but only once.

The change uses the existing readPromptPresentation decoder to identify an app-owned presentation when there is a hidden suffix to retain. It then reconstructs that suffix from the decoded comments using the existing file-comment and note-comment formatters. The current request remains responsible for generating references for the attachments actually present in the editor. This separates the two kinds of generated content without parsing or rewriting the user's prompt text.

Messages from another client may have display text and additional context without the app's structured comments list. Their opaque suffix remains unchanged. A user-typed phrase such as Attached file: /repo/user-typed.txt also remains in the edited text. Stored file context continues through the existing admission path, so preserving a review note does not discard the file that note refers to.

The production change is confined to the suffix handling in queue.ts, where the app already has both the original presentation and the newly built request. It applies to queued messages with non-empty display text and a hidden generated suffix. This keeps ownership clear: current composer attachments generate path references, and original structured comments generate retained notes.

How did you verify your code works?

Extended the existing session-queue.spec.ts keeper with a two-case table for removing and retaining a path attachment. Each case checks the actual replacement request text, its attachment metadata, retained review and browser comments, a literal attachment-looking phrase in the user's text, and the review comment's stored file URI. The assertions confirm that removing the card removes its generated reference and retaining it sends that reference exactly once.

A further keeper case verifies that opaque suffix context from another client survives editing. The five focused browser checks, including the existing deleted-file-mention and comment-only cases, pass locally in Chromium 143. The comment-only test now waits for the editor to gain focus before sending its editing keys, matching the queue's asynchronous focus restoration.

Package-level bun typecheck passes, with the tracked custom-element declaration symlink resolved locally for the Windows check. Focused linting of the two changed files reports no warnings or errors, and git diff --check passes.

To exercise the same scenarios from packages/app, run the existing keeper with one worker:

bun run test:e2e -- e2e/regression/session-queue.spec.ts --grep 'editing (removes|keeps once|a comment-only|drops a file|preserves opaque)' --workers=1

Screenshots / recordings

No visual layout changes. The regression assertions inspect the replacement request because the defect is an unwanted or duplicated reference in its model-visible text.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

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.

The fix works and the change looks sound. I ran the new e2e cases against the base version of queue.ts: the "removes" and "keeps once" path-attachment cases fail there, each with one extra Attached file: line in the request text. With this PR, all five targeted queue-editing tests pass, and bun run typecheck in packages/app passes.

The rebuilt suffix matches how buildPromptRequest puts the text together: the user's text, then path references, then comment notes, each joined with a newline and written by the same formatters. So comments survive in the same form while path references now come only from the attachments still in the editor. Messages from other clients, which have no comments list, keep their suffix untouched. The comments metadata is still carried over, so editing the same message twice also works.

Public API: unchanged (internal app code only).

No blocking concerns.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editing queued messages retains removed path attachment references

1 participant