Skip to content

fix(session): repair stale paginated question blockers#962

Merged
Astro-Han merged 2 commits into
devfrom
codex/stale-question-pagination
May 28, 2026
Merged

fix(session): repair stale paginated question blockers#962
Astro-Han merged 2 commits into
devfrom
codex/stale-question-pagination

Conversation

@Astro-Han

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

Copy link
Copy Markdown
Owner

Summary

Repair stale external-result question blockers when session messages are loaded through the paginated message endpoint. This is a follow-up to #947: the full-history path was repaired, but the desktop app uses GET /session/:sessionID/message?limit=... and that route still bypassed the repair.

Why

A session can be reopened after the app is shut down while a question tool is waiting for renderer input. If the in-memory ExternalResult is gone, the persisted question part is no longer answerable. The paginated endpoint previously returned that stale part as running, so the UI kept showing a question card and every response failed with "session restarted".

Related Issue

No standalone issue. Follow-up regression from #947.

Human Review Status

Pending

Review Focus

Please check that stale-question terminalization stays in the session API layer instead of moving side effects into the low-level MessageV2.page() storage reader.

Risk Notes

Skipped checklist items:

  • Visible UI/manual screenshot: no visible UI or copy changed; the affected user-visible state is covered through the server route contract.
  • macOS/Windows platform impact: no platform, packaging, updater, signing, shell, or permission surface changed.
  • Docs/release/dependencies/generated/local files: none touched.

How To Verify

Diff check: git diff --check passed
RED: bun test test/server/session-messages.test.ts -t "terminalizes stale running external-result questions in paginated responses" failed before the fix with Expected "error", Received "running"
RED follow-up: bun test test/server/session-messages.test.ts -t "older cursor page" failed when the route was temporarily restored to direct MessageV2.page, with Expected "error", Received "running"
Server route tests: bun test test/server/session-messages.test.ts passed, 9 tests
Session stale-question tests: bun test test/session/session.test.ts -t "messages" passed, 3 tests
Tool response route tests: bun test test/server/tool-respond-route.test.ts passed, 7 tests
Typecheck: bun run typecheck passed

Screenshots or Recordings

Not applicable. No visible UI change.

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 harness Model harness, prompts, tool descriptions, and session mechanics labels May 28, 2026

@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 non-doc, non-test paths outside the low-risk bucket).

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 session message pagination to use a new Session.messagesPage service method instead of querying MessageV2.page directly. This new method ensures that stale running external-result questions are terminalized when retrieving a page of messages. Additionally, comprehensive unit tests have been added to verify the correct handling of stale, live pending, and unready external-result questions in paginated responses. I have no feedback to provide as there are no review comments.

@coderabbitai

coderabbitai Bot commented May 28, 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 41 minutes and 9 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: 9bd61ae8-9152-4ce8-810a-72c4f09bc6c9

📥 Commits

Reviewing files that changed from the base of the PR and between a72c2cb and fdc7337.

📒 Files selected for processing (3)
  • packages/opencode/src/server/instance/session.ts
  • packages/opencode/src/session/session.ts
  • packages/opencode/test/server/session-messages.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/stale-question-pagination

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.

@Astro-Han Astro-Han force-pushed the codex/stale-question-pagination branch from 6fd1ffd to fdc7337 Compare May 28, 2026 06:50
@Astro-Han Astro-Han merged commit c936fee into dev May 28, 2026
26 checks passed
@Astro-Han Astro-Han deleted the codex/stale-question-pagination branch May 28, 2026 07:38
Astro-Han added a commit that referenced this pull request May 28, 2026
Bump PawWork desktop release version to 2026.5.29.

Changes since v2026.5.28:
- feat(settings): move Connections to Integrations + global toast monitor (#975)
- feat(ui): display cache hit rate with one decimal place (#967)
- fix: stabilize session opening state (#969)
- fix(session): repair stale paginated question blockers (#962)
- fix(ui): refit read-file icon into 0-20 viewBox (#964)
- fix: allow running tools to expand
- fix: add run lifecycle diagnostics
- fix: harden Electron repair fallback
- refactor: remove legacy theme choices
- ci: stabilize e2e Playwright install and PR triage paths

Verification: diff scope matches prior release bump (#958) — only the version string in packages/desktop-electron/package.json and the workspace entry in bun.lock. All CI checks green (e2e-artifacts required a rerun due to Playwright browser install flake unrelated to this change).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working harness Model harness, prompts, tool descriptions, and session mechanics P1 High priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant