Skip to content

fix(web): keep thread context when stashing prompts - #18843

Open
saphid wants to merge 6 commits into
pingdotgg:mainfrom
saphid:t3code/sweep/composer-thread-context-copy
Open

saphid wants to merge 6 commits into
pingdotgg:mainfrom
saphid:t3code/sweep/composer-thread-context-copy

Conversation

@saphid

@saphid saphid commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Stashing a prompt discarded its thread-context records, so restoring it could leave an unresolved reference. Save the complete records with the stash, clear them from the source only after a successful write, and restore them into the main composer draft. The existing importer still checks the environment and deduplicates in the destination.

Thanks @saphid for the original implementation in #18843. Clipboard preservation already landed in #18789; this diff contains only the remaining stash behavior.

Verification at local integration head c2858b994b:

  • PR-specific tests: 0 → 0; 198 existing tests across five relevant files pass. These support the stores/import paths; they do not exercise the component-local stash closures. No artificial callback or source-text tests were added.
  • Web typecheck, focused lint and formatting pass.
  • One full-diff review round by Claude Opus 5.5 and GPT-6 Sol: no blockers. Both identified an existing pending-question prompt-overwrite issue outside this thread-record fix.
  • Headless Linux client, actual main versus this head, matching synthetic data and viewport: main produces a stash with no thread record and an unresolved chip after restore into another thread. This head saves the complete record, clears the source, restores the identical context ID/environment/thread/title into the destination, consumes the stash, and preserves the resolved link after a full reload. Menu restore and the empty-composer Ctrl+S restore shortcut both work. No provider turn ran.
  • The browser required loading installed Liberation fonts through FontFace because its default font metrics were zero; both captures use the same fonts.

Before (main): restored reference is unresolved.

Before: stashed thread reference is unresolved

After (this head): restored reference resolves with its original thread record.

After: stashed thread reference resolves

Before recording · After recording

Not verified: pending-question restoration with a matching question-draft record, restoring over existing prompt text, provider delivery, remote/relay/tunnel connections, native macOS/Windows, iOS/Android, or Electron desktop. Web and the desktop renderer share this component; mobile code, provider adapters, contracts and server behavior are unchanged. GitHub feedback was refreshed after DNS recovered: no new actionable findings. Current-head CI jobs completed successfully or skipped, apart from a superseded cancelled native fingerprint attempt whose replacement passed. Macroscope approved this head; there are no review threads. Unmerged; final maintainer review remains.

Implementation assessed by GPT-6.1 Sol; tests by GPT-6 Astra (high); reviews by Claude Opus 5.5 and GPT-6 Sol; integration and client proof by GPT-6.1 Sol (high), through T3 Code and the Codex harness (Claude reviewer through Claude Agent).

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8fe3a2fa-5039-4f82-a16f-ebadc5319ae7
📥 Commits

Reviewing files that changed from the base of the PR and between 7ac952c and 1df4c32.

📒 Files selected for processing: 1
  • apps/web/src/components/chat/ChatComposer.tsx

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

📝 Walkthrough

The chat composer can import context records into a specified thread draft. Stashed context now includes thread-context records, and the composer clears those records after stashing.

Changes: Chat composer context stashing

Layer / File(s) Summary
Targeted context import
apps/web/src/components/chat/ChatComposer.tsx
importContextRecords accepts a thread-draft target and adds records to that target. Matching thread-context records are skipped only when the target is the attachment-draft target. Stash restoration passes the current composer draft target.
Thread-context stashing
apps/web/src/components/chat/ChatComposer.tsx
Stashed context records include the composer’s thread-context records. After stashing, the composer clears those records. The stash callback tracks the thread-context setter and records.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: t3dotgg

Merge Risk: ⚪ Minimal · up to 1df4c

The change preserves thread context through stash and restoration, and the inspected persistence and submission flows show no unresolved material merge risk.

Security architecture risk: 🔵 Low · up to 1df4c

Saved prompts now retain thread references and restore them to the intended draft. Existing environment checks remain, and rejected saves preserve the original draft. End-to-end access isolation for referenced threads was not fully established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The introduced exposure is persistence and restoration of thread identities and title snapshots already attached to a draft. Sensitive history remains resolved through the existing server thread-read path; the PR does not add a history payload or change that tool's authority.

Trust Boundaries and Controls

  • observed — Import rejects thread records declaring a different environment. Downstream thread reads require orchestration capability and resolve a live, non-deleted thread by its supplied ID. The inspected read path does not compare the target project with the caller's project; these controls and environment-wide targeting behavior predate this PR, and complete per-user isolation was not established.

Resilience and Maintainability Implications

  • observed — Restore verifies attachments before removing the stash entry, aborts if the draft target changed during verification, and uses entry removal to guard repeated activation. A failed durable deletion produces a warning. The stash shortcut excludes pending-question states that can split composer and attachment targets.
Pre-merge checks: Passed 4
Check name Status Explanation
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.
Title check Passed The title is concise, conventional, and accurately identifies the main change: preserving thread context when stashing prompts.
Description check Passed The description clearly explains the problem, the fix, scope, verification results, evidence, limitations, and agent details. It does not use the template headings, and explicit maintainer approval is…
Full details: Description check

Explanation

The description clearly explains the problem, the fix, scope, verification results, evidence, limitations, and agent details. It does not use the template headings, and explicit maintainer approval is not stated, but the focused bug rationale and supporting context make the description mostly complete.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Oct 12, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Oct 12, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 095c78c

Macroscope's review found this PR approvable — This narrowly scoped web fix preserves existing thread context records when prompts are stashed, restores them into the correct composer draft, and clears the source draft consistently. It does not introduce schema changes, product-default changes, static-analysis overrides, or sensitive/infrastructure behavior.

You can add or adjust custom eligibility rules. Learn more.

saphid and others added 3 commits October 14, 2026 17:15
The copy half already landed on main in pingdotgg#18789; drop the duplicate
thread-record line the merge left in the clipboard fragment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep the restored prompt and its records together during a pending question. Clipboard imports keep targeting the active answer draft.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
@saphid saphid changed the title fix(web): preserve thread context when copying or stashing prompts fix(web): keep thread context when stashing prompts Oct 14, 2026
@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). and removed size:XS 0-9 changed lines (additions + deletions). labels Oct 14, 2026
@macroscopeapp
macroscopeapp Bot dismissed their stale review October 14, 2026 21:33

Dismissing prior approval to re-evaluate 1df4c32

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Oct 14, 2026
… stashing prompts

Preserve the scoped contribution against upstream 70d60e0.
Focused checks and read-only integration review recorded in the PR.

GPT-6.1 Sol (high), Codex harness through T3 Code.
@macroscopeapp
macroscopeapp Bot dismissed their stale review October 17, 2026 03:02

Dismissing prior approval to re-evaluate 095c78c

@juliusmarminge juliusmarminge self-assigned this Oct 19, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Taking over this one for batch worktree-git-01. I will preserve contributor commits, merge current main, keep the change focused on stashed thread context, and verify restoration through the client. No merge is planned.

This branch has not been deployed

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

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants