Skip to content

Preserve thread visited state across partial syncs#2506

Open
hogeheer499-commits wants to merge 1 commit intopingdotgg:mainfrom
hogeheer499-commits:fix/preserve-thread-visited-state
Open

Preserve thread visited state across partial syncs#2506
hogeheer499-commits wants to merge 1 commit intopingdotgg:mainfrom
hogeheer499-commits:fix/preserve-thread-visited-state

Conversation

@hogeheer499-commits
Copy link
Copy Markdown

@hogeheer499-commits hogeheer499-commits commented May 4, 2026

What changed

  • Preserve threadLastVisitedAtById entries when syncThreads receives a partial snapshot that does not include a thread.
  • Keep the existing pruning behavior for threadChangedFilesExpandedById.
  • Add a regression test for the partial-snapshot visited-state case.

Why this should exist

This is a small, focused frontend state bug fix.

A production crash report showed React error 185 with markThreadVisited in the stack. On current main, ChatView calls markThreadVisited(threadKey, completedAt), but syncThreads could delete that completed-turn timestamp when a partial/recovery snapshot omitted the active thread. After that, the same completed turn could be marked visited again instead of remaining idempotent.

The regression test proves the exact state transition:

  1. mark a thread visited at completedAt
  2. run syncThreads([]) as a partial snapshot
  3. call markThreadVisited(thread, completedAt) again

With the old pruning behavior, the timestamp is lost. With this change, it is preserved and the second mark returns the same state object.

Scope

  • No UI or layout change.
  • Does not change WebSocket reconnect behavior.
  • Does not change server/provider turn lifecycle behavior.
  • Separate from the server projection issue tracked in later work.

Validation

  • npx --yes bun@1.3.11 run --filter @t3tools/web test src/uiStateStore.test.ts
  • npx --yes bun@1.3.11 fmt
  • npx --yes bun@1.3.11 lint - exit 0, existing warnings only
  • npx --yes bun@1.3.11 typecheck

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: efe4ce49-a930-496c-b146-45a070e32948

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels May 4, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 4, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 4, 2026

Approvability

Verdict: Approved

Straightforward bug fix that preserves thread visited state across partial syncs by removing incorrect pruning logic. The change is small, localized, and includes updated tests verifying the expected behavior.

You can customize Macroscope's approvability policy. Learn more.

@hogeheer499-commits hogeheer499-commits force-pushed the fix/preserve-thread-visited-state branch from 852728f to 60a6d68 Compare May 4, 2026 22:09
@macroscopeapp macroscopeapp Bot dismissed their stale review May 4, 2026 22:09

Dismissing prior approval to re-evaluate 60a6d68

@hogeheer499-commits
Copy link
Copy Markdown
Author

Adding the original reporter error details here as reviewer context. The screenshot showed the T3 Code Alpha error boundary with this expanded stack:

Hide error details
Error: Minified React error #185; visit https://react.dev/errors/185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Zr (http://192.168.2.13:3773/assets/index-CVbnJsIO.js:9:27497)
    at Yr (http://192.168.2.13:3773/assets/index-CVbnJsIO.js:9:27070)
    at zo (http://192.168.2.13:3773/assets/index-CVbnJsIO.js:9:52284)
    at http://192.168.2.13:3773/assets/index-CVbnJsIO.js:9:52165
    at http://192.168.2.13:3773/assets/index-CVbnJsIO.js:25:79722
    at Set.forEach (<anonymous>)
    at r (http://192.168.2.13:3773/assets/index-CVbnJsIO.js:25:79711)
    at markThreadVisited (http://192.168.2.13:3773/assets/index-CVbnJsIO.js:45:85530)
    at http://192.168.2.13:3773/assets/index-CVbnJsIO.js:306:6630
    at Lc (http://192.168.2.13:3773/assets/index-CVbnJsIO.js:9:91969)

This is the reason I focused this PR on the markThreadVisited path rather than on reconnect handling in general.

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants