Skip to content

Fix CLI attach control output and drive message controls#1044

Merged
willwashburn merged 4 commits into
mainfrom
fix/cli-attach-controls-pr
Jun 3, 2026
Merged

Fix CLI attach control output and drive message controls#1044
willwashburn merged 4 commits into
mainfrom
fix/cli-attach-controls-pr

Conversation

@willwashburn
Copy link
Copy Markdown
Member

@willwashburn willwashburn commented Jun 3, 2026

User description

Summary

  • keep successful view/drive/passthrough attach banners out of the interactive terminal buffer
  • remove drive/passthrough Ctrl+B and Ctrl+G hotkey handling so those bytes pass through to the agent TUI
  • add explicit local broker controls: agent message hold, agent message flush, and agent message auto
  • update CLI docs and changelog

Tests

  • ./node_modules/.bin/vitest run packages/cli/src/cli/lib/attach-view.test.ts packages/cli/src/cli/lib/attach-drive.test.ts packages/cli/src/cli/lib/attach-passthrough.test.ts packages/cli/src/cli/commands/relaycast-groups.test.ts packages/cli/src/cli/bootstrap.test.ts
  • ./node_modules/.bin/tsc -p packages/cli/tsconfig.json --noEmit

CodeAnt-AI Description

Move message delivery controls out of attach key chords

What Changed

  • drive and passthrough sessions now forward Ctrl+B and Ctrl+G to the agent instead of using them for local actions
  • Ctrl+C is now the local detach key in both attach modes, and the status bar reflects that simpler control
  • Added agent message hold, agent message flush, and agent message auto so message delivery can be managed from another terminal
  • Removed attach startup banners from the interactive terminal buffer

Impact

✅ Fewer broken shortcuts in agent terminal apps
✅ Clearer attach controls
✅ Safer message delivery handling during drive sessions

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@willwashburn willwashburn requested a review from khaliqgant as a code owner June 3, 2026 20:36
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Jun 3, 2026

CodeAnt AI is reviewing your PR.

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Adds agent message subcommands (hold/flush/auto) for local broker delivery control; simplifies attach sessions to forward all bytes except Ctrl+C (which detaches), removes attach opening banners, updates tests, and revises CLI/docs accordingly.

Changes

Message delivery control and attach session simplification

Layer / File(s) Summary
New agent message CLI commands
packages/cli/src/cli/commands/agent.ts, packages/cli/src/cli/bootstrap.test.ts, packages/cli/src/cli/commands/relaycast-groups.test.ts
Adds AgentCommandDependencies with local broker wiring, runLocalBroker helper, and agent message subcommands (flush, hold, auto) that call broker client methods and print JSON; tests validate broker selection and HTTP calls.
Drive attach keybinding simplification
packages/cli/src/cli/lib/attach-drive.ts, packages/cli/src/cli/lib/attach-drive.test.ts
Drive key parsing now only treats Ctrl+C as detach and forwards all other bytes; removes Ctrl+B/Ctrl+G handling and help UI; renderStatusLine signature simplified; opening banner removed; tests updated.
Passthrough attach keybinding simplification
packages/cli/src/cli/lib/attach-passthrough.ts, packages/cli/src/cli/lib/attach-passthrough.test.ts
Passthrough parser narrowed to Ctrl+C detach only and forwards other bytes; status rendering simplified; opening log removed; tests updated for forwarding and Ctrl+C detach.
View attach session banner removal
packages/cli/src/cli/lib/attach-view.ts, packages/cli/src/cli/lib/attach-view.test.ts
Removes WebSocket open handler that logged streaming banners; tests assert no opening banner is emitted.
Documentation and changelog updates
CHANGELOG.md, web/content/docs/cli-agent-management.mdx, web/content/docs/reference-cli.mdx
Changelog and docs add `agent message hold

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

size:M

Suggested reviewers

  • khaliqgant

Poem

A rabbit hops through keybinds with cheer,
Ctrl+B chords fade, Ctrl+C draws near.
Three tiny commands—hold, flush, auto—play,
Messages managed the non-interactive way.
No banners to clutter, just clean detach light. 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% 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 clearly and specifically summarizes the main changes: fixing CLI attach control output (removing banners, changing hotkeys) and adding drive message controls (agent message commands).
Description check ✅ Passed The description covers the core changes with a clear summary section and testing instructions, though it lacks some detail in the Test Plan checklist.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cli-attach-controls-pr

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


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 and usage tips.

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Jun 3, 2026
Copy link
Copy Markdown

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

ℹ️ 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/commands/agent.ts Outdated
function withAgentDefaults(overrides: Partial<AgentCommandDependencies> = {}): AgentCommandDependencies {
return {
...withSdkDefaults(overrides),
connectLocal: (cwd: string) => Promise.resolve(HarnessDriverClient.connect({ cwd })),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add broker selection flags to message controls

When the broker is not using the current directory's default state dir (for example agent-relay local up --state-dir /tmp/relay and local agent attach --state-dir /tmp/relay), these new agent message hold|flush|auto commands have no way to target that same broker because the connection is always created from only cwd. HarnessDriverClient.connect then looks at AGENT_RELAY_STATE_DIR or <cwd>/.agentworkforce/relay/connection.json, so the replacement out-of-band controls fail with “No running broker found” even though the attach commands can connect via --state-dir/--broker-url.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 33f5752: agent message hold|flush|auto now accept --broker-url, --api-key, and --state-dir, resolve them through the shared broker connection path, and have tests covering flag resolution into the default local client.

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Jun 3, 2026

CodeAnt AI finished reviewing your PR.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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.ts`:
- Around line 377-383: The stdin chunk loop in attach-drive.ts currently
continues appending bytes after detecting the detach byte (0x03), causing bytes
after Ctrl+C to be forwarded; modify the logic in stdinDataHandler so that when
iterating a chunk and encountering 0x03 (Ctrl+C) you push 'detach' into actions
and immediately stop processing that chunk (do not append any further bytes to
the forward buffer), ensuring subsequent bytes in the same chunk are dropped;
update tests in attach-drive.test.ts to expect no forwarded bytes after the
detach byte in a coalesced chunk (e.g., "a Ctrl+C b" should only forward "a" and
trigger detach).

In `@packages/cli/src/cli/lib/attach-passthrough.ts`:
- Around line 207-213: The loop that scans incoming chunks currently uses
"continue" when encountering byte === 0x03 (Ctrl+C) which allows later bytes in
the same chunk to be forwarded; change that behavior to stop parsing the chunk
at the first Ctrl+C so no trailing bytes are forwarded: when you detect byte ===
0x03 push 'detach' onto actions and break out of the for (const byte of chunk)
loop (instead of continue), ensuring the forward array does not receive any
bytes after the detach marker.
🪄 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: 9977718c-bc9e-4191-9c46-06c9f6afd66e

📥 Commits

Reviewing files that changed from the base of the PR and between f4ff7e0 and 2a77003.

📒 Files selected for processing (12)
  • CHANGELOG.md
  • packages/cli/src/cli/bootstrap.test.ts
  • packages/cli/src/cli/commands/agent.ts
  • packages/cli/src/cli/commands/relaycast-groups.test.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-view.test.ts
  • packages/cli/src/cli/lib/attach-view.ts
  • web/content/docs/cli-agent-management.mdx
  • web/content/docs/reference-cli.mdx
💤 Files with no reviewable changes (1)
  • packages/cli/src/cli/lib/attach-view.ts

Comment thread packages/cli/src/cli/lib/attach-drive.ts
Comment thread packages/cli/src/cli/lib/attach-passthrough.ts
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 12 files

Re-trigger cubic

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

Preview deployed!

Environment URL
Web https://d109p8vcmv7n93.cloudfront.net

This preview will be cleaned up when the PR is merged or closed.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/cli/src/cli/commands/agent.ts (1)

41-54: 💤 Low value

runLocalBroker passes cwd, but default connectLocal still resolves connection.json from process.cwd()

connectLocal(_cwd, ...) ignores _cwd and relies on resolveBrokerConnection(..., { getDefaultStateDir: deps.getDefaultStateDir }). defaultStateDir() uses getProjectPaths().projectRoot, and getProjectPaths() (when called with no arg) uses findProjectRoot() whose default start dir is process.cwd(). So overriding deps.cwd() won’t change where .agentworkforce/relay/connection.json is read, even though the error message implies running from a specific directory.

Consider either threading _cwd into project-root/state-dir resolution (so connection.json lookup honors the injected cwd) or dropping the _cwd parameter from the connectLocal contract to avoid a misleading dependency.

🤖 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/commands/agent.ts` around lines 41 - 54, The
connectLocal default currently ignores the injected _cwd causing
resolveBrokerConnection/defaultStateDir/getProjectPaths/findProjectRoot to use
process.cwd(); update connectLocal (and its call site runLocalBroker) to pass
the provided _cwd into resolveBrokerConnection via getDefaultStateDir (or into a
new parameter) so resolveBrokerConnection/getDefaultStateDir/getProjectPaths use
that start dir, or alternatively remove the unused _cwd parameter from the
connectLocal signature and update runLocalBroker to not pass it; modify
resolveBrokerConnection/getDefaultStateDir/getProjectPaths usages to accept and
forward the injected cwd so .agentworkforce/relay/connection.json lookup honors
the injected working directory, and update any relevant tests and call sites
accordingly.
🤖 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.

Nitpick comments:
In `@packages/cli/src/cli/commands/agent.ts`:
- Around line 41-54: The connectLocal default currently ignores the injected
_cwd causing
resolveBrokerConnection/defaultStateDir/getProjectPaths/findProjectRoot to use
process.cwd(); update connectLocal (and its call site runLocalBroker) to pass
the provided _cwd into resolveBrokerConnection via getDefaultStateDir (or into a
new parameter) so resolveBrokerConnection/getDefaultStateDir/getProjectPaths use
that start dir, or alternatively remove the unused _cwd parameter from the
connectLocal signature and update runLocalBroker to not pass it; modify
resolveBrokerConnection/getDefaultStateDir/getProjectPaths usages to accept and
forward the injected cwd so .agentworkforce/relay/connection.json lookup honors
the injected working directory, and update any relevant tests and call sites
accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6b58dc9b-81af-45ec-a45b-7085103be7c9

📥 Commits

Reviewing files that changed from the base of the PR and between 2a77003 and 33f5752.

📒 Files selected for processing (12)
  • CHANGELOG.md
  • packages/cli/src/cli/bootstrap.test.ts
  • packages/cli/src/cli/commands/agent.ts
  • packages/cli/src/cli/commands/relaycast-groups.test.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-view.test.ts
  • packages/cli/src/cli/lib/attach-view.ts
  • web/content/docs/cli-agent-management.mdx
  • web/content/docs/reference-cli.mdx
💤 Files with no reviewable changes (1)
  • packages/cli/src/cli/lib/attach-view.ts
✅ Files skipped from review due to trivial changes (3)
  • web/content/docs/reference-cli.mdx
  • web/content/docs/cli-agent-management.mdx
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/cli/src/cli/bootstrap.test.ts
  • packages/cli/src/cli/lib/attach-view.test.ts
  • packages/cli/src/cli/lib/attach-passthrough.ts
  • packages/cli/src/cli/lib/attach-passthrough.test.ts
  • packages/cli/src/cli/lib/attach-drive.ts
  • packages/cli/src/cli/lib/attach-drive.test.ts

@willwashburn willwashburn merged commit c781146 into main Jun 3, 2026
46 checks passed
@willwashburn willwashburn deleted the fix/cli-attach-controls-pr branch June 3, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant