Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Sep 15, 2025

Fix 'Press any key to continue' to accept any key, not just Enter

Summary

The agentuity project import command was showing "Press any key to continue..." prompts that only responded to the Enter key, not any key as advertised. This was caused by the underlying tui.WaitForAnyKey() and tui.WaitForAnyKeyMessage() functions using regular os.Stdin.Read(), which requires Enter to flush the input buffer.

Solution:

  • Created new internal/input package with WaitForAnyKey() and WaitForAnyKeyMessage() functions
  • Uses raw terminal mode (term.MakeRaw()) for immediate keypress detection, following the same pattern as the existing AskForConfirm() function
  • Replaced all 5 call sites across the codebase with the new implementation
  • Includes proper signal handling for Ctrl+C and graceful fallback if raw mode fails

Testing: Created standalone test program that successfully detected space bar and letter keys without requiring Enter.

Review & Testing Checklist for Human

  • Test actual CLI flow: Run agentuity project import and verify the "Press any key to continue..." prompt responds to various keys (letters, numbers, space, arrow keys) without needing Enter
  • Test signal handling: During a "press any key" prompt, press Ctrl+C to ensure it still properly cancels the operation and doesn't leave terminal in broken state
  • Test terminal state: Interrupt the program during keypress waiting (kill process, etc.) and verify terminal still works normally afterward

Notes

Summary by CodeRabbit

  • Chores

    • Upgraded Go toolchain and refreshed dependencies across telemetry, networking, gRPC/protobuf, crypto, and logging stacks; removed deprecated/unused packages. Improves stability, compatibility, and maintainability.
  • Security

    • Incorporated upstream security patches via updated cryptography and core libraries.
  • Performance

    • Minor performance and resource efficiency improvements from upstream dependency updates.
  • Bug Fixes

    • Transitive fixes from dependency upgrades, reducing edge-case failures and improving reliability.

- Create local input.WaitForAnyKey() and input.WaitForAnyKeyMessage() functions
- Use raw terminal mode like existing AskForConfirm() pattern
- Replace all calls to tui.WaitForAnyKey() and tui.WaitForAnyKeyMessage()
- Fixes issue where only Enter key worked instead of any key
- Tested with space key and letter keys - both work immediately

Co-Authored-By: Dhilan Fye <dfye@agentuity.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 15, 2025

Walkthrough

Dependency updates in go.mod: toolchain bumped to Go 1.25.1, multiple direct and indirect modules upgraded (OpenTelemetry, gRPC, protobuf, golang.org/x/*, testify, go-common), some indirects removed/added (e.g., remove filippo.io/edwards25519, add github.com/cenkalti/backoff/v5). No source files or public APIs changed.

Changes

Cohort / File(s) Summary
Module and dependency updates
go.mod
- Toolchain: go 1.25 → 1.25.1
- go-common: v1.0.72 → v1.0.91
- testify: v1.10.0 → v1.11.1
- Remove indirect: filippo.io/edwards25519 v1.1.0
- Add indirect: github.com/cenkalti/backoff/v5 v5.0.3; drop v4
- golang.org/x: crypto v0.36.0 → v0.41.0; term v0.30.0 → v0.34.0; net v0.43.0; sync v0.16.0; sys v0.35.0; text v0.28.0
- OpenTelemetry: core/sdk/exporters to v1.38.x; logs otlp http exporter v0.14.0; proto/otlp v1.7.1
- gRPC/protobuf: grpc v1.75.0; protobuf v1.36.8; genproto to 202508xx revisions
- grpc-gateway: v2.26.3 → v2.27.2
- go-logr/logr: v1.4.2 → v1.4.3

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibble on modules, hop through the vines,
Updating the garden of tidy go lines.
OTel blooms brighter, gRPC hums along,
Backoff v5 taps a steadier song.
With 1.25.1 under moonlit mod,
I thump, "deps aligned!"—then wink at the pod. 🐰✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title is concise and specifically describes the PR's primary intent from the PR objectives: changing the "Press any key to continue" prompt to accept any key instead of only Enter, making it clear what behavior is fixed.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1757949618-fix-any-key-continue

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
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

🧹 Nitpick comments (2)
internal/input/input.go (2)

25-31: Cooked‑mode fallback should consume the whole line to avoid stray buffered input.

Reading a single byte in cooked mode leaves the rest (including newline) in stdin, which can bleed into the next prompt.

Apply this diff:

-	oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
+	oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
 	if err != nil {
 		fmt.Print(message)
-		buf := make([]byte, 1)
-		os.Stdin.Read(buf)
+		// cooked mode: read until newline so nothing leaks into subsequent prompts
+		br := bufio.NewReader(os.Stdin)
+		_, _ = br.ReadBytes('\n')
 		return
 	}

Add import:

 import (
 	"context"
 	"fmt"
+	"bufio"
 	"os"

39-43: Arrow/function keys emit multi‑byte sequences; consider draining residual bytes.

Reading only one byte can leave extra bytes (e.g., “ESC [ A”) in the buffer, which downstream prompts might observe. If portability allows later, we can non‑blocking‑read a few more bytes after the first ESC to drain common sequences. Not a blocker for this PR.

Please sanity‑test by pressing arrow keys at the prompt, then immediately opening a selection prompt (e.g., a tui.Select) to confirm there’s no spurious input.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b0a6104 and 4825552.

📒 Files selected for processing (6)
  • cmd/agent.go (2 hunks)
  • cmd/cloud.go (2 hunks)
  • cmd/mcp.go (2 hunks)
  • cmd/project.go (2 hunks)
  • internal/errsystem/console.go (2 hunks)
  • internal/input/input.go (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-05-22T18:27:10.386Z
Learnt from: jhaynie
PR: agentuity/cli#313
File: cmd/cloud.go:852-853
Timestamp: 2025-05-22T18:27:10.386Z
Learning: In the agentuity CLI codebase, there's a specific error handling pattern: errsystem is used exclusively for unexpected system errors, while expected error conditions use tui.ShowWarning() and direct os.Exit(1) calls.

Applied to files:

  • internal/errsystem/console.go
🧬 Code graph analysis (5)
cmd/agent.go (1)
internal/input/input.go (1)
  • WaitForAnyKey (15-17)
cmd/cloud.go (1)
internal/input/input.go (1)
  • WaitForAnyKey (15-17)
cmd/mcp.go (1)
internal/input/input.go (1)
  • WaitForAnyKeyMessage (20-60)
internal/errsystem/console.go (1)
internal/input/input.go (1)
  • WaitForAnyKeyMessage (20-60)
cmd/project.go (1)
internal/input/input.go (1)
  • WaitForAnyKeyMessage (20-60)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build and Test (blacksmith-4vcpu-ubuntu-2204)
  • GitHub Check: Test CLI Upgrade Path (blacksmith-4vcpu-ubuntu-2204)
  • GitHub Check: Test CLI Upgrade Path (windows-latest)
  • GitHub Check: Analyze (go)
🔇 Additional comments (4)
cmd/cloud.go (1)

23-23: Switch to internal/input looks good.

Import and call-site replacement correctly route to the new raw‑mode implementation.

Also applies to: 97-97

cmd/mcp.go (1)

12-12: Good migration to input.WaitForAnyKeyMessage().

The prompt now benefits from raw‑mode reads; no other behavior changes.

Also applies to: 123-123

cmd/project.go (1)

17-17: Project flow now uses raw‑mode keypress; LGTM.

Import and call-site change are correct and TTY‑safe.

Also applies to: 424-424

cmd/agent.go (1)

20-20: Agent warnings pause now honors any key; looks good.

Minimal, correct change.

Also applies to: 586-586

- Explicitly call term.Restore() before os.Exit(1) in signal handlers
- Prevents terminal from being left in raw mode when user presses Ctrl+C
- Addresses CodeRabbit review feedback about proper cleanup

Co-Authored-By: Dhilan Fye <dfye@agentuity.com>
Copy link
Member

@jhaynie jhaynie left a comment

Choose a reason for hiding this comment

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

instead of making this change in this project we should instead fix the bug in the tui package of go-common

@devin-ai-integration
Copy link
Contributor Author

Thanks for the feedback @jhaynie! You're absolutely right - fixing this in the go-common tui package would be the better architectural approach since it would benefit all projects using go-common.

I can see two options:

  1. Fix the and functions in go-common/tui/input.go to use raw terminal mode (like already does)
  2. Keep the current CLI-specific fix as a temporary solution

Would you prefer I:

  • Create a separate PR for go-common with the proper fix?
  • Close this PR and start fresh with the go-common approach?
  • Or keep this as a temporary fix until the go-common change is ready?

Let me know your preference and I'll proceed accordingly.

- Updated go-common dependency from v1.0.72 to v1.0.91 (contains merged fix)
- Removed internal/input package (CLI-specific workaround)
- Reverted all imports back to using tui.WaitForAnyKey() and tui.WaitForAnyKeyMessage()
- Verified fix works correctly with any key press (not just Enter)
- Cleaned up go.mod dependencies

Co-Authored-By: Dhilan Fye <dfye@agentuity.com>
Copy link
Member

@jhaynie jhaynie left a comment

Choose a reason for hiding this comment

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

looks good!

Copy link
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: 0

🧹 Nitpick comments (1)
go.mod (1)

30-62: Minor tidy: run go mod tidy to drop any unused or misclassified direct deps.

E.g., go-git/go-git/v5 is listed without // indirect in a secondary block; tidy will normalize.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 026b9e2 and 35a6626.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test CLI Upgrade Path (windows-latest)
  • GitHub Check: Analyze (go)
🔇 Additional comments (7)
go.mod (7)

132-139: grpc/protobuf/genproto set updated: run tests touching RPC code to catch wire incompatibilities early.

Pseudo‑versions for genproto are fine; ensure generated stubs match these versions.


23-23: Testify bump to v1.11.1: run unit tests to catch any matcher/require API shifts.

Low risk, but confirm no deprecation fallout.


36-36: Backoff major version bump (v4 → v5): confirm no lingering v4 imports
Automated search for 'cenkalti/backoff/v4' produced no output; manually verify all Go imports use 'github.com/cenkalti/backoff/v5' and go.mod requires v5 — e.g. run locally: rg -nP --type go 'cenkalti/backoff(/v4)?'.


59-61: No term.MakeRaw/term.Restore found — original raw‑mode concern not applicable.

rg showed no calls to term.MakeRaw, term.Restore, or signal.Notify; only isatty.IsTerminal in internal/errsystem/console.go (calls tui.WaitForAnyKeyMessage, ~lines 146–152). If tui.WaitForAnyKeyMessage itself uses x/term.MakeRaw then apply TTY gating and ensure term.Restore via defer + signal handlers; otherwise ignore this comment.

Likely an incorrect or invalid review comment.


120-129: OTel upgrade OK — no removed/renamed APIs found.

Found only internal/dev/server.go:644 using otel.Tracer(..., trace.WithInstrumentationAttributes(...)); both otel.Tracer and trace.WithInstrumentationAttributes are present in the opentelemetry-go API docs. (pkg.go.dev)


3-3: Invalid go directive: patch versions aren’t allowed; add a toolchain line instead.

go.mod only accepts MAJOR.MINOR in the go directive. Use go 1.25 and specify the patch via toolchain go1.25.1.

Apply this diff:

-go 1.25.1
+go 1.25
+toolchain go1.25.1

Likely an incorrect or invalid review comment.


7-7: Confirm AskForConfirm API compatibility with github.com/agentuity/go-common v1.0.91

go.mod pins github.com/agentuity/go-common v1.0.91; callsites found: internal/bundler/upgrade.go and internal/bundler/bundler.go — verify AskForConfirm's signature/return type in the go-common v1.0.91 tag matches these usages (or update the callsites/tests).

@jhaynie jhaynie merged commit a1ef78d into main Sep 15, 2025
14 checks passed
@jhaynie jhaynie deleted the devin/1757949618-fix-any-key-continue branch September 15, 2025 19:47
devin-ai-integration bot added a commit that referenced this pull request Sep 24, 2025
- Added: [AGENT-684] Check if zsh is installed before adding autocomplete in the CLI (#450)
- Added: [AGENT-628] Unit tests (#441)
- Added: feat: automatically add AGENTUITY_SDK_KEY and AGENTUITY_PROJECT_KEY to .env file when running dev command (#442)
- Changed: Dont sort releases by commit msg (#447)
- Changed: [AGENT-628] prevent local development env files from syncing to production (#440)
- Fixed: Fix npm workspaces (#451)
- Fixed: Fix 'Press any key to continue' to accept any key, not just Enter (#445)

Co-Authored-By: unknown <>
jhaynie pushed a commit that referenced this pull request Sep 24, 2025
- Added: [AGENT-684] Check if zsh is installed before adding autocomplete in the CLI (#450)
- Added: [AGENT-628] Unit tests (#441)
- Added: feat: automatically add AGENTUITY_SDK_KEY and AGENTUITY_PROJECT_KEY to .env file when running dev command (#442)
- Changed: Dont sort releases by commit msg (#447)
- Changed: [AGENT-628] prevent local development env files from syncing to production (#440)
- Fixed: Fix npm workspaces (#451)
- Fixed: Fix 'Press any key to continue' to accept any key, not just Enter (#445)

Co-Authored-By: unknown <>

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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