Skip to content

fix(wework): prevent duplicate pasted messages across chats - #2063

Closed
qdaxb wants to merge 2 commits into
mainfrom
fix/wework-duplicate-pasted-message
Closed

qdaxb wants to merge 2 commits into
mainfrom
fix/wework-duplicate-pasted-message

Conversation

@qdaxb

@qdaxb qdaxb commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

What

  • scope buffered composer drafts to the active chat/task
  • discard stale buffered text when a reused composer switches conversations
  • add a regression test for switching chats, pasting the previous text, and pressing Enter
  • document the scoped-draft interaction invariant

Why

The buffered composer previously treated an unchanged external value as proof that its local draft still belonged to the current chat. After stopping a task and opening a new chat, both external values could be empty while the component instance was reused, so pasting the previous text could combine with stale hidden draft state and submit duplicate content.

Verification

  • pnpm --filter wework test (180 files / 1820 tests passed)
  • pnpm --filter wework exec vitest run src/components/layout/BufferedChatInput.test.tsx
  • pnpm --filter wework exec tsc --noEmit
  • Wework pre-push ESLint, TypeScript, and unit test checks
  • isolated Wework flow: send → stop → new chat → paste the same text → Enter; one submitted copy

Summary by CodeRabbit

  • Bug Fixes

    • Buffered chat drafts are now isolated to their current conversation or task.
    • Switching chats no longer carries over hidden composer text or stale draft content.
    • Draft insertions and submissions now respect the active conversation context.
  • Documentation

    • Updated interaction-state guidance to document conversation-scoped composer drafts.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 054138c1-98d9-44e8-8100-5db21298f1fb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Buffered composer drafts are now scoped to the active project chat. Workbench context values expose scopeKey, BufferedChatInput validates draft reuse against that scope, and tests cover scope changes and submission behavior.

Changes

Conversation draft scoping

Layer / File(s) Summary
Propagate chat scope keys
wework/src/components/chat/ChatInput.tsx, wework/src/features/workbench/WorkbenchProvider.tsx
ProjectChatControls and both project chat context values now expose scopeKey, with memoization dependencies updated for scope changes.
Scope buffered draft state
wework/src/components/layout/BufferedChatInput.tsx, wework/src/components/layout/BufferedChatInput.test.tsx, wework/DESIGN.md
Buffered drafts and insertion handling now require matching scope and source values; tests and design policy cover discarding drafts after scope changes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • wecode-ai/Wegent#1855: Addresses workbench composer state preservation during auxiliary-page navigation, complementing this change’s conversation-scoped draft handling.

Suggested reviewers: icycrystal4

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: preventing duplicate pasted messages by scoping buffered drafts across chats.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wework-duplicate-pasted-message

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 @coderabbitai help to get the list of available commands.

@qdaxb
qdaxb marked this pull request as ready for review July 20, 2026 01:24
@qdaxb

qdaxb commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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