Skip to content

fix(cli): preserve attach rendering and Relay routing - #1366

Merged
willwashburn merged 5 commits into
mainfrom
codex/fix-v11-2-cli-demo
Jul 30, 2026
Merged

fix(cli): preserve attach rendering and Relay routing#1366
willwashburn merged 5 commits into
mainfrom
codex/fix-v11-2-cli-demo

Conversation

@willwashburn

@willwashburn willwashburn commented Jul 26, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the v11.2 CLI demo failures where drive/passthrough status rendering
tears full-screen agent TUIs and an interactive Codex gamemaster substitutes
native subagents for existing Relay participants.

Root cause

  • Relay painted its status text inside the child application's terminal grid.
    Full-screen redraws, autowrap, DECSTBM/DECOM state, resize races, and partial
    ANSI sequences could therefore overwrite or splice into Relay's repaint.
  • The MCP server exposed Relay tools but did not tell interactive Codex
    sessions that named existing participants must be contacted through Relay.

Changes

  • Reserve a dedicated local status row and spare autowrap column while sizing
    the child PTY to the remaining grid.
  • Preserve and restore child scroll margins, origin mode, primary/alternate
    buffer state, and ANSI sequence boundaries around status repaints.
  • Reconcile resizes during attach setup, handle one/two-row terminals without
    invalid margins, and keep predictive echo boundary tracking aligned with
    bytes actually written.
  • Publish Relay-first participant-routing instructions in MCP initialization.
  • Add MCP protocol coverage and a credential-gated Codex/Relay E2E assertion.

Relationship to #1364

This independently confirms #1364's status-line autowrap diagnosis and adopts
its strongest testing idea: real status paints are replayed through
@xterm/headless at 80, 66, and 40 columns.

The implementation differs by creating a real ownership boundary between the
child PTY and Relay's local status row, rather than only truncating a label
painted inside the child's grid. It also tracks DECSTBM, DECOM, alternate
buffers, split CSI/OSC/DCS sequences, degenerate terminal sizes, and setup
resize races. This PR additionally addresses the reported Codex
native-subagent substitution through MCP instructions and a protocol-level E2E
guard. It intentionally does not include #1364's separate broker orphan-reaping
change.

Validation

  • npx vitest run packages/cli — 816 passed, 11 skipped
  • Focused attach/MCP suite — 211 passed
  • npm run build:core — passed
  • npm run test:integration:broker:build — passed
  • npm run lint --workspace=agent-relay — 0 errors, 41 warnings
  • git diff --check — passed
  • Independent fresh-context Codex review — approved
  • Live multi-PTY run — three real Codex agents completed a full game over
    Relay (X5, O1, X9, O3, X2, O8, X6, O4, X7; draw). The gamemaster
    discovered the existing named participants with list_agents, exchanged
    every move through send_dm, created no native substitute agents, and the
    drive/passthrough status rows remained isolated through live terminal
    resizes.

The automated credential-gated Codex test remains opt-in; the equivalent
scenario above was verified interactively against the actual PR build.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2ebb1327-2eba-4583-8022-1b0bbcb2ff9d

📥 Commits

Reviewing files that changed from the base of the PR and between 65d226a and 595a7ba.

📒 Files selected for processing (2)
  • crates/broker/src/listen_api.rs
  • packages/harness-driver/src/client.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/broker/src/listen_api.rs
  • packages/harness-driver/src/client.ts

📝 Walkthrough

Walkthrough

The PR updates drive and passthrough attach sessions with reserved status rows, ANSI and scroll-region tracking, safer repaint timing, and reconciled PTY resizing. It also publishes Relay-first MCP instructions and adds protocol, startup, and Codex integration coverage for named-participant coordination.

Changes

Terminal attach rendering

Layer / File(s) Summary
Terminal layout and repaint primitives
packages/cli/src/cli/lib/attach.ts, packages/cli/src/cli/lib/attach.test.ts
Adds reserved-row sizing, status clipping, ANSI boundary handling, invalidation scanning, scroll-region tracking, and boundary-safe repaint coordination.
Drive attach layout and resize flow
packages/cli/src/cli/lib/attach-drive.ts, packages/cli/src/cli/lib/attach-drive.test.ts
Applies reserved PTY dimensions, reconciles setup and snapshot state, coordinates predictive echo, and validates worker output, resize, fallback, and terminal-size behavior.
Passthrough attach layout and resize flow
packages/cli/src/cli/lib/attach-passthrough.ts, packages/cli/src/cli/lib/attach-passthrough.test.ts
Establishes reserved layout before snapshot replay, corrects stale resizes, tracks output state, and handles status reset and reactivation across terminal size changes.
PTY resize release restoration
crates/broker/src/runtime/api.rs, crates/broker/src/listen_api.rs, packages/harness-driver/src/client.ts
Restores PTY dimensions during resize ownership release and documents the combined release-and-resize response.

Relay-first MCP coordination

Layer / File(s) Summary
MCP instruction publication and verification
packages/cli/src/cli/agent-relay-mcp.ts, packages/cli/src/cli/agent-relay-mcp.protocol.test.ts, packages/cli/src/cli/agent-relay-mcp.startup.test.ts
Publishes shared Relay-first instructions through MCP initialization and verifies them through protocol and startup tests.
Named-participant integration coverage
tests/integration/broker/mcp-injection.test.ts, .agentworkforce/trajectories/completed/2026-07/traj_rifnk10uqgl4.md, CHANGELOG.md
Verifies Codex contacts an existing named participant and does not enter provider-native subagent waiting output, while recording validation and release notes.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested labels: size:L

Suggested reviewers: khaliqgant

Poem

A rabbit watched the status bar gleam,
While ANSI flowed like carrot cream.
Rows made room, resizes danced,
Relay friends were now entranced.
“No native waits!” the bunny sings—
Fresh green tests on floppy wings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main changes to attach rendering and Relay routing.
Description check ✅ Passed The description covers summary, root cause, changes, and validation, but it omits the template's Test Plan and Screenshots sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-v11-2-cli-demo

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.

@willwashburn
willwashburn marked this pull request as ready for review July 27, 2026 13:58
@willwashburn
willwashburn requested a review from khaliqgant as a code owner July 27, 2026 13:58

@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: 080853e2e0

ℹ️ 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 packages/cli/src/cli/lib/attach.ts

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/cli/src/cli/lib/attach-drive.ts (1)

796-821: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Write the updated child scroll region on resize. renderChildScrollRegion() is only written from beginSubscribedLayout, so after resizeHandler updates scrollRegion the DECSTBM bottom installed by the previous layout remains stale. Emit the new region when resizing while the status row is enabled; shrink below the threshold keeps the old child margin without a chance to correct it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach-drive.ts` around lines 796 - 821, Update
resizeHandler to call renderChildScrollRegion after scrollRegion.setRows when
statusLineEnabled and agentSize are valid, so the terminal’s DECSTBM region
matches the new child dimensions. Preserve the existing behavior when the status
row is disabled or resize calculations return early.
🧹 Nitpick comments (13)
packages/cli/src/cli/lib/attach-drive.ts (4)

774-789: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Both settlement handlers are identical.

♻️ Simplify
     const applyServerOutput = (chunk: string): void => {
       if (predictiveEcho) {
-        void predictiveEcho.onServerOutput(chunk).then(
-          () => {
-            paintStatus();
-          },
-          () => {
-            paintStatus();
-          }
-        );
+        void predictiveEcho.onServerOutput(chunk).finally(paintStatus);
       } else {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach-drive.ts` around lines 774 - 789, Update
applyServerOutput so predictiveEcho.onServerOutput(chunk) uses a single
completion handler for both success and failure, preserving the existing
paintStatus() call regardless of settlement outcome. Keep the non-predictive
output path unchanged.

557-575: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

scrollBottom default can exceed the child's actual margin. When scrollBottom is omitted it falls back to row - 1, i.e. the full physical height minus the status row. That happens to match the reserved layout today, but the session code always passes explicit scrollTop/scrollBottom from the tracker, so the only consumers of this default are tests and any future caller — where silently reinstalling a full-height margin would undo a child DECSTBM. Consider omitting the \x1b[{top};{bottom}r reinstall entirely when the caller supplies no region.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach-drive.ts` around lines 557 - 575, Update the
status-line rendering flow around scrollTop and scrollBottom so the DECSTBM
reinstall escape is emitted only when the caller supplies an explicit scroll
region. Avoid deriving a full-height default region from row for callers that
omit scrollTop/scrollBottom, while preserving the existing explicit-region
restoration and origin-mode handling in the returned sequence.

708-719: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low value

correctSetupResize can duplicate a resize the handler already sent. beginSubscribedLayout installs resizeHandler before the awaited initial resize, so a SIGWINCH during setup is forwarded twice: once by the handler and again here, because the comparison is against the pre-await baseline rather than the last size actually forwarded. The broker no-ops a same-size re-assert, so this is benign today, but tracking the last-forwarded dimensions would make the setup path deterministic.

♻️ Sketch
+    let lastForwarded: { rows: number; cols: number } | null = null;
     const correctSetupResize = async (baseline: { rows: number; cols: number } | null): Promise<void> => {
       const latest = reserveStatusLineRow(deps.terminal.getSize());
-      if (!latest || (latest.rows === baseline?.rows && latest.cols === baseline?.cols)) return;
+      const reference = lastForwarded ?? baseline;
+      if (!latest || (latest.rows === reference?.rows && latest.cols === reference?.cols)) return;

(with resizeHandler setting lastForwarded = agentSize.)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach-drive.ts` around lines 708 - 719, Update
correctSetupResize and the setup resize state so comparison uses the last
dimensions actually forwarded by resizeHandler, rather than the pre-await
baseline. Have resizeHandler update the shared last-forwarded size whenever it
sends a resize, and let correctSetupResize skip correction when latest matches
that state while preserving correction for genuinely unforwarded changes.

721-737: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

beginSubscribedLayout forward-references the const resizeHandler in both session loops. Each closure reads a const declared further down the same scope; this only avoids a ReferenceError because the first invocation comes from the socket.on('open') callback, and the socket is created after the declaration. Any reordering — or a transport that emits open synchronously from the factory — turns both into temporal-dead-zone crashes at attach time. Promoting the handler to a hoisted function declaration removes the ordering dependency in both files.

  • packages/cli/src/cli/lib/attach-drive.ts#L721-L737: change const resizeHandler = (): void => {…} at Line 796 into function resizeHandler(): void {…} so Line 724's deps.terminal.onResize(resizeHandler) is order-independent.
  • packages/cli/src/cli/lib/attach-passthrough.ts#L448-L462: apply the same conversion to the const resizeHandler at Line 511 referenced from Line 449.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach-drive.ts` around lines 721 - 737, Convert the
resizeHandler definition in packages/cli/src/cli/lib/attach-drive.ts at lines
796 and packages/cli/src/cli/lib/attach-passthrough.ts at lines 511 from const
arrow functions to hoisted function declarations, preserving their existing
bodies and behavior. This removes the ordering dependency for
beginSubscribedLayout’s resizeHandler references at attach-drive.ts lines
721-737 and attach-passthrough.ts lines 448-462; both sites require the same
direct change.
packages/cli/src/cli/lib/attach.ts (6)

913-914: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Doc no longer matches the widened type. enabled is now also toggled dynamically when the terminal shrinks below the reservation threshold, not just for non-TTY stdout.

♻️ Suggested wording
-  /** When false (stdout is not a TTY) the status line is never painted. */
+  /**
+   * Whether the status line may be painted. Pass a thunk when this can change
+   * mid-session (non-TTY stdout, or a terminal too small to reserve a row).
+   */
   enabled: boolean | (() => boolean);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach.ts` around lines 913 - 914, Update the
documentation for the enabled property to describe both static and dynamic
disabling: it may be false for non-TTY stdout and may be toggled off when the
terminal shrinks below the reserved status-line threshold.

402-413: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Doc block is attached to the wrong function. The JSDoc at Lines 402-409 describes the status-label fitting behavior but sits above conservativeTerminalCellWidth; move it onto fitStatusLineText (Line 415) so editors surface it on the exported API.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach.ts` around lines 402 - 413, Move the existing
terminal-row status-label JSDoc from conservativeTerminalCellWidth onto
fitStatusLineText, preserving the text unchanged so it documents the exported
API rather than the width helper.

373-389: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicated reservation threshold. The rows >= 3 && cols >= 2 rule is spelled out twice; a divergence here would silently desync "reserved size" from "status enabled".

♻️ Suggested consolidation
 export function reserveStatusLineRow(
   localSize: { rows: number; cols: number } | null
 ): { rows: number; cols: number } | null {
   if (!localSize) return null;
-  if (localSize.rows < 3 || localSize.cols < 2) return localSize;
+  if (!canReserveStatusLine(localSize)) return localSize;
   return {
     rows: localSize.rows - 1,
     cols: localSize.cols - 1,
   };
 }

(Requires moving canReserveStatusLine above, or hoisting via function declaration — function declarations hoist, so no reorder is needed.)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach.ts` around lines 373 - 389, Consolidate the
reservation threshold by updating reserveStatusLineRow to reuse
canReserveStatusLine instead of independently checking localSize.rows and
localSize.cols. Preserve the null and undersized-terminal behavior, and rely on
the existing function declaration hoisting if needed.

758-851: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Third ANSI state machine in this file. TerminalScrollRegionTracker's ground/escape/csi/string/string_escape parser duplicates AnsiBoundaryScanner's transitions almost byte-for-byte (CAN/SUB/ESC/ST handling, C1 entry points), with the only real difference being the applyCsi callback and BEL-for-OSC handling. A shared tokenizer emitting {params, final} events would let both classes drop their transition tables and keep the two from drifting apart on future control-byte fixes.

Not blocking for this PR — the behavior is well covered by the new tests — but worth scheduling before a third consumer appears.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach.ts` around lines 758 - 851, Consolidate the
duplicated ANSI parser transitions used by TerminalScrollRegionTracker and
AnsiBoundaryScanner into a shared tokenizer that emits CSI {params, final}
events. Reuse the tokenizer for ground, escape, csi, string, and string_escape
handling, while preserving each consumer’s existing applyCsi behavior and
BEL-for-OSC configuration.

681-694: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Wire up StatusLineInvalidationScanner or remove it. It is only referenced by its definition and tests, while production attach paths use StatusLineController / TerminalScrollRegionTracker.

Also hoist the regexp from push: StatusLineInvalidationScanner.push is the hot per-chunk path, and this currently rebuilds the regex every time with new RegExp(...). Use a module-level /g regex with lastIndex = 0, or drop g and use matchAll.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach.ts` around lines 681 - 694, Remove the unused
StatusLineInvalidationScanner class and its tests, or integrate it into the
production attach flow so it is invoked by the relevant
StatusLineController/TerminalScrollRegionTracker path. If retained, move the
private-mode regexp out of push into module scope and reset its lastIndex before
scanning, or replace the global-regex loop with matchAll to avoid rebuilding it
per chunk.

Source: Linters/SAST tools


456-476: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use or drop the syncInitialPtySize boolean. attach-drive.ts and attach-passthrough.ts both await the Promise, but the returned true/false value is never consumed before the unconditional snapshot path. Either pass the result through to force/log a post-resize repaint, or keep the helper’s return type Promise<void> to match the existing behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach.ts` around lines 456 - 476, Update
syncInitialPtySize and its callers in attach-drive.ts and attach-passthrough.ts
so the Promise<boolean> result is consumed to control or log the post-resize
repaint; otherwise change syncInitialPtySize to return Promise<void> and remove
the unused true/false returns. Preserve the existing resize failure handling and
unconditional snapshot behavior unless the consumed result explicitly requires
changing it.
packages/cli/src/cli/lib/attach.test.ts (1)

27-37: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Test title contradicts the assertion. reserveStatusLineRow also drops a column, so "while preserving its width" is misleading given line 29 expects cols: 119.

♻️ Suggested rename
-  it('gives a TUI one fewer row while preserving its width', () => {
+  it('gives a TUI one fewer row and one spare autowrap column', () => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach.test.ts` around lines 27 - 37, Rename the
test case in the reserveStatusLineRow describe block to accurately state that it
reduces both the terminal row and column dimensions, matching the expected {
rows: 39, cols: 119 } assertion.
packages/cli/src/cli/lib/attach-passthrough.test.ts (1)

1028-1045: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

This test pins the "no margin refresh on resize" behavior. expect(writes).toHaveLength(writesBeforeResize) asserts the resize emits nothing at all — which is true today only because renderChildScrollRegion is never re-emitted after the initial layout (see attach-drive.ts Lines 796-821). If that gap is fixed, this assertion breaks. Consider narrowing it to the status-paint count so the test survives a margin-refresh fix.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach-passthrough.test.ts` around lines 1028 -
1045, Update the resize assertions in the passthrough-session test around
runPassthroughSession and terminal.setSize so they verify only that no
additional “passthrough Alice” status paint occurs before the worker’s split CSI
sequence completes. Remove the writes.length equality assertion, allowing other
resize output such as renderChildScrollRegion margin refreshes while preserving
the existing status-paint behavior check.
packages/cli/src/cli/lib/attach-drive.test.ts (1)

1637-1676: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

predictiveWrite is captured but never exercised. The test asserts only toBeTypeOf('function'); the actual boundary tracking is driven by opts.write(chunk) inside onServerOutput. Either drop the variable or use it to write a chunk directly and assert the boundary state moved — the latter is what the test title ("bytes predictive echo actually writes") promises.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach-drive.test.ts` around lines 1637 - 1676, The
test’s predictiveWrite capture is unused and does not verify the bytes-written
boundary described by the test title. Update the test around
createPredictiveEcho and pendingOutputs to invoke the captured predictiveWrite
with a chunk and assert the corresponding boundary/repaint state advances, or
remove the capture if direct verification is not intended; preserve the existing
onServerOutput completion and repaint ordering checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/cli/lib/attach-drive.test.ts`:
- Around line 1406-1426: Add an explicit function-type assertion for
resolveInitialResize after the terminal.setSize flush and before invoking it in
both stale initial resize tests: packages/cli/src/cli/lib/attach-drive.test.ts
lines 1406-1426 and packages/cli/src/cli/lib/attach-passthrough.test.ts lines
855-901. Keep the existing optional invocation and remaining assertions
unchanged.

In `@tests/integration/broker/mcp-injection.test.ts`:
- Around line 265-266: Move the try block in the test setup so it begins before
calling BrokerHarness.start, keeping startup and the existing test logic inside
the cleanup scope. Preserve the finally block so cleanup runs when startup
throws, preventing partially initialized broker resources from remaining active.
- Around line 282-300: Replace the fixed 45-second sleep in the integration test
with BrokerHarness.waitForEvent, using a bounded timeout and a predicate that
matches the expected relay_inbound event targeting playerName with move, choose,
or tic-tac-toe content. After the event is observed, collect and inspect the
harness events as before, preserving the existing assertions that verify routing
and absence of the provider-native wait flow.

---

Outside diff comments:
In `@packages/cli/src/cli/lib/attach-drive.ts`:
- Around line 796-821: Update resizeHandler to call renderChildScrollRegion
after scrollRegion.setRows when statusLineEnabled and agentSize are valid, so
the terminal’s DECSTBM region matches the new child dimensions. Preserve the
existing behavior when the status row is disabled or resize calculations return
early.

---

Nitpick comments:
In `@packages/cli/src/cli/lib/attach-drive.test.ts`:
- Around line 1637-1676: The test’s predictiveWrite capture is unused and does
not verify the bytes-written boundary described by the test title. Update the
test around createPredictiveEcho and pendingOutputs to invoke the captured
predictiveWrite with a chunk and assert the corresponding boundary/repaint state
advances, or remove the capture if direct verification is not intended; preserve
the existing onServerOutput completion and repaint ordering checks.

In `@packages/cli/src/cli/lib/attach-drive.ts`:
- Around line 774-789: Update applyServerOutput so
predictiveEcho.onServerOutput(chunk) uses a single completion handler for both
success and failure, preserving the existing paintStatus() call regardless of
settlement outcome. Keep the non-predictive output path unchanged.
- Around line 557-575: Update the status-line rendering flow around scrollTop
and scrollBottom so the DECSTBM reinstall escape is emitted only when the caller
supplies an explicit scroll region. Avoid deriving a full-height default region
from row for callers that omit scrollTop/scrollBottom, while preserving the
existing explicit-region restoration and origin-mode handling in the returned
sequence.
- Around line 708-719: Update correctSetupResize and the setup resize state so
comparison uses the last dimensions actually forwarded by resizeHandler, rather
than the pre-await baseline. Have resizeHandler update the shared last-forwarded
size whenever it sends a resize, and let correctSetupResize skip correction when
latest matches that state while preserving correction for genuinely unforwarded
changes.
- Around line 721-737: Convert the resizeHandler definition in
packages/cli/src/cli/lib/attach-drive.ts at lines 796 and
packages/cli/src/cli/lib/attach-passthrough.ts at lines 511 from const arrow
functions to hoisted function declarations, preserving their existing bodies and
behavior. This removes the ordering dependency for beginSubscribedLayout’s
resizeHandler references at attach-drive.ts lines 721-737 and
attach-passthrough.ts lines 448-462; both sites require the same direct change.

In `@packages/cli/src/cli/lib/attach-passthrough.test.ts`:
- Around line 1028-1045: Update the resize assertions in the passthrough-session
test around runPassthroughSession and terminal.setSize so they verify only that
no additional “passthrough Alice” status paint occurs before the worker’s split
CSI sequence completes. Remove the writes.length equality assertion, allowing
other resize output such as renderChildScrollRegion margin refreshes while
preserving the existing status-paint behavior check.

In `@packages/cli/src/cli/lib/attach.test.ts`:
- Around line 27-37: Rename the test case in the reserveStatusLineRow describe
block to accurately state that it reduces both the terminal row and column
dimensions, matching the expected { rows: 39, cols: 119 } assertion.

In `@packages/cli/src/cli/lib/attach.ts`:
- Around line 913-914: Update the documentation for the enabled property to
describe both static and dynamic disabling: it may be false for non-TTY stdout
and may be toggled off when the terminal shrinks below the reserved status-line
threshold.
- Around line 402-413: Move the existing terminal-row status-label JSDoc from
conservativeTerminalCellWidth onto fitStatusLineText, preserving the text
unchanged so it documents the exported API rather than the width helper.
- Around line 373-389: Consolidate the reservation threshold by updating
reserveStatusLineRow to reuse canReserveStatusLine instead of independently
checking localSize.rows and localSize.cols. Preserve the null and
undersized-terminal behavior, and rely on the existing function declaration
hoisting if needed.
- Around line 758-851: Consolidate the duplicated ANSI parser transitions used
by TerminalScrollRegionTracker and AnsiBoundaryScanner into a shared tokenizer
that emits CSI {params, final} events. Reuse the tokenizer for ground, escape,
csi, string, and string_escape handling, while preserving each consumer’s
existing applyCsi behavior and BEL-for-OSC configuration.
- Around line 681-694: Remove the unused StatusLineInvalidationScanner class and
its tests, or integrate it into the production attach flow so it is invoked by
the relevant StatusLineController/TerminalScrollRegionTracker path. If retained,
move the private-mode regexp out of push into module scope and reset its
lastIndex before scanning, or replace the global-regex loop with matchAll to
avoid rebuilding it per chunk.
- Around line 456-476: Update syncInitialPtySize and its callers in
attach-drive.ts and attach-passthrough.ts so the Promise<boolean> result is
consumed to control or log the post-resize repaint; otherwise change
syncInitialPtySize to return Promise<void> and remove the unused true/false
returns. Preserve the existing resize failure handling and unconditional
snapshot behavior unless the consumed result explicitly requires changing it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f5b3262-616e-45a1-8de3-322ef74289cb

📥 Commits

Reviewing files that changed from the base of the PR and between af898f7 and 080853e.

📒 Files selected for processing (12)
  • .agentworkforce/trajectories/completed/2026-07/traj_rifnk10uqgl4.md
  • CHANGELOG.md
  • packages/cli/src/cli/agent-relay-mcp.protocol.test.ts
  • packages/cli/src/cli/agent-relay-mcp.startup.test.ts
  • packages/cli/src/cli/agent-relay-mcp.ts
  • packages/cli/src/cli/lib/attach-drive.test.ts
  • packages/cli/src/cli/lib/attach-drive.ts
  • packages/cli/src/cli/lib/attach-passthrough.test.ts
  • packages/cli/src/cli/lib/attach-passthrough.ts
  • packages/cli/src/cli/lib/attach.test.ts
  • packages/cli/src/cli/lib/attach.ts
  • tests/integration/broker/mcp-injection.test.ts

Comment thread packages/cli/src/cli/lib/attach-drive.test.ts
Comment thread tests/integration/broker/mcp-injection.test.ts Outdated
Comment thread tests/integration/broker/mcp-injection.test.ts Outdated
willwashburn pushed a commit that referenced this pull request Jul 29, 2026
Address review feedback on #1366.

- Detaching a drive/passthrough attach now hands back the row and column
  it reserved for Relay's status line. `POST /api/resize/{name}` applies
  dimensions sent alongside `release: true`, so the restore is atomic
  with dropping ownership: a separate resize would have to land strictly
  before the release or it re-claims the lease (#1247), and it would add
  a second round-trip to teardown. Without this the worker stayed at
  `rows - 1`/`cols - 1`, and since a read-only `view` session never
  resizes the PTY, the agent TUI stayed short until the next writable
  attach.
- Assert `resolveInitialResize` is a function in both "stale initial
  resize" tests. If setup hadn't reached the first `POST /resize`, the
  optional resolve was a no-op and the surviving assertions passed on
  the SIGWINCH resize alone — a silent false green.
- Move `harness.start()` inside the try in the named-participant
  integration test so a failing startup still runs cleanup.
- Replace that test's fixed 45s sleep with a bounded `waitForEvent` on
  the routing event; a timeout falls through to the descriptive
  assertions rather than masking them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bkme6VN5DoN2SgcR1jnpXU

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/cli/lib/attach-drive.test.ts`:
- Line 1328: Remove the duplicate releaseBody const declaration in the
attach-drive test, retaining a single declaration for the releaseCall body
before its uses so the file compiles.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 49853de5-83bc-4019-a8b1-649af3a3bf45

📥 Commits

Reviewing files that changed from the base of the PR and between 080853e and d5cb6f9.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • crates/broker/src/listen_api.rs
  • crates/broker/src/runtime/api.rs
  • packages/cli/src/cli/agent-relay-mcp.ts
  • packages/cli/src/cli/lib/attach-drive.test.ts
  • packages/cli/src/cli/lib/attach-drive.ts
  • packages/cli/src/cli/lib/attach-passthrough.test.ts
  • packages/cli/src/cli/lib/attach-passthrough.ts
  • packages/harness-driver/src/client.ts
  • tests/integration/broker/mcp-injection.test.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • CHANGELOG.md
  • tests/integration/broker/mcp-injection.test.ts
  • packages/cli/src/cli/agent-relay-mcp.ts
  • packages/cli/src/cli/lib/attach-passthrough.test.ts
  • packages/cli/src/cli/lib/attach-passthrough.ts
  • packages/cli/src/cli/lib/attach-drive.ts

Comment thread packages/cli/src/cli/lib/attach-drive.test.ts
willwashburn and others added 3 commits July 29, 2026 20:31
Address review feedback on #1366.

- Detaching a drive/passthrough attach now hands back the row and column
  it reserved for Relay's status line. `POST /api/resize/{name}` applies
  dimensions sent alongside `release: true`, so the restore is atomic
  with dropping ownership: a separate resize would have to land strictly
  before the release or it re-claims the lease (#1247), and it would add
  a second round-trip to teardown. Without this the worker stayed at
  `rows - 1`/`cols - 1`, and since a read-only `view` session never
  resizes the PTY, the agent TUI stayed short until the next writable
  attach.
- Assert `resolveInitialResize` is a function in both "stale initial
  resize" tests. If setup hadn't reached the first `POST /resize`, the
  optional resolve was a no-op and the surviving assertions passed on
  the SIGWINCH resize alone — a silent false green.
- Move `harness.start()` inside the try in the named-participant
  integration test so a failing startup still runs cleanup.
- Replace that test's fixed 45s sleep with a bounded `waitForEvent` on
  the routing event; a timeout falls through to the descriptive
  assertions rather than masking them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bkme6VN5DoN2SgcR1jnpXU
@willwashburn
willwashburn force-pushed the codex/fix-v11-2-cli-demo branch from d5cb6f9 to fe2976f Compare July 30, 2026 00:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (7)
packages/cli/src/cli/lib/attach-drive.test.ts (2)

1096-1108: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Copied test claims reserved-row restoration but only counts repaints. Both files gained the same test whose name promises the reserved status row is "safely restored" while the only assertion is that the [drive|passthrough Alice] write count increased.

  • packages/cli/src/cli/lib/attach-drive.test.ts#L1096-L1108: assert the last repaint contains the reserved-row CUP (\x1b[30;1H) and the child DECSTBM reinstall, or rename to "repaints after worker_stream chunks".
  • packages/cli/src/cli/lib/attach-passthrough.test.ts#L679-L691: apply the same change to the passthrough copy.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach-drive.test.ts` around lines 1096 - 1108, The
worker_stream tests in packages/cli/src/cli/lib/attach-drive.test.ts:1096-1108
and packages/cli/src/cli/lib/attach-passthrough.test.ts:679-691 claim
reserved-row restoration but only count repaints; update both tests to assert
the latest repaint contains the reserved-row CUP (\x1b[30;1H) and child DECSTBM
reinstall, while retaining the existing repaint-count assertion.

1708-1747: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

predictiveWrite is captured but never exercised.

The only use is expect(predictiveWrite).toBeTypeOf('function'), which passes as long as the factory ran. Either drive a write through it (to prove tracker/controller see predictive bytes) or drop the variable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach-drive.test.ts` around lines 1708 - 1747,
Update the test around createPredictiveEcho so the captured predictiveWrite
callback is either invoked with representative output and its effect is
asserted, or removed if the test does not need to exercise it. Do not retain
predictiveWrite solely for the toBeTypeOf assertion; ensure the test directly
verifies predictive bytes when keeping the callback.
packages/cli/src/cli/lib/attach.ts (3)

496-512: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Derive the reservation threshold from a single predicate.

reserveStatusLineRow and canReserveStatusLine each hard-code rows >= 3 && cols >= 2. If one threshold changes, the paint gate and the PTY sizing silently disagree.

♻️ Proposed refactor
 export function reserveStatusLineRow(
   localSize: { rows: number; cols: number } | null
 ): { rows: number; cols: number } | null {
   if (!localSize) return null;
-  if (localSize.rows < 3 || localSize.cols < 2) return localSize;
+  if (!canReserveStatusLine(localSize)) return localSize;
   return {
     rows: localSize.rows - 1,
     cols: localSize.cols - 1,
   };
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach.ts` around lines 496 - 512, Centralize the
rows/columns eligibility check in canReserveStatusLine and have
reserveStatusLineRow reuse that predicate instead of duplicating the rows >= 3
and cols >= 2 thresholds. Preserve the existing null and undersized return
behavior while ensuring both functions derive reservation decisions from the
same condition.

525-563: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the unused fitStatusLineText helper.

fitStatusLineText and conservativeTerminalCellWidth are only referenced by the status-line tests, while the renderer uses clampStatusLineText(..., true). Keep one truncation model/implementation and remove this duplicate plus the fitStatusLineText import and tests.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach.ts` around lines 525 - 563, Remove the unused
fitStatusLineText helper and its conservativeTerminalCellWidth dependency from
attach.ts, since rendering already uses clampStatusLineText(..., true). Remove
the corresponding fitStatusLineText import and status-line tests, preserving the
existing clampStatusLineText truncation behavior.

804-838: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Wire or drop StatusLineInvalidationScanner.

It is only imported and instantiated in unit code; attach-drive.ts and attach-passthrough.ts still use AnsiBoundaryScanner via StatusLineController, so the status repaint edge case has no production owner. If the invalidation path is kept, privateModes is also rebuilt on every chunk for the same reason as AnsiBoundaryScanner; hoist it and reset lastIndex or use matchAll.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach.ts` around lines 804 - 838, Make
StatusLineInvalidationScanner part of the production status-line repaint flow by
wiring it through StatusLineController and the
attach-drive.ts/attach-passthrough.ts paths, or remove the unused scanner and
its unit-only integration. If retained, hoist the privateModes regular
expression to avoid rebuilding it in push() and reset its lastIndex before
iteration (or use matchAll), while preserving detection of alternate-screen
invalidation sequences.

Source: Linters/SAST tools

packages/harness-driver/src/client.ts (1)

715-734: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Tighten the resized contract wording.

The broker derives resized from send_to_worker(...).is_ok() — the resize_pty frame was dispatched, not acknowledged by the worker (unlike write_pty, which parks a pending request for a real ack). "reached the worker" reads as delivery confirmation; prefer "whether the broker dispatched the restore resize".

Related: ResizePtyBody's doc in crates/broker/src/listen_api.rs still states the handler "skips the resize entirely on release", which this PR makes false — worth updating in the same pass.

📝 Proposed wording
-   * `resized` reports whether that restore reached the worker.
+   * `resized` reports whether the broker dispatched the restore resize to the
+   * worker (it is not a worker-side acknowledgement).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/harness-driver/src/client.ts` around lines 715 - 734, Update the
`resizePty` documentation to state that `resized` reports whether the broker
dispatched the restore resize, not whether the worker acknowledged or received
it. Also revise the `ResizePtyBody` documentation in `listen_api.rs` to remove
the outdated claim that release skips resizing, reflecting that release may
dispatch the resize before dropping ownership.
packages/cli/src/cli/lib/attach-drive.ts (1)

719-748: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Reserved-layout and setup-resize wiring is now duplicated verbatim across the two attach sessions. correctSetupResize and beginSubscribedLayout (and the surrounding tracker/predictive-echo/scroll-region setup) are byte-identical in both files apart from the log prefix and status label, so every future fix to the reservation contract has to be applied twice.

  • packages/cli/src/cli/lib/attach-drive.ts#L719-L748: extract these two helpers into attach.ts (e.g. a createReservedLayout({ verb, terminal, ... }) factory) and call it here.
  • packages/cli/src/cli/lib/attach-passthrough.ts#L438-L465: replace the copied helpers with the shared factory, passing 'passthrough' as the verb.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli/lib/attach-drive.ts` around lines 719 - 748, The
reserved-layout and setup-resize logic is duplicated across both attach
sessions. Extract the shared correctSetupResize and beginSubscribedLayout
behavior into a factory in attach.ts, such as createReservedLayout,
parameterized by the session-specific verb, terminal, and required dependencies;
then replace the duplicated helpers in packages/cli/src/cli/lib/attach-drive.ts
lines 719-748 and packages/cli/src/cli/lib/attach-passthrough.ts lines 438-465,
passing "passthrough" for the latter and preserving each session’s log prefix
and status label.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/cli/lib/attach.test.ts`:
- Around line 31-33: Rename the test case describing reserveStatusLineRow so its
title accurately states that both rows and columns decrease by one, matching the
existing { rows: 39, cols: 119 } assertion.

---

Nitpick comments:
In `@packages/cli/src/cli/lib/attach-drive.test.ts`:
- Around line 1096-1108: The worker_stream tests in
packages/cli/src/cli/lib/attach-drive.test.ts:1096-1108 and
packages/cli/src/cli/lib/attach-passthrough.test.ts:679-691 claim reserved-row
restoration but only count repaints; update both tests to assert the latest
repaint contains the reserved-row CUP (\x1b[30;1H) and child DECSTBM reinstall,
while retaining the existing repaint-count assertion.
- Around line 1708-1747: Update the test around createPredictiveEcho so the
captured predictiveWrite callback is either invoked with representative output
and its effect is asserted, or removed if the test does not need to exercise it.
Do not retain predictiveWrite solely for the toBeTypeOf assertion; ensure the
test directly verifies predictive bytes when keeping the callback.

In `@packages/cli/src/cli/lib/attach-drive.ts`:
- Around line 719-748: The reserved-layout and setup-resize logic is duplicated
across both attach sessions. Extract the shared correctSetupResize and
beginSubscribedLayout behavior into a factory in attach.ts, such as
createReservedLayout, parameterized by the session-specific verb, terminal, and
required dependencies; then replace the duplicated helpers in
packages/cli/src/cli/lib/attach-drive.ts lines 719-748 and
packages/cli/src/cli/lib/attach-passthrough.ts lines 438-465, passing
"passthrough" for the latter and preserving each session’s log prefix and status
label.

In `@packages/cli/src/cli/lib/attach.ts`:
- Around line 496-512: Centralize the rows/columns eligibility check in
canReserveStatusLine and have reserveStatusLineRow reuse that predicate instead
of duplicating the rows >= 3 and cols >= 2 thresholds. Preserve the existing
null and undersized return behavior while ensuring both functions derive
reservation decisions from the same condition.
- Around line 525-563: Remove the unused fitStatusLineText helper and its
conservativeTerminalCellWidth dependency from attach.ts, since rendering already
uses clampStatusLineText(..., true). Remove the corresponding fitStatusLineText
import and status-line tests, preserving the existing clampStatusLineText
truncation behavior.
- Around line 804-838: Make StatusLineInvalidationScanner part of the production
status-line repaint flow by wiring it through StatusLineController and the
attach-drive.ts/attach-passthrough.ts paths, or remove the unused scanner and
its unit-only integration. If retained, hoist the privateModes regular
expression to avoid rebuilding it in push() and reset its lastIndex before
iteration (or use matchAll), while preserving detection of alternate-screen
invalidation sequences.

In `@packages/harness-driver/src/client.ts`:
- Around line 715-734: Update the `resizePty` documentation to state that
`resized` reports whether the broker dispatched the restore resize, not whether
the worker acknowledged or received it. Also revise the `ResizePtyBody`
documentation in `listen_api.rs` to remove the outdated claim that release skips
resizing, reflecting that release may dispatch the resize before dropping
ownership.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a73d2f7-95c6-46b7-b253-2665e1f8d96c

📥 Commits

Reviewing files that changed from the base of the PR and between d5cb6f9 and fe2976f.

📒 Files selected for processing (15)
  • .agentworkforce/trajectories/completed/2026-07/traj_rifnk10uqgl4.md
  • CHANGELOG.md
  • crates/broker/src/listen_api.rs
  • crates/broker/src/runtime/api.rs
  • packages/cli/src/cli/agent-relay-mcp.protocol.test.ts
  • packages/cli/src/cli/agent-relay-mcp.startup.test.ts
  • packages/cli/src/cli/agent-relay-mcp.ts
  • packages/cli/src/cli/lib/attach-drive.test.ts
  • packages/cli/src/cli/lib/attach-drive.ts
  • packages/cli/src/cli/lib/attach-passthrough.test.ts
  • packages/cli/src/cli/lib/attach-passthrough.ts
  • packages/cli/src/cli/lib/attach.test.ts
  • packages/cli/src/cli/lib/attach.ts
  • packages/harness-driver/src/client.ts
  • tests/integration/broker/mcp-injection.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

Comment thread packages/cli/src/cli/lib/attach.test.ts Outdated
relay and others added 2 commits July 29, 2026 20:46
Both doc comments predate the release-carries-dimensions change and now
describe behavior that no longer exists.

- `resizePty` claimed `resized` reports the restore "reached the worker".
  The broker derives it from `send_to_worker(...).is_ok()`, which is
  dispatch success — `resize_pty` parks no pending request, so unlike
  `write_pty` there is no worker-side ack to report.
- `ResizePtyBody` still said the handler "skips the resize entirely on
  release", which stopped being true once a release began applying any
  dimensions it carries.

Comment-only; no behavior change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bkme6VN5DoN2SgcR1jnpXU

Copy link
Copy Markdown
Member Author

Disposition of the 7 nitpicks from the latest CodeRabbit review, so the remaining ones read as considered rather than missed.

Fixed — 595a7ba (the one that was factually wrong, and mine):

  • harness-driver/src/client.ts resized wording. The reviewer is right: the broker derives resized from send_to_worker(...).is_ok(), which is dispatch success — resize_pty parks no pending request, so unlike write_pty there is no worker-side ack. "reached the worker" overstated it. Also corrected ResizePtyBody in listen_api.rs, which still claimed the handler "skips the resize entirely on release" — my release-carries-dimensions change made that false. Comment-only, no behavior change.

Already fixed in 65d226a: the attach.test.ts title.

Deliberately not doing here, with reasons:

  • reserveStatusLineRow / canReserveStatusLine share a threshold (attach.ts:496) — agreed this is a real hazard; the duplicated rows >= 3 && cols >= 2 must stay in lockstep or the paint gate and PTY sizing silently disagree. Behavior is identical today and covered by tests, so it's a pure refactor. Left out to keep this branch minimal while it's pending approval.
  • Unused fitStatusLineText (attach.ts:525) — confirmed dead in production (only the definition and its tests reference it; the renderer uses clampStatusLineText(..., true)). Deleting an exported helper plus its tests is the author's call, not a merge-blocker.
  • StatusLineInvalidationScanner not wired in (attach.ts:804) — this is a design question about intent, not a defect. Either it belongs in StatusLineController or it should go; guessing wrong silently changes repaint behavior. Needs the author.
  • Duplicated reserved-layout wiring across drive/passthrough (attach-drive.ts:719) — real duplication, but CodeRabbit itself scores it 🏗️ heavy lift. Extracting a shared createReservedLayout factory touches both hot attach paths; not something to land unreviewed on a branch waiting on sign-off.
  • Two test-quality nits (attach-drive.test.ts:1096, :1708) — both pre-existing in this PR's tests and scored 🔵 Trivial / 💤 low value.

Note on the Docstring Coverage pre-merge warning (73.68% vs 80%): it dropped from 84.62% only after the rebase onto main pulled #1364 in — it isn't a regression from the review fixes. CodeRabbit's own commit status is success.

Verification on 595a7ba: cargo build -p agent-relay-broker, cargo fmt --check, and prettier --check all clean. Earlier on this head: 857 CLI tests passing, 851 broker tests passing, all 44 CI checks green.


Generated by Claude Code

@willwashburn
willwashburn merged commit cad4512 into main Jul 30, 2026
45 checks passed
@willwashburn
willwashburn deleted the codex/fix-v11-2-cli-demo branch July 30, 2026 00:59
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