fix(cli): restore cursor when configure exits (#10222)

This commit is contained in:
Barry 2026-07-06 04:59:47 +08:00 committed by GitHub
parent 9b837f1a46
commit 4889c0d405
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,11 +28,22 @@ use goose::session::SessionType;
use goose_providers::thinking::ThinkingEffort;
use serde_json::Value;
use std::collections::HashMap;
use std::io::IsTerminal;
use std::io::{IsTerminal, Write};
// useful for light themes where there is no discernible colour contrast between
// cursor-selected and cursor-unselected items.
const MULTISELECT_VISIBILITY_HINT: &str = "<";
const SHOW_CURSOR: &[u8] = b"\x1b[?25h";
struct CursorRestoreGuard;
impl Drop for CursorRestoreGuard {
fn drop(&mut self) {
let mut stdout = std::io::stdout().lock();
let _ = stdout.write_all(SHOW_CURSOR);
let _ = stdout.flush();
}
}
pub async fn handle_configure() -> anyhow::Result<()> {
if !std::io::stdin().is_terminal() {
@ -42,6 +53,7 @@ pub async fn handle_configure() -> anyhow::Result<()> {
);
}
let _cursor_restore = CursorRestoreGuard;
let config = Config::global();
if !config.exists() {