fix: Windows prompt cursor positioning issue with ANSI escape sequences#4464
Conversation
084d9bc to
2e6ee5e
Compare
|
Bump |
michaelneale
left a comment
There was a problem hiding this comment.
looks good to me, can't test on windows myself but downside risk is low. And I learned that you can use "not" in platform macros, very cool! thanks @thebristolsound
|
Thanks! Taking a look at these test failures, they were passing locally but something looks a bit off. |
cdf5e7c to
4b47fd8
Compare
4b47fd8 to
e18f9cd
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a Windows-specific bug where ANSI escape sequences in the Goose CLI prompt cause incorrect cursor positioning and visual artifacts in terminals. The solution implements platform-specific prompt generation to use plain text on Windows while preserving styled prompts on other platforms.
- Extracted prompt generation into a reusable
get_input_prompt_string()function with conditional compilation - Added Windows-specific workaround to use plain text prompts without ANSI escape sequences
- Included comprehensive unit tests to verify platform-specific behavior and prompt consistency
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
e679c9c to
c53456a
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
thanks @thebristolsound you will need to also follow instructions for the DCO Check: https://github.com/block/goose/pull/4464/checks?check_run_id=50117009096 |
a695b3f to
3a10238
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
8a1ac80 to
d3ccb4a
Compare
f390049 to
0465c08
Compare
Signed-off-by: Matt Donovan <[email protected]> Update crates/goose-cli/src/session/input.rs Co-authored-by: Copilot <[email protected]> Signed-off-by: Matt Donovan <[email protected]> Update input.rs Signed-off-by: Matt Donovan <[email protected]>
Co-authored-by: Copilot <[email protected]> Signed-off-by: Matt Donovan <[email protected]> Remove useless unit test Signed-off-by: Matt Donovan <[email protected]>
…(terminal vs plaintext) Signed-off-by: Matt Donovan <[email protected]>
c7e4381 to
ff2bf74
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
ff2bf74 to
68f0c6b
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Signed-off-by: Matt Donovan <[email protected]>
68f0c6b to
adfee2d
Compare
|
Okay, sorry for the notification spam on this one, but I think we're all green in the pipeline now. I've re-requested review as I made some minor adjustments to the unit tests in this PR. Let me know if anything else comes up or you want additional changes. cc @michaelneale |
|
bump. Any chance we can get this merged in? |
|
yes! |
…-unification * 'main' of github.com:block/goose: (24 commits) feat(cli): add `path` & `limit` to `session list` command (#4878) Allow better concurrent access (#4896) fix: Windows prompt cursor positioning issue with ANSI escape sequences (#4464) Fix: LiteLLM API key field not showing in UI configuration (#4105) fix: path is duplicated on tool calls causing them to fail (#4658) (#4859) add new prompt to get all available tutorials (#4802) Add filtering for agentVisible: false messages on streaming providers (#4847) alexhancock/mcp-crate-cleanup (#4885) docs: rename sub-recipe to subrecipe (#4886) docs: new multi-model section with autopilot topic (#4864) make agent manager singleton (#4880) Cli web auth token (#4456) fix(token_counter): fix panic with GitHub Copilot (#4632) Revert "Internal MCP Crate Cleanup (#4800)" (#4883) remove 2 redundant comments and one that lies (#4866) Internal MCP Crate Cleanup (#4800) Fix #4612: Return non-zero exit code when CLI session ends with error (#4621) Dead code cleanup (#4873) fix: restoring test data and correcting name (#4875) Add .goosehints file to enforce lowercase branding in documentation (#4870) ...
* main: (206 commits) Tiny: fix github casing (block#4903) remove anyOf from create_task tool (block#4897) chore(deps): bump tracing-subscriber from 0.3.19 to 0.3.20 (block#4442) fix optional recipe schema zod validation (block#4900) Added CMD+T keyboard shortcut that takes you to the Home tab (block#4541) feat(cli): add `path` & `limit` to `session list` command (block#4878) Allow better concurrent access (block#4896) fix: Windows prompt cursor positioning issue with ANSI escape sequences (block#4464) Fix: LiteLLM API key field not showing in UI configuration (block#4105) fix: path is duplicated on tool calls causing them to fail (block#4658) (block#4859) add new prompt to get all available tutorials (block#4802) Add filtering for agentVisible: false messages on streaming providers (block#4847) alexhancock/mcp-crate-cleanup (block#4885) docs: rename sub-recipe to subrecipe (block#4886) docs: new multi-model section with autopilot topic (block#4864) make agent manager singleton (block#4880) Cli web auth token (block#4456) fix(token_counter): fix panic with GitHub Copilot (block#4632) Revert "Internal MCP Crate Cleanup (block#4800)" (block#4883) remove 2 redundant comments and one that lies (block#4866) ...
…es (block#4464) Signed-off-by: Matt Donovan <[email protected]> Co-authored-by: Matt Donovan <[email protected]> Signed-off-by: HikaruEgashira <[email protected]>
Fix Windows prompt cursor positioning issue with ANSI escape sequences
Overview
This PR addresses a Windows-specific bug where ANSI escape sequences in the Goose CLI prompt cause incorrect cursor positioning and visual artifacts. This is a follow-up to the draft PR #3989 originally started by another contributor, with a refined implementation focused on simplicity and reliability.
Problem Description
On Windows, the Goose CLI prompt uses ANSI escape sequences for styling (cyan and bold colors):
However,
rustylineon Windows has a known issue with ANSI escape sequence width calculation that causes:Root Cause
This is a known issue in the
rustylinelibrary where ANSI escape sequences are not properly accounted for in width calculations on Windows terminals. The issue affects howrustylinepositions the cursor relative to the displayed text.Related Issues:
Solution
This PR implements a Windows-specific workaround with a simple, direct approach:
Platform-Specific Prompt Generation: The
get_input_prompt_string()function uses a compile-timecfg!check to determine the operating system:"( O)> "without ANSI escape sequencesCode Changes
cfg!(target_os = "windows")directly in the prompt generation function to conditionally return styled or plain text#[cfg]) to test only the behavior that runs on each platform, avoiding CI/CD environment issuesTesting
The
test_get_input_prompt_stringtest uses conditional compilation to validate platform-specific behavior:This approach ensures tests are reliable across different environments and CI/CD systems.
Future Considerations
This workaround should be removed once the repository updates to a version of
rustylinethat includes the fix from kkawakam/rustyline#890 and the fix has been verified to resolve the cursor positioning issues on Windows.Credit
This work builds upon the draft PR #3989 originally created by another contributor. The implementation has been simplified for reliability and maintainability. #3989
Before screenshot:

After (fixed):

Screenshots taken in Windows 11 Terminal Preview, PowerShell 7