Skip to content

🤖 fix: prevent concurrent agent banner wake flicker#3713

Open
ammar-agent wants to merge 6 commits into
mainfrom
agent-banner-pjde
Open

🤖 fix: prevent concurrent agent banner wake flicker#3713
ammar-agent wants to merge 6 commits into
mainfrom
agent-banner-pjde

Conversation

@ammar-agent

@ammar-agent ammar-agent commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Keep the concurrent local-agent warning stable while another agent cycles through background wake-ups, including the handoff gap after a one-shot monitor or terminal task notification is consumed but before the synthetic turn starts streaming.

Background

The warning originally only considered an interruptible stream active. Background monitor matches and workflow/task terminal messages transition the owning workspace through waiting, queued/preparing, and streaming states. For inactive workspaces, pre-stream startup was not exposed in activity snapshots, so the banner could still unmount and remount on every wake cycle.

Implementation

  • Add an authoritative pendingBackgroundWake workspace activity field.
  • Publish it before durable bash-monitor or terminal-attention sources disappear.
  • Recompute it from pending wake stores plus queued/preparing/retrying session state, with versioned async refreshes to prevent stale clears.
  • Include the signal in activity list bootstrap/reconnect and frontend sidebar state.
  • Keep the concurrent warning visible for streaming, startup, pending background wakes, active workflows, and armed monitors.
  • Add focused coverage for selector behavior, inactive workspace activity propagation, monitor wakes, and terminal wakes.

Validation

  • Focused warning, workspace store, monitor wake, and terminal wake regression suites
  • make typecheck
  • make static-check

Risks

Moderate and localized to workspace activity signaling. The pending flag is recomputed from durable stores and live session state, and is cleared on stream start, cancellation, supersession, or consumed terminal attention; versioned refreshes prevent older async reads from restoring stale state.


Generated with mux • Model: openai:gpt-5.6-sol • Thinking: high • Cost: $2.94

@ammar-agent

Copy link
Copy Markdown
Collaborator 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: 9876c1478d

ℹ️ 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".

@ammar-agent

Copy link
Copy Markdown
Collaborator Author

Addressed the inactive-workspace startup gap by adding an authoritative pendingBackgroundWake activity signal. Durable bash-monitor and task/workflow terminal notifications now publish the handoff before their source activity disappears, and the signal stays set through queued/preparing startup until streaming begins or the wake is canceled/superseded. Added focused backend/store regression coverage.

@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: d8c11fb0a4

ℹ️ 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 thread src/node/services/workspaceService.ts Outdated
@ammar-agent

Copy link
Copy Markdown
Collaborator Author

Addressed the activity-list race: getActivityList() now computes the current pending wake for its response without mutating or versioning the live cache, so it cannot invalidate a newer refresh or restore stale pending state.

@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: c7f785131a

ℹ️ 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 thread src/node/services/taskService.ts
@ammar-agent

Copy link
Copy Markdown
Collaborator Author

Seeded pendingBackgroundWake for every persisted terminal-attention owner during TaskService.initialize() before scheduling its drain, and added restart recovery coverage that asserts the handoff signal is published.

@codex review

@ammar-agent

Copy link
Copy Markdown
Collaborator Author

Seeded pendingBackgroundWake for every persisted terminal-attention owner during TaskService.initialize() before scheduling drains, including records that already existed on disk and therefore were not recreated by recovery. Added a restart regression assertion.

@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: 9dd4f14ca3

ℹ️ 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 thread src/node/services/taskService.ts
@ammar-agent

Copy link
Copy Markdown
Collaborator Author

Cleared the live pending wake signal after terminal-attention notifications transition to delivered (and after re-pending on pre-stream failure), so normal requireIdle delivery cannot leave the concurrent warning stuck. Added a focused assertion around the normal drain path.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: b0f371466f

ℹ️ 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".

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant