Skip to content

fix(app): avoid stale session context reads#986

Merged
Astro-Han merged 4 commits into
devfrom
codex/i985-stale-show-session-switch
May 29, 2026
Merged

fix(app): avoid stale session context reads#986
Astro-Han merged 4 commits into
devfrom
codex/i985-stale-show-session-switch

Conversation

@Astro-Han

@Astro-Han Astro-Han commented May 29, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes a Solid stale <Show> accessor read in SessionContextUsage by avoiding callback accessors for context usage tooltip content.

Why

Production v2026.5.29 can throw Stale read from <Show> while switching sessions. The issue was first filed as #985. The release regression was exposed by PR #969 keeping the composer mounted during session opening; Claude's read-only review agreed that restoring the composer guard would be a symptom fix that regresses #969, and that the smaller root fix is to stop passing volatile context accessors through non-keyed <Show> children inside the composer subtree.

Related Issue

Fixes #985

Human Review Status

Pending

Review Focus

Please check that the tooltip still renders the same context/cost information while no longer using callback-form <Show> accessors for values that can disappear during session transitions.

Risk Notes

Low risk. This keeps the #969 composer mount behavior intact and only changes the render shape inside the context usage tooltip. Review follow-up replaced the brittle source-string render contract with a browser-condition test that renders SessionContextUsage itself and clears the mocked session messages so context metrics disappear. Platform/packaging surfaces were not touched. Docs, dependencies, permissions, generated files, and local file behavior were not touched.

How To Verify

Diff check: git diff --check passed
Focused tests: bun test --preload ./happydom.ts ./src/components/session/session-context-metrics.test.ts ./src/components/session-context-usage.test.ts passed, 13 tests, including a SessionContextUsage render regression for disappearing context metrics
Typecheck: bun run typecheck passed in packages/app
Visual check: bun run snap session-context-cache passed; reviewed docs/design/preview/screenshots/session-context-cache.png

Screenshots or Recordings

Visual snap checked locally: docs/design/preview/screenshots/session-context-cache.png (session-context-cache).

Checklist

How to use this checklist:

  • Tick a box by replacing [ ] with [x]. Do not edit, add, or remove items.
  • The bot-applied label items can only be honestly ticked AFTER the PR is opened and the labeler / priority-triage bots have run — return to the PR description and tick them then.
  • Most items are required. The few that are conditional are explicitly marked (conditional); for those, leave unticked if they truly do not apply and explain why in Risk Notes. All other items must be ticked before requesting human review.
  • Type label — this PR carries exactly one of bug, enhancement, task, documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.
  • Routing labels — this PR carries at least one of app, ui, platform, harness, ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.
  • Priority label — this PR carries exactly one of P0, P1, P2, P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.
  • Human Review Status above is set to Pending, Approved by @<reviewer>, or Not required: <reason> (default is Pending; "not required" is restricted to bot-authored low-risk PRs).
  • I linked the related issue, or stated in Summary why there is no issue.
  • I described the review focus and any meaningful risks.
  • I replaced the example block in How To Verify with the real verification steps and the key result for each.
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope.
  • (conditional) I manually checked visible UI or copy changes when needed, with screenshots or recordings. Leave unticked only if no visible UI or copy changed.
  • (conditional) I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes. Leave unticked only if no platform/packaging surface was touched.
  • (conditional) I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant. Leave unticked only if none of those surfaces was touched.
  • I reviewed the final diff for unrelated changes and suspicious dependency changes.
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English.

@Astro-Han Astro-Han added bug Something isn't working P1 High priority app Application behavior and product flows ui Design system and user interface labels May 29, 2026
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Astro-Han, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 48 minutes and 52 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 15ff23be-ee0a-426c-b479-e023a577109b

📥 Commits

Reviewing files that changed from the base of the PR and between 6b813b2 and 0a73a12.

📒 Files selected for processing (2)
  • packages/app/src/components/session-context-usage.test.ts
  • packages/app/src/components/session-context-usage.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/i985-stale-show-session-switch

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 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested priority: P2 (includes user-path files (packages/app/src/components/session-context-usage.test.ts, packages/app/src/components/session-context-usage.tsx)).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the SessionContextUsage component to avoid passing volatile context accessors through non-keyed <Show> children by introducing a memoized contextUsedLabel. It also adds a test to enforce this render contract. The reviewer suggested using import.meta.url and fileURLToPath instead of __dirname in the test file to ensure path resolution remains stable across different execution contexts.

Comment thread packages/app/src/components/session-context-usage.test.ts Outdated
@Astro-Han Astro-Han merged commit c9b5c04 into dev May 29, 2026
28 of 29 checks passed
@Astro-Han Astro-Han deleted the codex/i985-stale-show-session-switch branch May 29, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Application behavior and product flows bug Something isn't working P1 High priority ui Design system and user interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Stale Solid Show read when switching sessions

1 participant