Skip to content

optimize thread shell summary updates - #78

Merged
tarik02 merged 1 commit into
mainfrom
fix/large-thread-shell-summary
Jul 28, 2026
Merged

optimize thread shell summary updates#78
tarik02 merged 1 commit into
mainfrom
fix/large-thread-shell-summary

Conversation

@tarik02

@tarik02 tarik02 commented Jul 28, 2026

Copy link
Copy Markdown
Owner

What Changed

  • Update thread shell summary fields only for events that can change them.
  • Recalculate pending user-input state from activities only for relevant user-input events.
  • Perform the full concurrent summary recalculation only after a thread revert.

Why

refreshThreadShellSummary loaded messages, proposed plans, activities, and approvals on every thread event. Its cost grew with thread history and could hold the global command queue for seconds.

Event-specific updates avoid unrelated reads while keeping the existing activity-based pending user-input calculation where it is needed.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Screenshots are not applicable because there are no UI changes
  • Video is not applicable because there are no interaction changes

@github-actions github-actions Bot added size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Jul 28, 2026
@tarik02
tarik02 force-pushed the fix/large-thread-shell-summary branch from b40c1d0 to 985e93b Compare July 28, 2026 08:26
@github-actions github-actions Bot added size:XL and removed size:L labels Jul 28, 2026
@tarik02

tarik02 commented Jul 28, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff0af5bcd2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +112 to +114
yield* sql`
UPDATE projection_threads
SET pending_user_input_count = 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Backfill outstanding inputs before zeroing cached counts

On the first startup after upgrading an existing database, migration 002 creates an empty sidecar table, while the projection.thread-activities checkpoint already exists and bootstrap therefore does not replay historical user-input.requested events into it. This unconditional reset consequently changes every outstanding request's cached count to zero, and subsequent add/remove operations remain based on an incomplete set, so affected threads stop surfacing hasPendingUserInput; reconstruct the sidecar from retained activities before synchronizing this cache.

Useful? React with 👍 / 👎.

@tarik02

tarik02 commented Jul 28, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec6bbcb1eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const path = yield* Path.Path;
const serverConfig = yield* ServerConfig;

const initializePendingUserInputTracking = Effect.fn("initializePendingUserInputTracking")(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add focused tests for sidecar tracking

This introduces backend persistence and migration behavior—including lazy activity backfill, sidecar synchronization, revert rebuilding, and restart handling—but the commit adds or updates no test files. Add focused coverage for the new sidecar lifecycle, particularly migration/restart and revert cases, as the repository explicitly requires backend changes to include and run focused tests for changed behavior.

AGENTS.md reference: AGENTS.md:L5-L8

Useful? React with 👍 / 👎.

@tarik02 tarik02 changed the title avoid full activity scans in thread summaries lazily persist pending user input state Jul 28, 2026
@tarik02 tarik02 changed the title lazily persist pending user input state optimize thread shell summary updates Jul 28, 2026
@tarik02
tarik02 force-pushed the fix/large-thread-shell-summary branch from ec6bbcb to e03ffc1 Compare July 28, 2026 14:41
@github-actions github-actions Bot added size:L and removed size:XL labels Jul 28, 2026
@tarik02
tarik02 merged commit ef9c838 into main Jul 28, 2026
12 of 14 checks passed
@tarik02
tarik02 deleted the fix/large-thread-shell-summary branch July 28, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 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.

1 participant