Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/core/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ pub struct AiConfig {
pub api_key: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub base_url: Option<String>,
#[serde(default = "default_true")]
pub diagnostic_banner: bool,
}

fn default_true() -> bool {
true
}

impl Default for AiConfig {
Expand All @@ -53,6 +59,7 @@ impl Default for AiConfig {
model: "claude-haiku-4-5-20251001".into(),
api_key: String::new(),
base_url: None,
diagnostic_banner: true,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/core/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub struct Grid {
pub enum ControlCommand {
OpenAskAi { preset: Option<std::sync::Arc<str>> },
OpenExplainAi { preset: Option<std::sync::Arc<str>> },
CommandFailure(u8),
}

impl Grid {
Expand Down
12 changes: 12 additions & 0 deletions src/sys/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,18 @@ impl<'a> Perform for AnsiExecutor<'a> {
.control_queue
.push(ControlCommand::OpenAskAi { preset });
}
cli::constants::PRIVATE_NOVA_OSC_CODE_BYTES
if params.len() >= 2 && params[1] == b"command_failure" =>
{
let code = params
.get(2)
.and_then(|c| std::str::from_utf8(c).ok()?.parse().ok())
.unwrap_or(1);
self
.grid
.control_queue
.push(ControlCommand::CommandFailure(code));
}
cli::constants::PRIVATE_NOVA_OSC_CODE_BYTES
if params.len() >= 2 && params[1] == b"explain_ai" =>
{
Expand Down
38 changes: 28 additions & 10 deletions src/sys/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ fn build_shell_command(shell: &str, initial_cwd: Option<&str>) -> CommandBuilder
let ps_prompt_script = format!(
r#"
Set-Item function:prompt {{
if (-not $global:__nova_prompt_count) {{ $global:__nova_prompt_count = $true; $global:LASTEXITCODE = 0; $exitCode = 0 }} else {{ $exitCode = $global:LASTEXITCODE; $global:LASTEXITCODE = 0 }}
$p = $PWD.ProviderPath;
$h = [regex]::Escape($env:USERPROFILE);
$d = $p -replace ('^' + $h), '~';
$uri = 'file://localhost/' + ($p -replace '\\', '/');
$ESC = [char]27;
Write-Host -NoNewline ('{{0}}]7;{{1}}{{0}}{{2}}' -f [char]27, $uri, [char]92);
return ($ESC + '[38;2;128;128;128m' + $d + $ESC + '[0m ' + $ESC + '[38;2;{ar};{ag};{ab}mλ' + $ESC + '[0m ')
$diag = if ($exitCode -ne 0) {{ "$ESC]777;command_failure;$exitCode$([char]7)" }} else {{ "" }}
return ($diag + $ESC + '[38;2;128;128;128m' + $d + $ESC + '[0m ' + $ESC + '[38;2;{ar};{ag};{ab}mλ' + $ESC + '[0m ')
}}
if (-not (Get-Command ssh -CommandType Function -ErrorAction SilentlyContinue)) {{
function global:ssh {{
Expand All @@ -142,7 +144,7 @@ fn build_shell_command(shell: &str, initial_cwd: Option<&str>) -> CommandBuilder
$ssh_exe = (Get-Command -Name ssh -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1).Source
if ($ssh_exe) {{ & $ssh_exe @args }} else {{ Write-Error 'ssh not found' }}
$p2 = $PWD.ProviderPath; $u2 = 'file://localhost/' + ($p2 -replace '\\', '/')
Write-Host -NoNewline ('{{0}}]7;{{1}}{{0}}{{2}}' -f [char]27, $u2, [char]92)
Write-Host -NoNewline ('{{0}}]7;ssh://{{1}}{{0}}{{2}}' -f [char]27, $u2, [char]92)
}}
}}
"#
Expand Down Expand Up @@ -181,14 +183,18 @@ fn build_shell_command(shell: &str, initial_cwd: Option<&str>) -> CommandBuilder
);
c.env(
"PROMPT_COMMAND",
r#"if ! declare -f __nova_ssh > /dev/null 2>&1; then
r#"__nova_exit_code=$?
if ! declare -f __nova_ssh > /dev/null 2>&1; then
__nova_ssh() { local h="" s=false; for a in "$@"; do $s && { s=false; continue; }; case "$a" in -b|-c|-D|-E|-e|-F|-I|-i|-J|-L|-l|-m|-o|-p|-Q|-R|-S|-W|-w) s=true;; -*) ;; *) h="$a"; break;; esac; done; [ -n "$h" ] && printf "\033]7;ssh://%s\033\\" "$h"; command ssh "$@"; printf "\033]7;file://%s%s\033\\" "$HOSTNAME" "$PWD"; }
ssh() { __nova_ssh "$@"; }
fi
if ! declare -f __nova_osc7 > /dev/null 2>&1; then
__nova_osc7() { printf "\033]7;file://%s%s\033\\" "$HOSTNAME" "$PWD"; }
fi
__nova_osc7"#,
__nova_osc7
if [ "$__nova_exit_code" -ne 0 ]; then
printf "\033]777;command_failure;$__nova_exit_code\a"
fi"#,
);
c
} else if is_git_bash {
Expand All @@ -211,14 +217,18 @@ __nova_osc7"#,
);
c.env(
"PROMPT_COMMAND",
r#"if ! declare -f __nova_ssh > /dev/null 2>&1; then
r#"__nova_exit_code=$?`
if ! declare -f __nova_ssh > /dev/null 2>&1; then
__nova_ssh() { local h="" s=false; for a in "$@"; do $s && { s=false; continue; }; case "$a" in -b|-c|-D|-E|-e|-F|-I|-i|-J|-L|-l|-m|-o|-p|-Q|-R|-S|-W|-w) s=true;; -*) ;; *) h="$a"; break;; esac; done; [ -n "$h" ] && printf "\033]7;ssh://%s\033\\" "$h"; command ssh "$@"; printf "\033]7;file://%s%s\033\\" "$HOSTNAME" "$PWD"; }
ssh() { __nova_ssh "$@"; }
fi
if ! declare -f __nova_osc7 > /dev/null 2>&1; then
__nova_osc7() { printf "\033]7;file://%s%s\033\\" "$HOSTNAME" "$PWD"; }
fi
__nova_osc7"#,
__nova_osc7
if [ "$__nova_exit_code" -ne 0 ]; then
printf "\033]777;command_failure;$__nova_exit_code\a"
fi"#,
);
c.args(["--login", "-i"]);
c
Expand Down Expand Up @@ -270,14 +280,18 @@ __nova_osc7"#,
);
c.env(
"PROMPT_COMMAND",
r#"if ! declare -f __nova_ssh > /dev/null 2>&1; then
r#"__nova_exit_code=$?
if ! declare -f __nova_ssh > /dev/null 2>&1; then
__nova_ssh() { local h="" s=false; for a in "$@"; do $s && { s=false; continue; }; case "$a" in -b|-c|-D|-E|-e|-F|-I|-i|-J|-L|-l|-m|-o|-p|-Q|-R|-S|-W|-w) s=true;; -*) ;; *) h="$a"; break;; esac; done; [ -n "$h" ] && printf "\033]7;ssh://%s\033\\" "$h"; command ssh "$@"; printf "\033]7;file://%s%s\033\\" "$HOSTNAME" "$PWD"; }
ssh() { __nova_ssh "$@"; }
fi
if ! declare -f __nova_osc7 > /dev/null 2>&1; then
__nova_osc7() { printf "\033]7;file://%s%s\033\\" "$HOSTNAME" "$PWD"; }
fi
__nova_osc7"#,
__nova_osc7
if [ "$__nova_exit_code" -ne 0 ]; then
printf "\033]777;command_failure;$__nova_exit_code\a"
fi"#,
);

c.env(
Expand All @@ -288,14 +302,18 @@ __nova_osc7"#,
);
c.env(
"NOVA_PROMPT_COMMAND",
r#"if ! declare -f __nova_ssh > /dev/null 2>&1; then
r#"__nova_exit_code=$?
if ! declare -f __nova_ssh > /dev/null 2>&1; then
__nova_ssh() { local h="" s=false; for a in "$@"; do $s && { s=false; continue; }; case "$a" in -b|-c|-D|-E|-e|-F|-I|-i|-J|-L|-l|-m|-o|-p|-Q|-R|-S|-W|-w) s=true;; -*) ;; *) h="$a"; break;; esac; done; [ -n "$h" ] && printf "\033]7;ssh://%s\033\\" "$h"; command ssh "$@"; printf "\033]7;file://%s%s\033\\" "$HOSTNAME" "$PWD"; }
ssh() { __nova_ssh "$@"; }
fi
if ! declare -f __nova_osc7 > /dev/null 2>&1; then
__nova_osc7() { printf "\033]7;file://%s%s\033\\" "$HOSTNAME" "$PWD"; }
fi
__nova_osc7"#,
__nova_osc7
if [ "$__nova_exit_code" -ne 0 ]; then
printf "\033]777;command_failure;$__nova_exit_code\a"
fi"#,
);
}
c
Expand Down
Loading