Skip to content

🤖 refactor: dedupe SSH/Coder startup barrier replay logic#3134

Open
ammar-agent wants to merge 1 commit intomainfrom
refactor-startup-replay-status-helpers
Open

🤖 refactor: dedupe SSH/Coder startup barrier replay logic#3134
ammar-agent wants to merge 1 commit intomainfrom
refactor-startup-replay-status-helpers

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

@ammar-agent ammar-agent commented Apr 5, 2026

Summary

This follow-up to #3133 deduplicates the logic that keeps the SSH/Coder startup barrier consistent during reconnects and workspace switching.

Background

#3133 fixed a concrete bug: startup detail like Checking workspace runtime... could disappear if you switched away from an SSH/Coder workspace and then switched back.

The first cleanup pass in this PR already moved low-level stream-lifecycle and runtime-status helper logic into src/common/types/stream.ts. This update follows through on the next cleanup opportunities nearby:

  • make WorkspaceStore use one replay-buffering path for previewing replayed startup/error state before caught-up
  • stop re-deriving "is this workspace still working/starting?" from raw aggregator fields in ProjectSidebar
  • pull AgentSession's replayed startup/terminal status emission into a named helper

Implementation

  • shared stream-lifecycle / runtime-status helper logic now lives in src/common/types/stream.ts
  • AgentSession now replays terminal/preparing status through emitReplayStatusSnapshot(...) instead of open-coding that state machine inside emitHistoricalEvents()
  • WorkspaceStore now routes pre-caught-up buffering through getBufferedReplayEventBehavior(...), so replayed stream-error, stream-lifecycle, stream-abort, and runtime-status follow one preview/buffer path
  • ProjectSidebar now uses replay-aware sidebar state for:
    • archive confirmation warnings
    • active/working checks
    • attention checks
      instead of recomputing startup state from raw aggregator fields
  • ProjectSidebar tests now provide getWorkspaceSidebarState() in the mocked workspace store so the shared sidebar-state path is exercised directly
  • focused coverage for the shared stream helpers lives in src/common/types/stream.test.ts

Validation

  • bun test src/browser/stores/WorkspaceStore.test.ts src/node/services/agentSession.preStreamError.test.ts src/browser/components/ProjectSidebar/ProjectSidebar.test.tsx
  • bun test src/common/types/stream.test.ts src/browser/utils/messages/StreamingMessageAggregator.runtimeStatus.test.ts src/node/services/agentSession.preStreamError.test.ts src/browser/stores/WorkspaceStore.test.ts
  • make typecheck
  • make static-check
  • git diff --check

Risks

Low. This is intended to stay behavior-preserving, but it touches the reconnect/workspace-switch startup path in both the backend replay layer and the renderer. The main regression risk would be stale or missing startup barrier state while replay is hydrating.


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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

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

ℹ️ 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 changed the title 🤖 refactor: share startup replay status helpers 🤖 refactor: dedupe SSH/Coder startup barrier replay logic Apr 5, 2026
---

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

<!-- mux-attribution: model=openai:gpt-5.4 thinking=xhigh costs=44.22 -->
@ammar-agent ammar-agent force-pushed the refactor-startup-replay-status-helpers branch from 4a743ee to 400ff14 Compare April 5, 2026 23:22
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

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