Skip to content

🤖 fix: stop treating slow stream starts as interruptions#2898

Merged
ammario merged 1 commit intomainfrom
fix/stream-start-lifecycle
Mar 13, 2026
Merged

🤖 fix: stop treating slow stream starts as interruptions#2898
ammario merged 1 commit intomainfrom
fix/stream-start-lifecycle

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Mar 11, 2026

Summary

Introduce a backend-owned stream lifecycle so slow-starting turns stay in-progress instead of being inferred as interrupted from a renderer-side timer or trailing-user transcript shape.

Background

The current retry/interruption UI treated a long PREPARING window as a likely interruption after the client-side grace period elapsed. That made legitimate slow starts and reconnects look broken even while the backend was still working on the same turn.

Implementation

  • add a shared stream-lifecycle event/snapshot that models preparing, streaming, completing, interrupted, and failed
  • emit that lifecycle from AgentSession, including replay-time hydration before caught-up
  • persist the lifecycle in browser workspace state and use it as the source of truth for interruption eligibility
  • keep manual-retry rollback state mounted while resumed attempts are in flight so temporary auto-retry enablement is restored only after a terminal outcome
  • preview replay lifecycle/error state before caught-up and replay terminal stream-error state so reconnects preserve failure-specific UI instead of regressing to generic interruption banners
  • ignore replayed terminal stream errors in the E2E stream timeline helper so recovery scenarios wait for the newly triggered request instead of stale replay state
  • keep transcript-shape interruption checks only as a fallback for history-only/crash-recovery cases
  • update chat barrier logic and regressions for slow-start, replay behavior, and the E2E stream timeline helper so additive lifecycle events do not break content-order assertions

Validation

  • bun test src/browser/features/Messages/ChatBarrier/RetryBarrier.test.tsx src/browser/stores/WorkspaceStore.test.ts src/browser/utils/messages/StreamingMessageAggregator.runtimeStatus.test.ts src/node/services/agentSession.preStreamError.test.ts
  • xvfb-run -a env PLAYWRIGHT_ARGS="tests/e2e/scenarios/streamingBehavior.spec.ts -g 'app recovers after error'" make test-e2e
  • make static-check

Risks

This touches the stream lifecycle path across backend replay, retry eligibility, and barrier rendering, so regressions would most likely show up in reconnect state restoration or interrupt/retry UI. The change is contained by making the lifecycle a derived view over existing backend state, replaying failure-specific terminal state explicitly, and adding regressions around replay previews plus manual retry cleanup.


Generated with mux • Model: openai:gpt-5.4 • Thinking: xhigh • Cost: $75.16

@ammar-agent
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Nice work!

ℹ️ 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 ammar-agent force-pushed the fix/stream-start-lifecycle branch from f599d69 to b890955 Compare March 11, 2026 14:16
@ammar-agent
Copy link
Collaborator Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: b8909553e4

ℹ️ 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 ammar-agent force-pushed the fix/stream-start-lifecycle branch from b890955 to d41969c Compare March 11, 2026 14:29
@ammar-agent
Copy link
Collaborator Author

@codex review

@ammar-agent ammar-agent force-pushed the fix/stream-start-lifecycle branch from d41969c to f70be97 Compare March 11, 2026 14:36
@ammar-agent
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Nice work!

ℹ️ 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 ammar-agent force-pushed the fix/stream-start-lifecycle branch from f70be97 to 9039bf9 Compare March 11, 2026 14:59
@ammar-agent
Copy link
Collaborator Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 9039bf9a52

ℹ️ 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 ammar-agent force-pushed the fix/stream-start-lifecycle branch from 9039bf9 to fb66b89 Compare March 11, 2026 15:16
@ammar-agent
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Delightful!

ℹ️ 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 ammar-agent force-pushed the fix/stream-start-lifecycle branch from fb66b89 to de02601 Compare March 12, 2026 14:40
@ammar-agent
Copy link
Collaborator Author

@codex review

@ammar-agent ammar-agent force-pushed the fix/stream-start-lifecycle branch from de02601 to 9f3d01d Compare March 12, 2026 14:50
@ammar-agent
Copy link
Collaborator Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 9f3d01d436

ℹ️ 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 ammar-agent force-pushed the fix/stream-start-lifecycle branch from 9f3d01d to b465c2b Compare March 12, 2026 15:05
@ammar-agent
Copy link
Collaborator Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: b465c2b6ef

ℹ️ 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 ammar-agent force-pushed the fix/stream-start-lifecycle branch from b465c2b to 29464ed Compare March 12, 2026 15:24
@ammar-agent
Copy link
Collaborator Author

@codex review

@ammar-agent ammar-agent force-pushed the fix/stream-start-lifecycle branch from 29464ed to fe47263 Compare March 12, 2026 15:30
@ammar-agent
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link

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

ℹ️ 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 ammar-agent force-pushed the fix/stream-start-lifecycle branch from fe47263 to 696db30 Compare March 12, 2026 16:14
@ammar-agent
Copy link
Collaborator Author

@codex review

Simplified the lifecycle/retry patch down to roughly 500 changed lines and reran make static-check.

@chatgpt-codex-connector
Copy link

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

ℹ️ 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 ammar-agent force-pushed the fix/stream-start-lifecycle branch from 696db30 to 8a61a13 Compare March 12, 2026 16:37
@ammar-agent
Copy link
Collaborator Author

@codex review

Follow-up fix: RetryBarrier now stays mounted via a null render when hidden, so the simplified rollback logic still works without leaking hidden "Stream interrupted" text into the DOM.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 8a61a132b2

ℹ️ 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 ammar-agent force-pushed the fix/stream-start-lifecycle branch from 8a61a13 to d618f83 Compare March 12, 2026 16:55
@ammar-agent
Copy link
Collaborator Author

@codex review

Addressed the stale hidden RetryBarrier state by clearing manual retry errors whenever the mounted-but-hidden barrier is suppressed.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: d618f8328b

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

Add a backend-owned stream lifecycle so the renderer can keep PREPARING turns in-progress,
rehydrate that state on reconnect, and reserve interruption UI for explicit abort/failure cases.

This follow-up also keeps manual-retry rollback state alive while resumed attempts are in flight,
previews replay lifecycle state before caught-up, and replays terminal stream errors so reconnects
preserve failure-specific UI instead of degrading to generic interruption banners.

---

_Generated with `mux` • Model: `openai:gpt-5.4` • Thinking: `xhigh` • Cost: `$75.16`_

<!-- mux-attribution: model=openai:gpt-5.4 thinking=xhigh costs=75.16 -->
@ammar-agent ammar-agent force-pushed the fix/stream-start-lifecycle branch from d618f83 to 1c5cb9f Compare March 12, 2026 17:13
@ammar-agent
Copy link
Collaborator Author

@codex review

Addressed the append-replay churn by making repeated pre-stream stream-error handling idempotent in the browser aggregator, and added a regression test for the preserved metadata.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Breezy!

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

@ammario ammario merged commit 190ca7f into main Mar 13, 2026
24 checks passed
@ammario ammario deleted the fix/stream-start-lifecycle branch March 13, 2026 14:53
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.

2 participants