Repository navigation
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
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.
|
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:
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. |
Issue for this PR
Closes #55179
Type of change
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:
buildPromptRequestappends path references and comment notes. Before this change,editedPromptInputrebuilt 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 datawith/repo/confidential.csvtoUse only public dataand 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
readPromptPresentationdecoder 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.txtalso 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.tskeeper 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 typecheckpasses, 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, andgit diff --checkpasses.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=1Screenshots / 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