Fix CLI attach control output and drive message controls#1044
Conversation
|
CodeAnt AI is reviewing your PR. |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
📝 WalkthroughWalkthroughAdds ChangesMessage delivery control and attach session simplification
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsStopped 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 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. Comment |
There was a problem hiding this comment.
💡 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".
| function withAgentDefaults(overrides: Partial<AgentCommandDependencies> = {}): AgentCommandDependencies { | ||
| return { | ||
| ...withSdkDefaults(overrides), | ||
| connectLocal: (cwd: string) => Promise.resolve(HarnessDriverClient.connect({ cwd })), |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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 finished reviewing your PR. |
There was a problem hiding this comment.
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
📒 Files selected for processing (12)
CHANGELOG.mdpackages/cli/src/cli/bootstrap.test.tspackages/cli/src/cli/commands/agent.tspackages/cli/src/cli/commands/relaycast-groups.test.tspackages/cli/src/cli/lib/attach-drive.test.tspackages/cli/src/cli/lib/attach-drive.tspackages/cli/src/cli/lib/attach-passthrough.test.tspackages/cli/src/cli/lib/attach-passthrough.tspackages/cli/src/cli/lib/attach-view.test.tspackages/cli/src/cli/lib/attach-view.tsweb/content/docs/cli-agent-management.mdxweb/content/docs/reference-cli.mdx
💤 Files with no reviewable changes (1)
- packages/cli/src/cli/lib/attach-view.ts
2a77003 to
33f5752
Compare
|
Preview deployed!
This preview will be cleaned up when the PR is merged or closed. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/cli/src/cli/commands/agent.ts (1)
41-54: 💤 Low value
runLocalBrokerpassescwd, but defaultconnectLocalstill resolvesconnection.jsonfromprocess.cwd()
connectLocal(_cwd, ...)ignores_cwdand relies onresolveBrokerConnection(..., { getDefaultStateDir: deps.getDefaultStateDir }).defaultStateDir()usesgetProjectPaths().projectRoot, andgetProjectPaths()(when called with no arg) usesfindProjectRoot()whose default start dir isprocess.cwd(). So overridingdeps.cwd()won’t change where.agentworkforce/relay/connection.jsonis read, even though the error message implies running from a specific directory.Consider either threading
_cwdinto project-root/state-dir resolution (soconnection.jsonlookup honors the injected cwd) or dropping the_cwdparameter from theconnectLocalcontract 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
📒 Files selected for processing (12)
CHANGELOG.mdpackages/cli/src/cli/bootstrap.test.tspackages/cli/src/cli/commands/agent.tspackages/cli/src/cli/commands/relaycast-groups.test.tspackages/cli/src/cli/lib/attach-drive.test.tspackages/cli/src/cli/lib/attach-drive.tspackages/cli/src/cli/lib/attach-passthrough.test.tspackages/cli/src/cli/lib/attach-passthrough.tspackages/cli/src/cli/lib/attach-view.test.tspackages/cli/src/cli/lib/attach-view.tsweb/content/docs/cli-agent-management.mdxweb/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
User description
Summary
Tests
CodeAnt-AI Description
Move message delivery controls out of attach key chords
What Changed
driveandpassthroughsessions now forwardCtrl+BandCtrl+Gto the agent instead of using them for local actionsCtrl+Cis now the local detach key in both attach modes, and the status bar reflects that simpler controlagent message hold,agent message flush, andagent message autoso message delivery can be managed from another terminalImpact
✅ 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:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
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:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
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.