aKode 0.3.1: Shift+Tab a tre modalità e topic di Telegram più puliti
- Shift+Tab: default, plan, accesso completo (preset di /permissions, saltato se i requisiti non lo permettono; uscendo tornano i permessi di prima). Modalità sotto il riquadro di scrittura, a sinistra, e in /stato su Telegram. - Telegram: topic creato al primo turno; sessioni chiuse senza turni perdono il topic, le altre diventano «(chiusa)» con nuovi tentativi; topic di «Nuova chat» assegnati con i pulsanti, i comandi lì ricevono risposta nella chat principale; pulizia all'avvio. - Versione 0.3.1 e novità nel README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@ expression: "render_bottom_popup(&app.chat_widget,\nwidth).replace(r\"C:\\cli-bu
|
||||
│
|
||||
|
||||
Update daemon and exit aKode?
|
||||
Use this CLI package v0.2.0 from /x/cli-build/bin/akode. Copy the
|
||||
Use this CLI package v0.3.1 from /x/cli-build/bin/akode. Copy the
|
||||
complete package and pin it against automatic updates.
|
||||
This may restart the daemon and interrupt active or queued work.
|
||||
Codex exits to update in this terminal. Relaunch it afterward.
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: "format!(\"enabled:\\n{}\\n---\\ndisabled:\\n{}\", text(after), text
|
||||
---
|
||||
enabled:
|
||||
|
||||
▄▄████▄▄ aKode v0.2.0
|
||||
▄▄████▄▄ aKode v0.3.1
|
||||
██▀▀██▀▀██ GPT-5.6-Sol · mock
|
||||
██▄▄██▄▄██ /tmp/project
|
||||
██▀████▀██
|
||||
@@ -50,7 +50,7 @@ enabled:
|
||||
---
|
||||
disabled:
|
||||
|
||||
▄▄████▄▄ aKode v0.2.0
|
||||
▄▄████▄▄ aKode v0.3.1
|
||||
██▀▀██▀▀██ GPT-5.6-Sol · mock
|
||||
██▄▄██▄▄██ /tmp/project
|
||||
██▀████▀██
|
||||
|
||||
@@ -3,7 +3,7 @@ source: tui/src/app/tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
▄▄████▄▄ aKode v0.2.0
|
||||
▄▄████▄▄ aKode v0.3.1
|
||||
██▀▀██▀▀██ gpt-test · mock
|
||||
██▄▄██▄▄██ <thread cwd>
|
||||
██▀████▀██
|
||||
|
||||
@@ -4,4 +4,5 @@ expression: "render_bottom_popup(&app.chat_widget, 80)"
|
||||
---
|
||||
› kept draft
|
||||
|
||||
gpt-test default Plan mode (⇧tab to cycle)
|
||||
gpt-test default
|
||||
⏸ plan mode attivo (shift+tab per cambiare)
|
||||
|
||||
@@ -5,3 +5,4 @@ expression: "normalize_snapshot_paths(render_bottom_popup(&app.chat_widget, 80))
|
||||
› startup draft
|
||||
|
||||
127.0.0.1:9 · gpt-retry · /tmp/project ctx 0% · -- t/s
|
||||
⏵⏵ accesso completo attivo (shift+tab per cambiare)
|
||||
|
||||
@@ -3,7 +3,7 @@ source: tui/src/app/tests/realtime_requests.rs
|
||||
expression: "normalize_voice_snapshot_directory(&rendered, &app.config.cwd)"
|
||||
---
|
||||
|
||||
▄▄████▄▄ aKode v0.2.0
|
||||
▄▄████▄▄ aKode v0.3.1
|
||||
██▀▀██▀▀██ gpt-test · mock
|
||||
██▄▄██▄▄██ /tmp/project
|
||||
██▀████▀██
|
||||
|
||||
@@ -3,7 +3,7 @@ source: tui/src/app/tests/realtime_requests.rs
|
||||
expression: "normalize_voice_snapshot_directory(&rendered, &app.config.cwd)"
|
||||
---
|
||||
|
||||
▄▄████▄▄ aKode v0.2.0
|
||||
▄▄████▄▄ aKode v0.3.1
|
||||
██▀▀██▀▀██ gpt-test · mock
|
||||
██▄▄██▄▄██ /tmp/project
|
||||
██▀████▀██
|
||||
|
||||
@@ -14,7 +14,7 @@ Restored owner:
|
||||
|
||||
127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s
|
||||
|
||||
▄▄████▄▄ aKode v0.2.0
|
||||
▄▄████▄▄ aKode v0.3.1
|
||||
██▀▀██▀▀██ gpt-test · mock
|
||||
██▄▄██▄▄██ /tmp/project
|
||||
██▀████▀██
|
||||
|
||||
@@ -3,7 +3,7 @@ source: tui/src/app/tests/realtime_requests.rs
|
||||
expression: "normalize_voice_snapshot_directory(&rendered, &app.config.cwd)"
|
||||
---
|
||||
|
||||
▄▄████▄▄ aKode v0.2.0
|
||||
▄▄████▄▄ aKode v0.3.1
|
||||
██▀▀██▀▀██ gpt-test · mock
|
||||
██▄▄██▄▄██ /tmp/project
|
||||
██▀████▀██
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source: tui/src/app/tests/new_session_tests.rs
|
||||
expression: "normalize_snapshot_paths(render_bottom_popup(&app.chat_widget, 80))"
|
||||
---
|
||||
▄▄████▄▄ aKode v0.2.0
|
||||
▄▄████▄▄ aKode v0.3.1
|
||||
██▀▀██▀▀██ loading · mock
|
||||
██▄▄██▄▄██ /tmp/project
|
||||
██▀████▀██
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: "normalize_snapshot_paths(normalize_agent_center_snapshot(snapshots.
|
||||
---
|
||||
80 columns
|
||||
|
||||
▄▄████▄▄ aKode v0.2.0
|
||||
▄▄████▄▄ aKode v0.3.1
|
||||
██▀▀██▀▀██ gpt-test · mock
|
||||
██▄▄██▄▄██ /tmp/project
|
||||
██▀████▀██
|
||||
@@ -26,7 +26,7 @@ expression: "normalize_snapshot_paths(normalize_agent_center_snapshot(snapshots.
|
||||
|
||||
32 columns
|
||||
|
||||
▄▄████▄▄ aKode v0.2.0
|
||||
▄▄████▄▄ aKode v0.3.1
|
||||
██▀▀██▀▀██ gpt-test · mock
|
||||
██▄▄██▄▄██ /tmp/project
|
||||
██▀████▀██
|
||||
|
||||
@@ -1452,13 +1452,21 @@ impl ChatComposer {
|
||||
self.draft.textarea.vim_mode_indicator_span()
|
||||
}
|
||||
|
||||
fn mode_indicator_line(&self, show_cycle_hint: bool) -> Option<Line<'static>> {
|
||||
/// Right-side indicators of a status row. With a separate status row the collaboration
|
||||
/// mode is left out: it is shown at the left of the hint row instead.
|
||||
pub(super) fn mode_indicator_line(
|
||||
&self,
|
||||
show_cycle_hint: bool,
|
||||
include_collaboration_mode: bool,
|
||||
) -> Option<Line<'static>> {
|
||||
let mut spans: Vec<Span<'static>> = Vec::new();
|
||||
if let Some(vim_mode) = self.vim_mode_indicator_span() {
|
||||
spans.push(vim_mode);
|
||||
}
|
||||
if let Some(indicators) = status_line_right_indicator_line(
|
||||
self.footer.collaboration_mode_indicator,
|
||||
self.footer
|
||||
.collaboration_mode_indicator
|
||||
.filter(|_| include_collaboration_mode),
|
||||
self.footer.goal_status_indicator.as_ref(),
|
||||
self.footer.ide_context_active,
|
||||
show_cycle_hint,
|
||||
@@ -4669,20 +4677,20 @@ impl ChatComposer {
|
||||
self.render_status_surface(hint_rect, buf, options);
|
||||
} else {
|
||||
let footer_props = self.hint_footer_props(options);
|
||||
let show_cycle_hint = !self.has_separate_status(options)
|
||||
&& !footer_props.is_task_running
|
||||
let show_cycle_hint = !footer_props.is_task_running
|
||||
&& self.footer.collaboration_mode_indicator.is_some();
|
||||
let show_shortcuts_hint =
|
||||
footer_props.mode == FooterMode::ComposerEmpty && !self.is_in_paste_burst();
|
||||
let show_queue_hint = footer_props.mode == FooterMode::ComposerHasDraft
|
||||
&& footer_props.is_task_running;
|
||||
let status_line_active = uses_passive_footer_status_layout(&footer_props);
|
||||
let left_mode_indicator =
|
||||
if status_line_active || self.has_separate_status(options) {
|
||||
None
|
||||
} else {
|
||||
self.footer.collaboration_mode_indicator
|
||||
};
|
||||
// The mode goes at the left of the hint row (as in Claude Code), unless the
|
||||
// shared status row owns this line.
|
||||
let left_mode_indicator = if status_line_active {
|
||||
None
|
||||
} else {
|
||||
self.footer.collaboration_mode_indicator
|
||||
};
|
||||
let active_footer_hint_override = self.footer.hint_override.as_ref();
|
||||
let left_width = if self.footer.flash_visible() {
|
||||
self.footer
|
||||
@@ -4709,8 +4717,13 @@ impl ChatComposer {
|
||||
} else if self.has_separate_status(options) {
|
||||
None
|
||||
} else if status_line_active {
|
||||
let full = self.mode_indicator_line(show_cycle_hint);
|
||||
let compact = self.mode_indicator_line(/*show_cycle_hint*/ false);
|
||||
let full = self.mode_indicator_line(
|
||||
show_cycle_hint,
|
||||
/*include_collaboration_mode*/ true,
|
||||
);
|
||||
let compact = self.mode_indicator_line(
|
||||
/*show_cycle_hint*/ false, /*include_collaboration_mode*/ true,
|
||||
);
|
||||
let full_width = full.as_ref().map(|l| l.width() as u16).unwrap_or(0);
|
||||
if can_show_left_with_context(hint_rect, left_width, full_width) {
|
||||
full
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
source: tui/src/bottom_pane/chat_composer/status_surface_tests.rs
|
||||
expression: separate
|
||||
---
|
||||
16 | Ready PR 12345
|
||||
15 | Ready
|
||||
15 | PR 12345
|
||||
16 | Ready PR 12345
|
||||
25 | Ready PR 12345
|
||||
@@ -6,5 +6,5 @@ expression: shared
|
||||
15 | Ready
|
||||
15 | PR 12345
|
||||
16 | Ready PR 12345
|
||||
25 | Ready
|
||||
25 | PR 12345 Plan mode
|
||||
25 | R…
|
||||
25 | P… ⏸ plan mode attivo
|
||||
|
||||
@@ -13,5 +13,5 @@ expression: wide
|
||||
|
||||
› Ask aKode
|
||||
|
||||
MODEL · ~/project · Context 20% used Plan mode (⇧tab to cycle)
|
||||
? for shortcuts
|
||||
MODEL · ~/project · Context 20% used
|
||||
⏸ plan mode attivo (shift+tab per cambiare) · ? for shortcuts
|
||||
|
||||
@@ -13,8 +13,8 @@ expression: "states.join(\"\\n---\\n\")"
|
||||
|
||||
› Ask aKode
|
||||
|
||||
MODEL · ~/project · Context 20% used Plan mode
|
||||
? for shortcuts
|
||||
MODEL · ~/project · Context 20% used
|
||||
⏸ plan mode attivo (shift+tab per cambiare) · ? for shortcuts
|
||||
---
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ expression: "states.join(\"\\n---\\n\")"
|
||||
|
||||
› Ask aKode
|
||||
|
||||
MODEL · ~/project · Context 20% used Plan mode
|
||||
MODEL · ~/project · Context 20% used
|
||||
Copied selection
|
||||
---
|
||||
|
||||
@@ -41,7 +41,7 @@ expression: "states.join(\"\\n---\\n\")"
|
||||
|
||||
› Ask aKode
|
||||
|
||||
MODEL · ~/project · Context 20% used Plan mode
|
||||
MODEL · ~/project · Context 20% used
|
||||
Ctrl+X waiting for chord
|
||||
---
|
||||
|
||||
@@ -55,5 +55,5 @@ expression: "states.join(\"\\n---\\n\")"
|
||||
|
||||
› Continue the task
|
||||
|
||||
MODEL · ~/project · Context 20% used Plan mode
|
||||
tab to queue message
|
||||
MODEL · ~/project · Context 20% used
|
||||
⏸ plan mode attivo · tab to queue message
|
||||
|
||||
@@ -133,7 +133,10 @@ impl ChatComposer {
|
||||
{
|
||||
None
|
||||
} else {
|
||||
let full = self.mode_indicator_line(show_cycle_hint);
|
||||
// A separate status row leaves the mode to the hint row, unless a transcript
|
||||
// footer (search, activity) takes that row.
|
||||
let include_mode = !options.separate_status_line || options.footer.is_some();
|
||||
let full = self.mode_indicator_line(show_cycle_hint, include_mode);
|
||||
let full_fits = full.as_ref().is_none_or(|right| {
|
||||
let right_width = right.width() as u16;
|
||||
(!options.separate_status_line || right_width <= inset_footer_hint_area(area).width)
|
||||
@@ -142,7 +145,7 @@ impl ChatComposer {
|
||||
if full_fits {
|
||||
full
|
||||
} else {
|
||||
self.mode_indicator_line(/*show_cycle_hint*/ false)
|
||||
self.mode_indicator_line(/*show_cycle_hint*/ false, include_mode)
|
||||
}
|
||||
};
|
||||
let right_width = right
|
||||
|
||||
@@ -158,8 +158,10 @@ fn extension_layout_uses_the_width_left_by_the_mode_indicator_after_resize() {
|
||||
}
|
||||
frames.join("\n")
|
||||
});
|
||||
assert_eq!(shared, separate);
|
||||
// With a separate status row the mode moves to the hint row, so the status keeps the
|
||||
// whole width.
|
||||
insta::assert_snapshot!(shared);
|
||||
insta::assert_snapshot!("extension_layout_separate_status_row", separate);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -391,7 +393,7 @@ fn fullscreen_plan_indicator_keeps_the_cycle_hint_when_it_fits() {
|
||||
composer.set_collaboration_mode_indicator(Some(CollaborationModeIndicator::Plan));
|
||||
let (wide, _) = render(&composer, /*width*/ 100, /*footer*/ None);
|
||||
assert!(
|
||||
wide.contains("Plan mode (⇧tab to cycle)"),
|
||||
wide.contains("plan mode attivo (shift+tab per cambiare)"),
|
||||
"idle fullscreen must explain how to leave Plan mode: {wide}"
|
||||
);
|
||||
insta::assert_snapshot!("fullscreen_plan_cycle_hint", wide);
|
||||
@@ -402,13 +404,13 @@ fn fullscreen_plan_indicator_keeps_the_cycle_hint_when_it_fits() {
|
||||
composer.set_active_agent_label(Some("reviewer".to_string()));
|
||||
let (narrow, _) = render(&composer, /*width*/ 37, /*footer*/ None);
|
||||
let row = narrow.lines().rev().nth(1).expect("persistent status row");
|
||||
insta::assert_snapshot!(strip_osc8(row).trim(), @"project · PR #42 · rev… Plan mode");
|
||||
insta::assert_snapshot!(strip_osc8(row).trim(), @"project · PR #42 · reviewer");
|
||||
composer.set_active_agent_label(/*active_agent_label*/ None);
|
||||
|
||||
composer.set_task_running(/*running*/ true);
|
||||
let (running, _) = render(&composer, /*width*/ 100, /*footer*/ None);
|
||||
assert!(running.contains("Plan mode"), "{running}");
|
||||
assert!(!running.contains("⇧tab"), "{running}");
|
||||
assert!(running.contains("plan mode attivo"), "{running}");
|
||||
assert!(!running.contains("shift+tab"), "{running}");
|
||||
composer.set_task_running(/*running*/ false);
|
||||
|
||||
let footer = TranscriptFooter {
|
||||
@@ -417,34 +419,34 @@ fn fullscreen_plan_indicator_keeps_the_cycle_hint_when_it_fits() {
|
||||
is_interactive: true,
|
||||
};
|
||||
let (search, _) = render(&composer, /*width*/ 100, Some(&footer));
|
||||
assert!(search.contains("Plan mode"), "{search}");
|
||||
assert!(!search.contains("⇧tab"), "{search}");
|
||||
assert!(search.contains("plan mode attivo"), "{search}");
|
||||
assert!(!search.contains("shift+tab"), "{search}");
|
||||
|
||||
// Configured items such as git-branch can have no value outside a repository.
|
||||
composer.set_status_line(/*status_line*/ None);
|
||||
let (empty_narrow, _) = render(&composer, /*width*/ 24, /*footer*/ None);
|
||||
assert_eq!(
|
||||
empty_narrow.lines().rev().nth(1).map(str::trim),
|
||||
Some("Plan mode")
|
||||
assert!(
|
||||
empty_narrow.lines().any(|line| line.contains("plan mode attivo")),
|
||||
"{empty_narrow}"
|
||||
);
|
||||
let (empty_wide, _) = render(&composer, /*width*/ 100, /*footer*/ None);
|
||||
assert!(
|
||||
empty_wide.contains("Plan mode (⇧tab to cycle)"),
|
||||
empty_wide.contains("plan mode attivo (shift+tab per cambiare)"),
|
||||
"{empty_wide}"
|
||||
);
|
||||
|
||||
composer.set_input_enabled(/*enabled*/ false, /*placeholder*/ None);
|
||||
let (read_only, _) = render(&composer, /*width*/ 100, /*footer*/ None);
|
||||
assert_eq!(
|
||||
read_only.lines().rev().nth(1).map(str::trim),
|
||||
Some("Plan mode")
|
||||
assert!(
|
||||
read_only.lines().any(|line| line.contains("plan mode attivo")),
|
||||
"{read_only}"
|
||||
);
|
||||
composer.set_input_enabled(/*enabled*/ true, /*placeholder*/ None);
|
||||
composer.set_parent_owned_thread();
|
||||
let (parent_owned, _) = render(&composer, /*width*/ 100, /*footer*/ None);
|
||||
assert_eq!(
|
||||
parent_owned.lines().rev().nth(1).map(str::trim),
|
||||
Some("Plan mode")
|
||||
assert!(
|
||||
parent_owned.lines().any(|line| line.contains("plan mode attivo")),
|
||||
"{parent_owned}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -620,10 +622,11 @@ fn status_survives_hints_feedback_and_queue() {
|
||||
composer.popups.active = popup;
|
||||
let (text, _) = render(&composer, /*width*/ 64, /*footer*/ None);
|
||||
assert!(text.contains("MODEL · ~/project · Context 20% used"));
|
||||
assert_eq!(text.matches("Plan mode").count(), 1);
|
||||
assert!(text.matches("plan mode attivo").count() <= 1);
|
||||
}
|
||||
for state in &states {
|
||||
assert_eq!(state.matches("Plan mode").count(), 1);
|
||||
// The mode shares the hint row: hints that replace it (overlay, flash) hide it.
|
||||
assert!(state.matches("plan mode attivo").count() <= 1);
|
||||
assert!(state.contains("MODEL · ~/project · Context 20% used"));
|
||||
}
|
||||
insta::assert_snapshot!("persistent_status_and_messages", states.join("\n---\n"));
|
||||
|
||||
@@ -93,6 +93,8 @@ pub(crate) struct FooterProps {
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub(crate) enum CollaborationModeIndicator {
|
||||
Plan,
|
||||
/// Default collaboration mode with full access: no sandbox and no approvals.
|
||||
FullAccess,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
@@ -146,28 +148,30 @@ impl FooterKeyHints {
|
||||
}
|
||||
|
||||
impl CollaborationModeIndicator {
|
||||
fn label(self, show_cycle_hint: bool) -> String {
|
||||
let suffix = if show_cycle_hint {
|
||||
format!(
|
||||
" ({} to cycle)",
|
||||
key_hint::shift(KeyCode::Tab).display_label()
|
||||
)
|
||||
} else {
|
||||
String::new()
|
||||
/// The text shown at the left of the hint row, as Claude Code does. `compact` keeps only
|
||||
/// the mode name; the symbols are text presentation characters, not emoji.
|
||||
fn label(self, show_cycle_hint: bool, compact: bool) -> String {
|
||||
let name = match (self, compact) {
|
||||
(CollaborationModeIndicator::Plan, true) => "plan",
|
||||
(CollaborationModeIndicator::Plan, false) => "\u{23F8} plan mode attivo",
|
||||
(CollaborationModeIndicator::FullAccess, true) => "accesso completo",
|
||||
(CollaborationModeIndicator::FullAccess, false) => {
|
||||
"\u{23F5}\u{23F5} accesso completo attivo"
|
||||
}
|
||||
};
|
||||
match self {
|
||||
CollaborationModeIndicator::Plan => format!("Plan mode{suffix}"),
|
||||
if show_cycle_hint && !compact {
|
||||
format!("{name} (shift+tab per cambiare)")
|
||||
} else {
|
||||
name.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
fn styled_line(self, show_cycle_hint: bool) -> Line<'static> {
|
||||
let mut line = Line::from(self.label(/*show_cycle_hint*/ false).magenta());
|
||||
if show_cycle_hint {
|
||||
line.push_span(" (".set_style(secondary_text_style()));
|
||||
line.extend(key_hint::shift(KeyCode::Tab).spans());
|
||||
line.push_span(" to cycle)".set_style(secondary_text_style()));
|
||||
}
|
||||
line
|
||||
fn styled_line(self, show_cycle_hint: bool, compact: bool) -> Line<'static> {
|
||||
let label = self.label(show_cycle_hint, compact);
|
||||
Line::from(match self {
|
||||
CollaborationModeIndicator::Plan => label.cyan(),
|
||||
CollaborationModeIndicator::FullAccess => label.red(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,6 +313,8 @@ enum SummaryHintKind {
|
||||
struct LeftSideState {
|
||||
hint: SummaryHintKind,
|
||||
show_cycle_hint: bool,
|
||||
/// Only the mode name (`plan`, `accesso completo`).
|
||||
compact: bool,
|
||||
}
|
||||
|
||||
fn left_side_line(
|
||||
@@ -317,6 +323,16 @@ fn left_side_line(
|
||||
key_hints: FooterKeyHints,
|
||||
) -> Line<'static> {
|
||||
let mut line = Line::from("");
|
||||
if let Some(collaboration_mode_indicator) = collaboration_mode_indicator {
|
||||
line.extend(
|
||||
collaboration_mode_indicator
|
||||
.styled_line(state.show_cycle_hint, state.compact)
|
||||
.spans,
|
||||
);
|
||||
if !matches!(state.hint, SummaryHintKind::None) {
|
||||
line.push_span(" · ".set_style(secondary_text_style()));
|
||||
}
|
||||
}
|
||||
match state.hint {
|
||||
SummaryHintKind::None => {}
|
||||
SummaryHintKind::Shortcuts => {
|
||||
@@ -346,17 +362,6 @@ fn left_side_line(
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(collaboration_mode_indicator) = collaboration_mode_indicator {
|
||||
if !matches!(state.hint, SummaryHintKind::None) {
|
||||
line.push_span(" · ".set_style(secondary_text_style()));
|
||||
}
|
||||
line.extend(
|
||||
collaboration_mode_indicator
|
||||
.styled_line(state.show_cycle_hint)
|
||||
.spans,
|
||||
);
|
||||
}
|
||||
|
||||
line
|
||||
}
|
||||
|
||||
@@ -387,6 +392,7 @@ pub(crate) fn single_line_footer_layout(
|
||||
let default_state = LeftSideState {
|
||||
hint: hint_kind,
|
||||
show_cycle_hint,
|
||||
compact: false,
|
||||
};
|
||||
let default_line = left_side_line(collaboration_mode_indicator, default_state, key_hints);
|
||||
let default_width = default_line.width() as u16;
|
||||
@@ -427,10 +433,12 @@ pub(crate) fn single_line_footer_layout(
|
||||
LeftSideState {
|
||||
hint: SummaryHintKind::QueueMessage,
|
||||
show_cycle_hint: false,
|
||||
compact: false,
|
||||
},
|
||||
LeftSideState {
|
||||
hint: SummaryHintKind::QueueShort,
|
||||
show_cycle_hint: false,
|
||||
compact: false,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -469,83 +477,54 @@ pub(crate) fn single_line_footer_layout(
|
||||
}
|
||||
}
|
||||
} else if collaboration_mode_indicator.is_some() {
|
||||
if show_cycle_hint {
|
||||
// First fallback: drop shortcut hint but keep the cycle
|
||||
// hint on the mode label if it can fit.
|
||||
let cycle_state = LeftSideState {
|
||||
// Narrow rows drop the "(shift+tab per cambiare)" first, then the other hints, then
|
||||
// shorten the mode to its name.
|
||||
let states = [
|
||||
LeftSideState {
|
||||
hint: hint_kind,
|
||||
show_cycle_hint: false,
|
||||
compact: false,
|
||||
},
|
||||
LeftSideState {
|
||||
hint: SummaryHintKind::None,
|
||||
show_cycle_hint: true,
|
||||
};
|
||||
let cycle_width = state_width(cycle_state);
|
||||
if cycle_width > 0 && can_show_left_with_context(area, cycle_width, context_width) {
|
||||
return (SummaryLeft::Custom(state_line(cycle_state)), true);
|
||||
}
|
||||
if cycle_width > 0 && left_fits(area, cycle_width) {
|
||||
return (SummaryLeft::Custom(state_line(cycle_state)), false);
|
||||
show_cycle_hint: false,
|
||||
compact: false,
|
||||
},
|
||||
LeftSideState {
|
||||
hint: SummaryHintKind::None,
|
||||
show_cycle_hint: false,
|
||||
compact: true,
|
||||
},
|
||||
];
|
||||
if !context_requires_cycle_hint {
|
||||
for state in states {
|
||||
let width = state_width(state);
|
||||
if width > 0 && can_show_left_with_context(area, width, context_width) {
|
||||
return (SummaryLeft::Custom(state_line(state)), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Next fallback: mode label only. If the cycle hint is applicable but
|
||||
// cannot fit, we also suppress context so the right side does not
|
||||
// outlive "(shift+tab to cycle)" on the left.
|
||||
let mode_only_state = LeftSideState {
|
||||
hint: SummaryHintKind::None,
|
||||
show_cycle_hint: false,
|
||||
};
|
||||
let mode_only_width = state_width(mode_only_state);
|
||||
if !context_requires_cycle_hint
|
||||
&& mode_only_width > 0
|
||||
&& can_show_left_with_context(area, mode_only_width, context_width)
|
||||
{
|
||||
return (
|
||||
SummaryLeft::Custom(state_line(mode_only_state)),
|
||||
true, // show_context
|
||||
);
|
||||
}
|
||||
if mode_only_width > 0 && left_fits(area, mode_only_width) {
|
||||
return (
|
||||
SummaryLeft::Custom(state_line(mode_only_state)),
|
||||
false, // show_context
|
||||
);
|
||||
for state in states {
|
||||
let width = state_width(state);
|
||||
if width > 0 && left_fits(area, width) {
|
||||
return (SummaryLeft::Custom(state_line(state)), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Final fallback: if queue variants (or other earlier states) could not fit
|
||||
// at all, drop every hint and try to show just the mode label.
|
||||
// Final fallback: if queue variants could not fit at all, drop every hint and try to
|
||||
// show just the mode name.
|
||||
if let Some(collaboration_mode_indicator) = collaboration_mode_indicator {
|
||||
let mode_only_state = LeftSideState {
|
||||
hint: SummaryHintKind::None,
|
||||
show_cycle_hint: false,
|
||||
};
|
||||
// Compute the width without going through `state_line` so we do not
|
||||
// depend on `default_state` (which may still be a queue variant).
|
||||
let mode_only_width = left_side_line(
|
||||
Some(collaboration_mode_indicator),
|
||||
mode_only_state,
|
||||
key_hints,
|
||||
)
|
||||
.width() as u16;
|
||||
if !context_requires_cycle_hint
|
||||
&& can_show_left_with_context(area, mode_only_width, context_width)
|
||||
{
|
||||
return (
|
||||
SummaryLeft::Custom(left_side_line(
|
||||
Some(collaboration_mode_indicator),
|
||||
mode_only_state,
|
||||
key_hints,
|
||||
)),
|
||||
true, // show_context
|
||||
);
|
||||
}
|
||||
if left_fits(area, mode_only_width) {
|
||||
return (
|
||||
SummaryLeft::Custom(left_side_line(
|
||||
Some(collaboration_mode_indicator),
|
||||
mode_only_state,
|
||||
key_hints,
|
||||
)),
|
||||
false, // show_context
|
||||
);
|
||||
for compact in [false, true] {
|
||||
let state = LeftSideState {
|
||||
hint: SummaryHintKind::None,
|
||||
show_cycle_hint: false,
|
||||
compact,
|
||||
};
|
||||
let line = left_side_line(Some(collaboration_mode_indicator), state, key_hints);
|
||||
if left_fits(area, line.width() as u16) {
|
||||
return (SummaryLeft::Custom(line), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,7 +535,7 @@ pub(crate) fn mode_indicator_line(
|
||||
indicator: Option<CollaborationModeIndicator>,
|
||||
show_cycle_hint: bool,
|
||||
) -> Option<Line<'static>> {
|
||||
indicator.map(|indicator| indicator.styled_line(show_cycle_hint))
|
||||
indicator.map(|indicator| indicator.styled_line(show_cycle_hint, /*compact*/ false))
|
||||
}
|
||||
|
||||
pub(crate) fn goal_status_indicator_line(
|
||||
@@ -784,6 +763,7 @@ fn footer_from_props_lines(
|
||||
SummaryHintKind::None
|
||||
},
|
||||
show_cycle_hint,
|
||||
compact: false,
|
||||
};
|
||||
vec![left_side_line(
|
||||
collaboration_mode_indicator,
|
||||
@@ -803,6 +783,7 @@ fn footer_from_props_lines(
|
||||
SummaryHintKind::None
|
||||
},
|
||||
show_cycle_hint,
|
||||
compact: false,
|
||||
};
|
||||
vec![left_side_line(
|
||||
collaboration_mode_indicator,
|
||||
@@ -983,6 +964,7 @@ mod tests {
|
||||
use crate::line_truncation::truncate_line_with_ellipsis_if_overflow;
|
||||
use crate::test_backend::VT100Backend;
|
||||
use insta::assert_snapshot;
|
||||
use ratatui::style::Color;
|
||||
use pretty_assertions::assert_eq;
|
||||
use ratatui::Terminal;
|
||||
use ratatui::backend::Backend;
|
||||
@@ -1704,6 +1686,64 @@ mod tests {
|
||||
snapshot_footer("footer_status_line_with_active_agent_label", props);
|
||||
}
|
||||
|
||||
fn idle_props() -> FooterProps {
|
||||
FooterProps {
|
||||
mode: FooterMode::ComposerEmpty,
|
||||
esc_backtrack_hint: false,
|
||||
is_task_running: false,
|
||||
queue_submissions: false,
|
||||
collaboration_modes_enabled: true,
|
||||
is_wsl: false,
|
||||
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
||||
status_line_value: None,
|
||||
status_line_enabled: false,
|
||||
key_hints: FooterKeyHints::default_bindings(),
|
||||
active_agent_label: None,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mode_cycle_indicator_snapshots() {
|
||||
let props = idle_props();
|
||||
for (name, indicator) in [
|
||||
("plan", CollaborationModeIndicator::Plan),
|
||||
("accesso_completo", CollaborationModeIndicator::FullAccess),
|
||||
] {
|
||||
for width in [120, 80, 40, 24] {
|
||||
snapshot_footer_with_mode_indicator(
|
||||
&format!("footer_mode_cycle_{name}_{width}"),
|
||||
width,
|
||||
&props,
|
||||
Some(indicator),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mode_cycle_indicator_colors_and_symbols() {
|
||||
let plan = CollaborationModeIndicator::Plan.styled_line(true, false);
|
||||
assert_eq!(
|
||||
plan.to_string(),
|
||||
"\u{23F8} plan mode attivo (shift+tab per cambiare)"
|
||||
);
|
||||
assert!(plan.spans.iter().all(|span| span.style.fg == Some(Color::Cyan)));
|
||||
let full = CollaborationModeIndicator::FullAccess.styled_line(true, false);
|
||||
assert_eq!(
|
||||
full.to_string(),
|
||||
"\u{23F5}\u{23F5} accesso completo attivo (shift+tab per cambiare)"
|
||||
);
|
||||
assert!(full.spans.iter().all(|span| span.style.fg == Some(Color::Red)));
|
||||
// Text presentation: no emoji variation selector.
|
||||
assert!(!full.to_string().contains('\u{FE0F}'));
|
||||
assert_eq!(
|
||||
CollaborationModeIndicator::FullAccess
|
||||
.styled_line(true, true)
|
||||
.to_string(),
|
||||
"accesso completo"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn footer_status_line_truncates_to_keep_mode_indicator() {
|
||||
let props = FooterProps {
|
||||
@@ -1731,11 +1771,11 @@ mod tests {
|
||||
);
|
||||
let collapsed = screen.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
assert!(
|
||||
collapsed.contains("Plan mode"),
|
||||
collapsed.contains("plan mode attivo"),
|
||||
"mode indicator should remain visible"
|
||||
);
|
||||
assert!(
|
||||
!collapsed.contains("⇧tab to cycle"),
|
||||
!collapsed.contains("shift+tab per cambiare"),
|
||||
"compact mode indicator should be used when space is tight"
|
||||
);
|
||||
assert!(
|
||||
|
||||
@@ -10,4 +10,4 @@ expression: terminal.backend()
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" ? for shortcuts · Plan mode (⇧tab to cycle) 100% context left "
|
||||
" ⏸ plan mode attivo (shift+tab per cambiare) · ? for shortcuts 100% context left "
|
||||
|
||||
@@ -10,4 +10,4 @@ expression: terminal.backend()
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" Plan mode (⇧tab to cycle) 100% context left "
|
||||
" ⏸ plan mode attivo · ? for shortcuts "
|
||||
|
||||
@@ -10,4 +10,4 @@ expression: terminal.backend()
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" Plan mode (⇧tab to cycle) "
|
||||
" ⏸ plan mode attivo · ? for shortcuts "
|
||||
|
||||
@@ -10,4 +10,4 @@ expression: terminal.backend()
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" Plan mode "
|
||||
" ⏸ plan mode attivo "
|
||||
|
||||
@@ -10,4 +10,4 @@ expression: terminal.backend()
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" tab to queue message · Plan mode 98% context left "
|
||||
" ⏸ plan mode attivo · tab to queue message 98% context left "
|
||||
|
||||
@@ -10,4 +10,4 @@ expression: terminal.backend()
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" tab to queue message · Plan mode "
|
||||
" ⏸ plan mode attivo · tab to queue "
|
||||
|
||||
@@ -10,4 +10,4 @@ expression: terminal.backend()
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" Plan mode "
|
||||
" ⏸ plan mode attivo"
|
||||
|
||||
@@ -10,4 +10,4 @@ expression: terminal.backend()
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" tab to queue · Plan mode 98% context left "
|
||||
" ⏸ plan mode attivo · tab to queue message "
|
||||
|
||||
@@ -10,4 +10,4 @@ expression: terminal.backend()
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" tab to queue · Plan mode "
|
||||
" ⏸ plan mode attivo "
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" ⏵⏵ accesso completo attivo (shift+tab per cambiare) · ? for shortcuts 100% context left "
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" accesso completo "
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" ⏵⏵ accesso completo attivo "
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" ⏵⏵ accesso completo attivo · ? for shortcuts "
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" ⏸ plan mode attivo (shift+tab per cambiare) · ? for shortcuts 100% context left "
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" ⏸ plan mode attivo "
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" ⏸ plan mode attivo · ? for shortcuts "
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" ⏸ plan mode attivo · ? for shortcuts "
|
||||
@@ -2,4 +2,4 @@
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" Plan mode (⇧tab to cycle) "
|
||||
" ⏸ plan mode attivo · ? for shortcuts "
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" ? for shortcuts · Plan mode 100% context left "
|
||||
" ⏸ plan mode attivo · ? for shortcuts 100% context left "
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" ? for shortcuts · Plan mode (⇧tab to cycle) 100% context left "
|
||||
" ⏸ plan mode attivo (shift+tab per cambiare) · ? for shortcuts 100% context left "
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" ? for shortcuts · Plan mode (⇧tab to cycle) 50% context left "
|
||||
" ⏸ plan mode attivo (shift+tab per cambiare) · ? for shortcuts 50% context left "
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" Plan mode (⇧tab to cycle) · IDE context "
|
||||
" ⏸ plan mode attivo (shift+tab per cambiare) · IDE context "
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" Plan mode (⇧tab to cycle) "
|
||||
" ⏸ plan mode attivo (shift+tab per cambiare) "
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" Status line content that … Plan mode "
|
||||
" Status line cont… ⏸ plan mode attivo "
|
||||
|
||||
@@ -671,6 +671,8 @@ pub(crate) struct ChatWidget {
|
||||
/// Ignore a held key after it dismisses the preset submenu.
|
||||
quick_dial_menu_key_guard: Option<crate::activation_key_guard::ActivationKeyGuard>,
|
||||
permission_shortcut_pending: bool,
|
||||
/// Permissions in use before Shift+Tab entered full access, restored when it leaves it.
|
||||
mode_cycle_restore: Option<PermissionProfileSelection>,
|
||||
// Pending notification to show when unfocused on next Draw
|
||||
pub(crate) pending_notification: Option<Notification>,
|
||||
/// When `Some`, the user has pressed a quit shortcut and the second press
|
||||
|
||||
@@ -225,6 +225,7 @@ impl ChatWidget {
|
||||
safety_buffering_source: UserMessageSource::Prompt,
|
||||
chat_keymap,
|
||||
permission_shortcut_pending: false,
|
||||
mode_cycle_restore: None,
|
||||
show_welcome_banner: is_first_run,
|
||||
startup_tooltip_override,
|
||||
suppress_session_configured_redraw: false,
|
||||
|
||||
@@ -277,8 +277,11 @@ impl ChatWidget {
|
||||
options.image_previews = self.composer_images.as_ref();
|
||||
options.warning_count = self.warning_display_state.count;
|
||||
options.textarea_right_reserve = right_reserve;
|
||||
// Plan and full access get their own row under the composer, at the left, as in
|
||||
// Claude Code, so the status line moves to a row of its own.
|
||||
options.separate_status_line = options.command_popup_placement
|
||||
!= crate::bottom_pane::CommandPopupPlacement::AboveComposer;
|
||||
!= crate::bottom_pane::CommandPopupPlacement::AboveComposer
|
||||
|| self.collaboration_mode_indicator().is_some();
|
||||
let bottom_pane = self.bottom_pane.backdrop_with_options(options);
|
||||
let above_composer = if self.quick_dial_menu && !options.floating_shortcuts {
|
||||
RenderableItem::Owned(Box::new(self.quick_dial_hud()))
|
||||
|
||||
@@ -513,12 +513,15 @@ impl ChatWidget {
|
||||
.then_some(active_mode.display_name())
|
||||
}
|
||||
|
||||
fn collaboration_mode_indicator(&self) -> Option<CollaborationModeIndicator> {
|
||||
pub(super) fn collaboration_mode_indicator(&self) -> Option<CollaborationModeIndicator> {
|
||||
if !self.collaboration_modes_enabled() {
|
||||
return None;
|
||||
}
|
||||
match self.active_mode_kind() {
|
||||
ModeKind::Plan => Some(CollaborationModeIndicator::Plan),
|
||||
ModeKind::Default if self.full_access_active() => {
|
||||
Some(CollaborationModeIndicator::FullAccess)
|
||||
}
|
||||
ModeKind::Default => None,
|
||||
}
|
||||
}
|
||||
@@ -576,18 +579,180 @@ impl ChatWidget {
|
||||
self.update_collaboration_mode_indicator();
|
||||
}
|
||||
|
||||
/// Cycle to the next collaboration mode variant (Plan -> Default -> Plan).
|
||||
/// Shift+Tab, as in Claude Code: Default -> Plan -> Accesso completo -> Default.
|
||||
///
|
||||
/// "Accesso completo" is the `/permissions` full-access preset in Default collaboration
|
||||
/// mode; it is skipped when requirements forbid it. Leaving it restores the permissions
|
||||
/// that were in use before it was entered.
|
||||
pub(super) fn cycle_collaboration_mode(&mut self) {
|
||||
if !self.collaboration_modes_enabled() {
|
||||
if !self.collaboration_modes_enabled() || self.permission_shortcut_pending {
|
||||
return;
|
||||
}
|
||||
|
||||
let plan = self.active_mode_kind() == ModeKind::Plan;
|
||||
if !plan && self.full_access_active() {
|
||||
let selection = self
|
||||
.mode_cycle_restore
|
||||
.take()
|
||||
.unwrap_or_else(Self::default_permission_selection);
|
||||
if self.send_mode_cycle_permissions(selection) {
|
||||
self.add_info_message("Modalità: default".to_string(), /*hint*/ None);
|
||||
}
|
||||
return;
|
||||
}
|
||||
let full_access = plan.then(|| self.full_access_selection()).flatten();
|
||||
if let Some(next_mask) = collaboration_modes::next_mask(
|
||||
self.model_catalog.as_ref(),
|
||||
self.active_collaboration_mask.as_ref(),
|
||||
) {
|
||||
self.set_collaboration_mask_from_user_action(next_mask);
|
||||
}
|
||||
if let Some(full_access) = full_access {
|
||||
let restore = self.current_permission_selection();
|
||||
if self.send_mode_cycle_permissions(full_access) {
|
||||
self.mode_cycle_restore = Some(restore);
|
||||
self.add_info_message(
|
||||
"Modalità: accesso completo \u{2014} nessuna approvazione richiesta".to_string(),
|
||||
/*hint*/ None,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
let notice = match self.active_mode_kind() {
|
||||
ModeKind::Plan => "Modalità: plan",
|
||||
ModeKind::Default => "Modalità: default",
|
||||
};
|
||||
self.add_info_message(notice.to_string(), /*hint*/ None);
|
||||
}
|
||||
|
||||
fn full_access_preset() -> Option<ApprovalPreset> {
|
||||
builtin_approval_presets()
|
||||
.into_iter()
|
||||
.find(|preset| preset.id == "full-access")
|
||||
}
|
||||
|
||||
/// The thread runs with the full-access preset (no sandbox, no approvals).
|
||||
pub(super) fn full_access_active(&self) -> bool {
|
||||
let Some(preset) = Self::full_access_preset() else {
|
||||
return false;
|
||||
};
|
||||
let current_approval =
|
||||
AskForApproval::from(self.config.permissions.approval_policy.value());
|
||||
match self.config.permissions.active_permission_profile() {
|
||||
Some(active) => {
|
||||
active.id == preset.active_permission_profile.id
|
||||
&& current_approval == AskForApproval::from(preset.approval)
|
||||
}
|
||||
None => Self::preset_matches_current(
|
||||
current_approval,
|
||||
self.config.permissions.permission_profile(),
|
||||
self.config.cwd.as_path(),
|
||||
&preset,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// The full-access selection of `/permissions`, when this thread may use it.
|
||||
fn full_access_selection(&self) -> Option<PermissionProfileSelection> {
|
||||
self.thread_id?;
|
||||
let preset = Self::full_access_preset()?;
|
||||
let approval = AskForApproval::from(preset.approval);
|
||||
let reviewer = ApprovalsReviewer::User;
|
||||
let locally_allowed = self
|
||||
.config
|
||||
.permissions
|
||||
.approval_policy
|
||||
.can_set(&approval.to_core())
|
||||
.is_ok()
|
||||
&& self
|
||||
.config
|
||||
.permissions
|
||||
.can_set_permission_profile(&preset.permission_profile)
|
||||
.is_ok();
|
||||
let server_allowed = self.permission_discovery.as_ref().is_none_or(|discovery| {
|
||||
discovery
|
||||
.disabled_reason(
|
||||
&preset.active_permission_profile.id,
|
||||
Some(approval),
|
||||
Some(reviewer.into()),
|
||||
)
|
||||
.is_none()
|
||||
});
|
||||
(locally_allowed && server_allowed).then(|| PermissionProfileSelection {
|
||||
profile_id: preset.active_permission_profile.id.clone(),
|
||||
approval_policy: Some(approval),
|
||||
approvals_reviewer: Some(reviewer),
|
||||
display_label: preset.label.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
/// The `/permissions` default: workspace sandbox, approval on request.
|
||||
fn default_permission_selection() -> PermissionProfileSelection {
|
||||
let preset = builtin_approval_presets()
|
||||
.into_iter()
|
||||
.find(|preset| preset.id == "auto");
|
||||
PermissionProfileSelection {
|
||||
profile_id: preset.as_ref().map_or_else(
|
||||
|| akode_protocol::models::BUILT_IN_PERMISSION_PROFILE_WORKSPACE.to_string(),
|
||||
|preset| preset.active_permission_profile.id.clone(),
|
||||
),
|
||||
approval_policy: Some(
|
||||
preset
|
||||
.as_ref()
|
||||
.map_or(AskForApproval::OnRequest, |preset| {
|
||||
AskForApproval::from(preset.approval)
|
||||
}),
|
||||
),
|
||||
approvals_reviewer: Some(ApprovalsReviewer::User),
|
||||
display_label: ASK_FOR_APPROVAL_LABEL.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The permissions in use now, as a selection that can be applied again.
|
||||
fn current_permission_selection(&self) -> PermissionProfileSelection {
|
||||
let approval = AskForApproval::from(self.config.permissions.approval_policy.value());
|
||||
let reviewer = self.config.approvals_reviewer;
|
||||
let active = self.config.permissions.active_permission_profile();
|
||||
let preset = builtin_approval_presets().into_iter().find(|preset| {
|
||||
active.as_ref().map_or_else(
|
||||
|| {
|
||||
Self::preset_matches_current(
|
||||
approval,
|
||||
self.config.permissions.permission_profile(),
|
||||
self.config.cwd.as_path(),
|
||||
preset,
|
||||
)
|
||||
},
|
||||
|active| active.id == preset.active_permission_profile.id,
|
||||
)
|
||||
});
|
||||
let Some(profile_id) = active
|
||||
.map(|active| active.id)
|
||||
.or_else(|| preset.as_ref().map(|p| p.active_permission_profile.id.clone()))
|
||||
else {
|
||||
return Self::default_permission_selection();
|
||||
};
|
||||
let display_label = match preset.as_ref().map(|preset| preset.id) {
|
||||
Some("auto") => ASK_FOR_APPROVAL_LABEL.to_string(),
|
||||
Some(_) => preset.as_ref().map_or_else(String::new, |p| p.label.to_string()),
|
||||
None => profile_id.clone(),
|
||||
};
|
||||
PermissionProfileSelection {
|
||||
profile_id,
|
||||
approval_policy: Some(approval),
|
||||
approvals_reviewer: Some(reviewer),
|
||||
display_label,
|
||||
}
|
||||
}
|
||||
|
||||
/// Applies a permission selection through the same path as the permission shortcuts.
|
||||
fn send_mode_cycle_permissions(&mut self, selection: PermissionProfileSelection) -> bool {
|
||||
let Some(thread_id) = self.thread_id else {
|
||||
return false;
|
||||
};
|
||||
self.permission_shortcut_pending = true;
|
||||
self.app_event_tx
|
||||
.send(AppEvent::ApplyPermissionShortcut { thread_id, selection });
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) fn set_collaboration_mask_from_user_action(&mut self, mask: CollaborationModeMask) {
|
||||
|
||||
@@ -6,4 +6,5 @@ expression: snapshot
|
||||
" "
|
||||
"› Ask aKode to do anything "
|
||||
" "
|
||||
" GPT-5.5 max Plan mode (⇧tab to cycle) "
|
||||
" GPT-5.5 max "
|
||||
" ⏸ plan mode attivo (shift+tab per cambiare) · ? for shortcuts "
|
||||
|
||||
@@ -6,4 +6,5 @@ expression: normalized_backend_snapshot(terminal.backend())
|
||||
" "
|
||||
"› Ask aKode to do anything "
|
||||
" "
|
||||
" gpt-5.2 medium Plan mode (⇧tab to cycle) "
|
||||
" gpt-5.2 medium "
|
||||
" ⏸ plan mode attivo (shift+tab per cambiare) · ? for shortcuts "
|
||||
|
||||
@@ -257,6 +257,8 @@ impl ChatWidget {
|
||||
/// warnings once, synchronizes shared cached state (such as git-branch
|
||||
/// lookup), then renders each surface from that shared snapshot.
|
||||
pub(crate) fn refresh_status_surfaces(&mut self) {
|
||||
// Permissions may have changed: full access has its own mode indicator.
|
||||
self.update_collaboration_mode_indicator();
|
||||
self.bottom_pane
|
||||
.set_luna_reserve_active(self.current_model() == LUNA_RESERVE_MODEL);
|
||||
let selections = self.status_surface_selections();
|
||||
|
||||
@@ -260,6 +260,8 @@ mod model_picker_tests;
|
||||
mod permission_picker_tests;
|
||||
#[path = "tests/permission_shortcuts_tests.rs"]
|
||||
mod permission_shortcuts_tests;
|
||||
#[path = "tests/mode_cycle_tests.rs"]
|
||||
mod mode_cycle_tests;
|
||||
mod permissions;
|
||||
mod plan_mode;
|
||||
#[path = "tests/plugin_catalog_tests.rs"]
|
||||
|
||||
110
akode-rs/tui/src/chatwidget/tests/mode_cycle_tests.rs
Normal file
110
akode-rs/tui/src/chatwidget/tests/mode_cycle_tests.rs
Normal file
@@ -0,0 +1,110 @@
|
||||
//! Shift+Tab cycles Default -> Plan -> Accesso completo -> Default, as in Claude Code.
|
||||
|
||||
use super::*;
|
||||
use crate::bottom_pane::CollaborationModeIndicator;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
fn full_access_id() -> String {
|
||||
builtin_approval_presets()
|
||||
.into_iter()
|
||||
.find(|preset| preset.id == "full-access")
|
||||
.expect("full-access preset")
|
||||
.active_permission_profile
|
||||
.id
|
||||
}
|
||||
|
||||
fn set_permissions(chat: &mut ChatWidget, profile: PermissionProfile, id: &str, approval: AskForApproval) {
|
||||
chat.config
|
||||
.permissions
|
||||
.set_permission_profile_from_session_snapshot(PermissionProfileSnapshot::active(
|
||||
profile,
|
||||
ActivePermissionProfile::new(id),
|
||||
))
|
||||
.expect("set profile");
|
||||
chat.set_approval_policy(approval);
|
||||
chat.config.approvals_reviewer = ApprovalsReviewer::User;
|
||||
}
|
||||
|
||||
fn shortcut_selections(rx: &mut tokio::sync::mpsc::UnboundedReceiver<AppEvent>) -> Vec<PermissionProfileSelection> {
|
||||
let mut selections = Vec::new();
|
||||
while let Ok(event) = rx.try_recv() {
|
||||
if let AppEvent::ApplyPermissionShortcut { selection, .. } = event {
|
||||
selections.push(selection);
|
||||
}
|
||||
}
|
||||
selections
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn shift_tab_cycles_plan_then_full_access_and_restores_the_previous_permissions() {
|
||||
let (mut chat, mut rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
let thread_id = ThreadId::new();
|
||||
chat.thread_id = Some(thread_id);
|
||||
chat.permission_discovery = Some(crate::permission_discovery::PermissionDiscovery::local(
|
||||
&chat.config,
|
||||
));
|
||||
// Not the default preset: the cycle must restore what was there, not a fixed choice.
|
||||
set_permissions(&mut chat, PermissionProfile::read_only(), ":read-only", AskForApproval::OnRequest);
|
||||
assert_eq!(chat.active_mode_kind(), ModeKind::Default);
|
||||
assert_eq!(chat.collaboration_mode_indicator(), None);
|
||||
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::BackTab, KeyModifiers::SHIFT));
|
||||
assert_eq!(chat.active_mode_kind(), ModeKind::Plan);
|
||||
assert_eq!(chat.collaboration_mode_indicator(), Some(CollaborationModeIndicator::Plan));
|
||||
assert!(shortcut_selections(&mut rx).is_empty(), "plan keeps the permissions");
|
||||
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::BackTab, KeyModifiers::SHIFT));
|
||||
assert_eq!(chat.active_mode_kind(), ModeKind::Default);
|
||||
let selections = shortcut_selections(&mut rx);
|
||||
assert_eq!(selections.len(), 1);
|
||||
assert_eq!(selections[0].profile_id, full_access_id());
|
||||
assert_eq!(selections[0].approval_policy, Some(AskForApproval::Never));
|
||||
assert_eq!(selections[0].approvals_reviewer, Some(ApprovalsReviewer::User));
|
||||
// The server applies it.
|
||||
set_permissions(&mut chat, PermissionProfile::Disabled, &full_access_id(), AskForApproval::Never);
|
||||
chat.complete_permission_shortcut(thread_id);
|
||||
assert_eq!(
|
||||
chat.collaboration_mode_indicator(),
|
||||
Some(CollaborationModeIndicator::FullAccess)
|
||||
);
|
||||
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::BackTab, KeyModifiers::SHIFT));
|
||||
assert_eq!(chat.active_mode_kind(), ModeKind::Default);
|
||||
let selections = shortcut_selections(&mut rx);
|
||||
assert_eq!(selections.len(), 1);
|
||||
assert_eq!(selections[0].profile_id, ":read-only");
|
||||
assert_eq!(selections[0].approval_policy, Some(AskForApproval::OnRequest));
|
||||
set_permissions(&mut chat, PermissionProfile::read_only(), ":read-only", AskForApproval::OnRequest);
|
||||
chat.complete_permission_shortcut(thread_id);
|
||||
assert_eq!(chat.collaboration_mode_indicator(), None);
|
||||
|
||||
// Back at the start: the next press is Plan again.
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::BackTab, KeyModifiers::SHIFT));
|
||||
assert_eq!(chat.active_mode_kind(), ModeKind::Plan);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn shift_tab_skips_full_access_when_requirements_forbid_it() {
|
||||
let (mut chat, mut rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.thread_id = Some(ThreadId::new());
|
||||
let mut discovery = crate::permission_discovery::PermissionDiscovery::local(&chat.config);
|
||||
let full = full_access_id();
|
||||
for profile in &mut discovery.profiles {
|
||||
if profile.id == full {
|
||||
profile.allowed = false;
|
||||
}
|
||||
}
|
||||
chat.permission_discovery = Some(discovery);
|
||||
set_permissions(
|
||||
&mut chat,
|
||||
PermissionProfile::workspace_write(),
|
||||
":workspace",
|
||||
AskForApproval::OnRequest,
|
||||
);
|
||||
chat.cycle_collaboration_mode();
|
||||
assert_eq!(chat.active_mode_kind(), ModeKind::Plan);
|
||||
chat.cycle_collaboration_mode();
|
||||
assert_eq!(chat.active_mode_kind(), ModeKind::Default);
|
||||
assert!(shortcut_selections(&mut rx).is_empty(), "full access is skipped");
|
||||
assert_eq!(chat.collaboration_mode_indicator(), None);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ source: tui/src/history_cell/tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
|
||||
▄▄████▄▄ aKode v0.2.0
|
||||
▄▄████▄▄ aKode v0.3.1
|
||||
██▀▀██▀▀██ gpt-5 · mock
|
||||
██▄▄██▄▄██ /tmp/project
|
||||
██▀████▀██
|
||||
|
||||
@@ -7,7 +7,7 @@ expression: rendered
|
||||
|
||||
Scegli i colori; potrai cambiarli con /theme.
|
||||
|
||||
1. Automatico │ ▄▄████▄▄ aKode v0.2.0
|
||||
1. Automatico │ ▄▄████▄▄ aKode v0.3.1
|
||||
2. Scuro │ ██▀▀██▀▀██ qwen3.6-35b-a3b
|
||||
3. Chiaro │ ██▄▄██▄▄██ ~/progetto
|
||||
4. Alto contrasto │ ██▀████▀██
|
||||
|
||||
@@ -7,7 +7,7 @@ expression: rendered
|
||||
|
||||
Scegli i colori; potrai cambiarli con /theme.
|
||||
|
||||
1. Automatico │ ▄▄████▄▄ aKode v0.2.0
|
||||
1. Automatico │ ▄▄████▄▄ aKode v0.3.1
|
||||
2. Scuro │ ██▀▀██▀▀██ qwen3.6-35b-a3b
|
||||
3. Chiaro │ ██▄▄██▄▄██ ~/progetto
|
||||
4. Alto contrasto │ ██▀████▀██
|
||||
|
||||
@@ -4,4 +4,5 @@ expression: "crate::chatwidget::tests::helpers::normalize_snapshot_paths(crate::
|
||||
---
|
||||
› Ask aKode to do anything
|
||||
|
||||
ctx 0% · -- t/s Plan mode
|
||||
ctx 0% · -- t/s
|
||||
⏸ plan mode attivo (shift+tab per camb
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex (reasoning none, summaries auto)
|
||||
Directory: [[workspace]]
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex (reasoning none, summaries auto)
|
||||
Directory: [[workspace]]
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex-max (reasoning none, summaries auto)
|
||||
Directory: [[workspace]]
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex-max (reasoning none, summaries auto)
|
||||
Directory: [[workspace]]
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex-max (reasoning high, summaries detailed)
|
||||
Directory: [[workspace]]
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Server: Local background server
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Server: unix:///tmp/codex-home/app-server-control/app-server-
|
||||
control.sock (v0.133.0)
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex-max (reasoning none, summaries auto)
|
||||
Directory: [[workspace]]
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex-max (reasoning none, summaries auto)
|
||||
Directory: [[workspace]]
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex-max (reasoning none, summaries auto)
|
||||
Directory: [[workspace]]
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex-max (reasoning none, summaries auto)
|
||||
Directory: [[workspace]]
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex-max (reasoning none, summaries auto)
|
||||
Directory: [[workspace]]
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: ガパガパガパガ
|
||||
パ-model (reasoning
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex-max (reasoning high, summaries
|
||||
detailed)
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex-max (reasoning medium, summaries auto)
|
||||
Directory: [[workspace]]
|
||||
|
||||
@@ -4,7 +4,7 @@ expression: sanitized
|
||||
---
|
||||
/status
|
||||
|
||||
>_ aKode (v0.2.0)
|
||||
>_ aKode (v0.3.1)
|
||||
|
||||
Model: gpt-5.1-codex-max (reasoning none, summaries auto)
|
||||
Directory: [[workspace]]
|
||||
|
||||
Reference in New Issue
Block a user