From 973acc59c954f671146ae4ebb0156dc113d903a1 Mon Sep 17 00:00:00 2001 From: "andrea.difonzo" Date: Thu, 12 Nov 2026 12:46:19 +0100 Subject: [PATCH] =?UTF-8?q?aKode=200.3.1:=20Shift+Tab=20a=20tre=20modalit?= =?UTF-8?q?=C3=A0=20e=20topic=20di=20Telegram=20pi=C3=B9=20puliti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- README.md | 5 + akode-rs/Cargo.lock | 316 ++++++++-------- akode-rs/Cargo.toml | 2 +- akode-rs/telegram/src/api.rs | 6 + akode-rs/telegram/src/bridge.rs | 348 ++++++++++++++++-- akode-rs/telegram/src/outbox.rs | 86 ++++- akode-rs/telegram/src/topics.rs | 72 +++- akode-rs/telegram/tests/bridge.rs | 214 ++++++++++- ..._menu__tests__daemon_cli_confirmation.snap | 2 +- ..._animation_tests__fresh_thread_header.snap | 4 +- ...s_previous_transcript_before_replay-2.snap | 2 +- ...tive_reconnect__restored_conversation.snap | 3 +- ...connect__rejected_startup_reconnected.snap | 1 + ...e_buffered_replay_reconciles_captions.snap | 2 +- ...__voice_completed_after_thread_switch.snap | 2 +- ...partial_completed_after_thread_switch.snap | 2 +- ...e_replay_reconciles_matching_captions.snap | 2 +- ...s_mention_usage_with_history_disabled.snap | 2 +- ...rame_tests__startup_tip_in_transcript.snap | 4 +- akode-rs/tui/src/bottom_pane/chat_composer.rs | 37 +- ..._extension_layout_separate_status_row.snap | 9 + ...ft_by_the_mode_indicator_after_resize.snap | 4 +- ...ce__tests__fullscreen_plan_cycle_hint.snap | 4 +- ...tests__persistent_status_and_messages.snap | 12 +- .../chat_composer/status_surface.rs | 7 +- .../chat_composer/status_surface_tests.rs | 41 ++- akode-rs/tui/src/bottom_pane/footer.rs | 244 +++++++----- ...ests__footer_collapse_plan_empty_full.snap | 2 +- ...se_plan_empty_mode_cycle_with_context.snap | 2 +- ...plan_empty_mode_cycle_without_context.snap | 2 +- ..._footer_collapse_plan_empty_mode_only.snap | 2 +- ...ests__footer_collapse_plan_queue_full.snap | 2 +- ...se_plan_queue_message_without_context.snap | 2 +- ..._footer_collapse_plan_queue_mode_only.snap | 2 +- ...ollapse_plan_queue_short_with_context.snap | 2 +- ...apse_plan_queue_short_without_context.snap | 2 +- ...ooter_mode_cycle_accesso_completo_120.snap | 5 + ...footer_mode_cycle_accesso_completo_24.snap | 5 + ...footer_mode_cycle_accesso_completo_40.snap | 5 + ...footer_mode_cycle_accesso_completo_80.snap | 5 + ...er__tests__footer_mode_cycle_plan_120.snap | 5 + ...ter__tests__footer_mode_cycle_plan_24.snap | 5 + ...ter__tests__footer_mode_cycle_plan_40.snap | 5 + ...ter__tests__footer_mode_cycle_plan_80.snap | 5 + ...r_mode_indicator_narrow_overlap_hides.snap | 2 +- ...ter_mode_indicator_running_hides_hint.snap | 2 +- ...er__tests__footer_mode_indicator_wide.snap | 2 +- ...er_status_line_disabled_context_right.snap | 2 +- ...ne_enabled_mode_and_ide_context_right.snap | 2 +- ...footer_status_line_enabled_mode_right.snap | 2 +- ...footer_status_line_truncated_with_gap.snap | 2 +- akode-rs/tui/src/chatwidget.rs | 2 + akode-rs/tui/src/chatwidget/constructor.rs | 1 + akode-rs/tui/src/chatwidget/rendering.rs | 5 +- akode-rs/tui/src/chatwidget/settings.rs | 173 ++++++++- ...s__reasoning_shortcut_max_plan_footer.snap | 3 +- ...model_with_reasoning_plan_mode_footer.snap | 3 +- .../tui/src/chatwidget/status_surfaces.rs | 2 + akode-rs/tui/src/chatwidget/tests.rs | 2 + .../src/chatwidget/tests/mode_cycle_tests.rs | 110 ++++++ ...nfo_availability_nux_tooltip_snapshot.snap | 2 +- ..._setup_wizard__tests__setup_theme_120.snap | 2 +- ...__setup_wizard__tests__setup_theme_80.snap | 2 +- ...ver_session__tests__resumed_plan_mode.snap | 3 +- ...ched_limits_hide_credits_without_flag.snap | 2 +- ..._snapshot_includes_credits_and_limits.snap | 2 +- ..._status_snapshot_includes_forked_from.snap | 2 +- ...tatus_snapshot_includes_monthly_limit.snap | 2 +- ...s_snapshot_includes_reasoning_details.snap | 2 +- ...atus_snapshot_local_background_server.snap | 2 +- ..._tests__status_snapshot_remote_server.snap | 2 +- ...hot_shows_active_user_defined_profile.snap | 2 +- ...napshot_shows_auto_review_permissions.snap | 2 +- ...snapshot_shows_missing_limits_message.snap | 2 +- ...s_snapshot_shows_stale_limits_message.snap | 2 +- ...shot_shows_unavailable_limits_message.snap | 2 +- ...tes_halfwidth_kana_in_narrow_terminal.snap | 2 +- ...snapshot_truncates_in_narrow_terminal.snap | 2 +- ...s_default_reasoning_when_config_empty.snap | 2 +- ..._limit_labels_for_unsupported_windows.snap | 2 +- 80 files changed, 1430 insertions(+), 417 deletions(-) create mode 100644 akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__extension_layout_separate_status_row.snap create mode 100644 akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_120.snap create mode 100644 akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_24.snap create mode 100644 akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_40.snap create mode 100644 akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_80.snap create mode 100644 akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_120.snap create mode 100644 akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_24.snap create mode 100644 akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_40.snap create mode 100644 akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_80.snap create mode 100644 akode-rs/tui/src/chatwidget/tests/mode_cycle_tests.rs diff --git a/README.md b/README.md index 4bb22fb3..7885b1ec 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,11 @@ Il token sta nell'archivio delle chiavi (`provider_api_key_store`, id `telegram- ## Novità +### 0.3.1 + +- Shift+Tab come in Claude Code: default, plan, accesso completo (senza approvazioni, saltato se i requisiti non lo permettono; uscendo tornano i permessi di prima). La modalità si vede sotto il riquadro di scrittura e in `/stato` su Telegram. +- Telegram: il topic di una sessione nasce al primo turno; le sessioni chiuse senza turni perdono il topic, le altre diventano «(chiusa)» con nuovi tentativi se il rinomina fallisce; i topic creati con «Nuova chat» chiedono a quale sessione appartengono (un comando riceve risposta nella chat principale e il topic sparisce); pulizia dei topic orfani all'avvio. + ### 0.3.0 - Controllo da Telegram: configurazione con **/telegram** (token, abbinamento della chat, attivazione). diff --git a/akode-rs/Cargo.lock b/akode-rs/Cargo.lock index 1b60a022..47c043fe 100644 --- a/akode-rs/Cargo.lock +++ b/akode-rs/Cargo.lock @@ -148,7 +148,7 @@ dependencies = [ [[package]] name = "akode-agent-extension" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-core", "akode-protocol", @@ -160,7 +160,7 @@ dependencies = [ [[package]] name = "akode-agent-graph-store" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "akode-state", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "akode-agent-message-board-client" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-extension-api", "akode-http-client", @@ -198,7 +198,7 @@ dependencies = [ [[package]] name = "akode-agent-message-board-extension" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-agent-message-board-client", "akode-config", @@ -217,7 +217,7 @@ dependencies = [ [[package]] name = "akode-agent-message-board-host" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-agent-message-board-client", "akode-agent-message-board-extension", @@ -234,7 +234,7 @@ dependencies = [ [[package]] name = "akode-agent-roles" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-config", "akode-file-system", @@ -247,7 +247,7 @@ dependencies = [ [[package]] name = "akode-ansi-escape" -version = "0.3.0" +version = "0.3.1" dependencies = [ "ansi-to-tui", "pretty_assertions", @@ -258,7 +258,7 @@ dependencies = [ [[package]] name = "akode-api" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-client", "akode-http-client", @@ -296,7 +296,7 @@ dependencies = [ [[package]] name = "akode-app-server" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-agent-message-board-host", "akode-app-server-daemon", @@ -410,7 +410,7 @@ dependencies = [ [[package]] name = "akode-app-server-client" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-app-server", "akode-app-server-protocol", @@ -442,7 +442,7 @@ dependencies = [ [[package]] name = "akode-app-server-daemon" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-app-server-protocol", "akode-app-server-transport", @@ -472,7 +472,7 @@ dependencies = [ [[package]] name = "akode-app-server-protocol" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-app-server-protocol-noop-macros", "akode-experimental-api-macros", @@ -507,11 +507,11 @@ dependencies = [ [[package]] name = "akode-app-server-protocol-noop-macros" -version = "0.3.0" +version = "0.3.1" [[package]] name = "akode-app-server-test-client" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-app-server-protocol", "akode-core", @@ -533,7 +533,7 @@ dependencies = [ [[package]] name = "akode-app-server-transport" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-api", "akode-app-server-protocol", @@ -579,7 +579,7 @@ dependencies = [ [[package]] name = "akode-apply-patch" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-exec-server", "akode-utils-absolute-path", @@ -599,7 +599,7 @@ dependencies = [ [[package]] name = "akode-arg0" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-apply-patch", "akode-async-utils", @@ -622,7 +622,7 @@ dependencies = [ [[package]] name = "akode-async-utils" -version = "0.3.0" +version = "0.3.1" dependencies = [ "pretty_assertions", "rand 0.9.3", @@ -632,7 +632,7 @@ dependencies = [ [[package]] name = "akode-attachment-store" -version = "0.3.0" +version = "0.3.1" dependencies = [ "pretty_assertions", "serde", @@ -642,7 +642,7 @@ dependencies = [ [[package]] name = "akode-aws-auth" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-http-client", "akode-utils-rustls-provider", @@ -668,7 +668,7 @@ dependencies = [ [[package]] name = "akode-build-info" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-install-context", "pretty_assertions", @@ -681,7 +681,7 @@ dependencies = [ [[package]] name = "akode-bwrap" -version = "0.3.0" +version = "0.3.1" dependencies = [ "cc", "libc", @@ -690,7 +690,7 @@ dependencies = [ [[package]] name = "akode-cli" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-api", "akode-app-server", @@ -792,7 +792,7 @@ dependencies = [ [[package]] name = "akode-client" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-http-client", "eventsource-stream", @@ -806,7 +806,7 @@ dependencies = [ [[package]] name = "akode-code-mode" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-code-mode-protocol", "akode-http-client", @@ -830,7 +830,7 @@ dependencies = [ [[package]] name = "akode-code-mode-host" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-code-mode", "akode-code-mode-protocol", @@ -860,7 +860,7 @@ dependencies = [ [[package]] name = "akode-code-mode-protocol" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "glob", @@ -878,7 +878,7 @@ dependencies = [ [[package]] name = "akode-code-mode-runtime" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-code-mode-protocol", "akode-plugin-host", @@ -900,11 +900,11 @@ dependencies = [ [[package]] name = "akode-collaboration-mode-templates" -version = "0.3.0" +version = "0.3.1" [[package]] name = "akode-config" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-execpolicy", "akode-features", @@ -957,7 +957,7 @@ dependencies = [ [[package]] name = "akode-config-schema" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-config", "anyhow", @@ -966,7 +966,7 @@ dependencies = [ [[package]] name = "akode-context-fragments" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "akode-protocol-test-support", @@ -977,7 +977,7 @@ dependencies = [ [[package]] name = "akode-core" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-agent-graph-store", "akode-agent-message-board-host", @@ -1126,7 +1126,7 @@ dependencies = [ [[package]] name = "akode-core-api" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-app-server-protocol", "akode-arg0", @@ -1148,7 +1148,7 @@ dependencies = [ [[package]] name = "akode-core-plugin-common" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-absolute-path", "semver", @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "akode-core-plugins" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-app-server-protocol", "akode-config", @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "akode-diagnostics" -version = "0.3.0" +version = "0.3.1" dependencies = [ "libc", "pretty_assertions", @@ -1214,7 +1214,7 @@ dependencies = [ [[package]] name = "akode-direct-tool-timing" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-critical-path", "pretty_assertions", @@ -1225,7 +1225,7 @@ dependencies = [ [[package]] name = "akode-exec" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-app-server-client", "akode-app-server-protocol", @@ -1278,7 +1278,7 @@ dependencies = [ [[package]] name = "akode-exec-server" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-api", "akode-build-info", @@ -1350,7 +1350,7 @@ dependencies = [ [[package]] name = "akode-exec-server-cli" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-api", "akode-app-server", @@ -1393,7 +1393,7 @@ dependencies = [ [[package]] name = "akode-exec-server-protocol" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-file-system", "akode-install-context", @@ -1411,7 +1411,7 @@ dependencies = [ [[package]] name = "akode-exec-server-test-support" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-exec-server", "akode-http-client", @@ -1426,7 +1426,7 @@ dependencies = [ [[package]] name = "akode-execpolicy" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-absolute-path", "anyhow", @@ -1446,7 +1446,7 @@ dependencies = [ [[package]] name = "akode-experimental-api-macros" -version = "0.3.0" +version = "0.3.1" dependencies = [ "proc-macro2", "quote", @@ -1455,7 +1455,7 @@ dependencies = [ [[package]] name = "akode-extension-api" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-api", "akode-config", @@ -1478,7 +1478,7 @@ dependencies = [ [[package]] name = "akode-extension-items" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-absolute-path", "pretty_assertions", @@ -1490,7 +1490,7 @@ dependencies = [ [[package]] name = "akode-external-agent-migration" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-app-server-protocol", "akode-config", @@ -1520,7 +1520,7 @@ dependencies = [ [[package]] name = "akode-features" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-network-proxy", "akode-protocol", @@ -1534,7 +1534,7 @@ dependencies = [ [[package]] name = "akode-feedback" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-login", "akode-protocol", @@ -1554,7 +1554,7 @@ dependencies = [ [[package]] name = "akode-file-search" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "clap", @@ -1570,7 +1570,7 @@ dependencies = [ [[package]] name = "akode-file-system" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "akode-utils-absolute-path", @@ -1584,7 +1584,7 @@ dependencies = [ [[package]] name = "akode-file-watcher" -version = "0.3.0" +version = "0.3.1" dependencies = [ "notify", "pretty_assertions", @@ -1595,7 +1595,7 @@ dependencies = [ [[package]] name = "akode-git-attribution" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-extension-api", "serde_json", @@ -1603,7 +1603,7 @@ dependencies = [ [[package]] name = "akode-git-utils" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-file-system", "akode-protocol", @@ -1631,7 +1631,7 @@ dependencies = [ [[package]] name = "akode-goal-extension" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-core", "akode-extension-api", @@ -1655,7 +1655,7 @@ dependencies = [ [[package]] name = "akode-guardian-context" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-context-fragments", "akode-history", @@ -1669,7 +1669,7 @@ dependencies = [ [[package]] name = "akode-guardian-reviewer" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-context-fragments", "akode-extension-api", @@ -1705,7 +1705,7 @@ dependencies = [ [[package]] name = "akode-guardian-v2" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-api", "akode-config", @@ -1745,7 +1745,7 @@ dependencies = [ [[package]] name = "akode-guardian-v3" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-attachment-store", "akode-context-fragments", @@ -1775,7 +1775,7 @@ dependencies = [ [[package]] name = "akode-history" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "akode-protocol-test-support", @@ -1789,7 +1789,7 @@ dependencies = [ [[package]] name = "akode-home" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-extension-api", "akode-utils-absolute-path", @@ -1801,7 +1801,7 @@ dependencies = [ [[package]] name = "akode-hooks" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-config", "akode-plugin", @@ -1830,7 +1830,7 @@ dependencies = [ [[package]] name = "akode-http-client" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-cargo-bin", "akode-utils-rustls-provider", @@ -1870,7 +1870,7 @@ dependencies = [ [[package]] name = "akode-install-context" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-absolute-path", "akode-utils-home-dir", @@ -1883,7 +1883,7 @@ dependencies = [ [[package]] name = "akode-keyring-store" -version = "0.3.0" +version = "0.3.1" dependencies = [ "keyring", "pretty_assertions", @@ -1894,7 +1894,7 @@ dependencies = [ [[package]] name = "akode-linux-sandbox" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-core", "akode-install-context", @@ -1923,7 +1923,7 @@ dependencies = [ [[package]] name = "akode-lmstudio" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-core", "akode-http-client", @@ -1937,7 +1937,7 @@ dependencies = [ [[package]] name = "akode-login" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-config", "akode-http-client", @@ -1981,7 +1981,7 @@ dependencies = [ [[package]] name = "akode-mcp" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-async-utils", "akode-config", @@ -2025,7 +2025,7 @@ dependencies = [ [[package]] name = "akode-mcp-extension" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-config", "akode-core", @@ -2056,7 +2056,7 @@ dependencies = [ [[package]] name = "akode-memories-extension" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-core", "akode-extension-api", @@ -2078,7 +2078,7 @@ dependencies = [ [[package]] name = "akode-memories-read" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "akode-shell-command", @@ -2088,7 +2088,7 @@ dependencies = [ [[package]] name = "akode-memories-write" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-config", "akode-core", @@ -2125,7 +2125,7 @@ dependencies = [ [[package]] name = "akode-mermaid" -version = "0.3.0" +version = "0.3.1" dependencies = [ "insta", "pretty_assertions", @@ -2134,7 +2134,7 @@ dependencies = [ [[package]] name = "akode-message-board" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-attachment-store", "akode-message-board-mcp", @@ -2159,7 +2159,7 @@ dependencies = [ [[package]] name = "akode-message-board-mcp" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-attachment-store", "akode-message-board", @@ -2187,7 +2187,7 @@ dependencies = [ [[package]] name = "akode-message-history" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-config", "memchr", @@ -2201,7 +2201,7 @@ dependencies = [ [[package]] name = "akode-model-provider" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-api", "akode-feedback", @@ -2238,7 +2238,7 @@ dependencies = [ [[package]] name = "akode-model-provider-info" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-client", "akode-http-client", @@ -2258,7 +2258,7 @@ dependencies = [ [[package]] name = "akode-models-manager" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-http-client", "akode-login", @@ -2277,7 +2277,7 @@ dependencies = [ [[package]] name = "akode-multi-env-copy-file" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-config", "akode-core", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "akode-mxc-sandbox" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-network-proxy", "akode-protocol", @@ -2324,7 +2324,7 @@ dependencies = [ [[package]] name = "akode-network-proxy" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-absolute-path", "akode-utils-home-dir", @@ -2375,7 +2375,7 @@ dependencies = [ [[package]] name = "akode-ollama" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-core", "akode-http-client", @@ -2395,7 +2395,7 @@ dependencies = [ [[package]] name = "akode-otel" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-api", "akode-protocol", @@ -2422,7 +2422,7 @@ dependencies = [ [[package]] name = "akode-plugin" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-config", "akode-core-plugin-common", @@ -2437,7 +2437,7 @@ dependencies = [ [[package]] name = "akode-plugin-host" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-cargo-bin", "akode-utils-process", @@ -2454,7 +2454,7 @@ dependencies = [ [[package]] name = "akode-process-hardening" -version = "0.3.0" +version = "0.3.1" dependencies = [ "libc", "pretty_assertions", @@ -2462,7 +2462,7 @@ dependencies = [ [[package]] name = "akode-prompts" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-collaboration-mode-templates", "akode-context-fragments", @@ -2480,7 +2480,7 @@ dependencies = [ [[package]] name = "akode-protocol" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-async-utils", "akode-execpolicy", @@ -2527,7 +2527,7 @@ dependencies = [ [[package]] name = "akode-protocol-test-support" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "uuid", @@ -2535,7 +2535,7 @@ dependencies = [ [[package]] name = "akode-queue-extension" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-core", "akode-extension-api", @@ -2556,7 +2556,7 @@ dependencies = [ [[package]] name = "akode-realtime-webrtc" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-build-info", "akode-install-context", @@ -2575,7 +2575,7 @@ dependencies = [ [[package]] name = "akode-response-debug-context" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-api", "base64 0.22.1", @@ -2586,7 +2586,7 @@ dependencies = [ [[package]] name = "akode-rmcp-client" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-api", "akode-config", @@ -2638,7 +2638,7 @@ dependencies = [ [[package]] name = "akode-rollout" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-extension-items", "akode-file-search", @@ -2671,7 +2671,7 @@ dependencies = [ [[package]] name = "akode-rollout-trace" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-code-mode", "akode-protocol", @@ -2688,7 +2688,7 @@ dependencies = [ [[package]] name = "akode-sandboxing" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-mxc-sandbox", "akode-network-proxy", @@ -2716,7 +2716,7 @@ dependencies = [ [[package]] name = "akode-secrets" -version = "0.3.0" +version = "0.3.1" dependencies = [ "age", "akode-git-utils", @@ -2737,7 +2737,7 @@ dependencies = [ [[package]] name = "akode-shell-command" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "akode-utils-absolute-path", @@ -2760,7 +2760,7 @@ dependencies = [ [[package]] name = "akode-skills" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "akode-shell-command", @@ -2777,7 +2777,7 @@ dependencies = [ [[package]] name = "akode-skills-extension" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-attachment-store", "akode-config", @@ -2816,7 +2816,7 @@ dependencies = [ [[package]] name = "akode-state" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-file-system", "akode-git-utils", @@ -2845,7 +2845,7 @@ dependencies = [ [[package]] name = "akode-stdio-to-uds" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-uds", "akode-utils-cargo-bin", @@ -2857,7 +2857,7 @@ dependencies = [ [[package]] name = "akode-tcp-tunnel" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "bytes", @@ -2878,7 +2878,7 @@ dependencies = [ [[package]] name = "akode-telegram" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-app-server-protocol", "akode-config", @@ -2903,7 +2903,7 @@ dependencies = [ [[package]] name = "akode-terminal-detection" -version = "0.3.0" +version = "0.3.1" dependencies = [ "pretty_assertions", "tracing", @@ -2911,7 +2911,7 @@ dependencies = [ [[package]] name = "akode-test-binary-support" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-arg0", "tempfile", @@ -2919,7 +2919,7 @@ dependencies = [ [[package]] name = "akode-thread-manager-sample" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-core-api", "anyhow", @@ -2930,7 +2930,7 @@ dependencies = [ [[package]] name = "akode-thread-store" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-app-server-protocol", "akode-extension-items", @@ -2962,7 +2962,7 @@ dependencies = [ [[package]] name = "akode-tools" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-attachment-store", "akode-code-mode", @@ -2987,7 +2987,7 @@ dependencies = [ [[package]] name = "akode-tui" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-ansi-escape", "akode-app-server-client", @@ -3117,7 +3117,7 @@ dependencies = [ [[package]] name = "akode-uds" -version = "0.3.0" +version = "0.3.1" dependencies = [ "async-io", "libc", @@ -3131,7 +3131,7 @@ dependencies = [ [[package]] name = "akode-update" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-rustls-provider", "anyhow", @@ -3151,7 +3151,7 @@ dependencies = [ [[package]] name = "akode-user-verification" -version = "0.3.0" +version = "0.3.1" dependencies = [ "base64 0.22.1", "block2", @@ -3172,7 +3172,7 @@ dependencies = [ [[package]] name = "akode-utils-absolute-path" -version = "0.3.0" +version = "0.3.1" dependencies = [ "dirs", "dunce", @@ -3186,14 +3186,14 @@ dependencies = [ [[package]] name = "akode-utils-approval-presets" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", ] [[package]] name = "akode-utils-audio" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "akode-utils-cache", @@ -3207,7 +3207,7 @@ dependencies = [ [[package]] name = "akode-utils-cache" -version = "0.3.0" +version = "0.3.1" dependencies = [ "lru", "sha1 0.10.6", @@ -3216,7 +3216,7 @@ dependencies = [ [[package]] name = "akode-utils-cargo-bin" -version = "0.3.0" +version = "0.3.1" dependencies = [ "assert_cmd", "runfiles", @@ -3225,7 +3225,7 @@ dependencies = [ [[package]] name = "akode-utils-cli" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "akode-shell-command", @@ -3237,22 +3237,22 @@ dependencies = [ [[package]] name = "akode-utils-critical-path" -version = "0.3.0" +version = "0.3.1" dependencies = [ "pretty_assertions", ] [[package]] name = "akode-utils-elapsed" -version = "0.3.0" +version = "0.3.1" [[package]] name = "akode-utils-fuzzy-match" -version = "0.3.0" +version = "0.3.1" [[package]] name = "akode-utils-git-discovery" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-git-utils", "akode-utils-absolute-path", @@ -3265,14 +3265,14 @@ dependencies = [ [[package]] name = "akode-utils-head-tail-buffer" -version = "0.3.0" +version = "0.3.1" dependencies = [ "pretty_assertions", ] [[package]] name = "akode-utils-home-dir" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-absolute-path", "dirs", @@ -3282,7 +3282,7 @@ dependencies = [ [[package]] name = "akode-utils-image" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-cache", "base64 0.22.1", @@ -3296,7 +3296,7 @@ dependencies = [ [[package]] name = "akode-utils-json-to-toml" -version = "0.3.0" +version = "0.3.1" dependencies = [ "pretty_assertions", "serde_json", @@ -3305,7 +3305,7 @@ dependencies = [ [[package]] name = "akode-utils-model-facing-id" -version = "0.3.0" +version = "0.3.1" dependencies = [ "blake3", "pretty_assertions", @@ -3318,7 +3318,7 @@ dependencies = [ [[package]] name = "akode-utils-oss" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-core", "akode-lmstudio", @@ -3328,7 +3328,7 @@ dependencies = [ [[package]] name = "akode-utils-output-truncation" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "akode-utils-string", @@ -3338,7 +3338,7 @@ dependencies = [ [[package]] name = "akode-utils-path" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-absolute-path", "dunce", @@ -3349,7 +3349,7 @@ dependencies = [ [[package]] name = "akode-utils-path-uri" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-absolute-path", "base64 0.22.1", @@ -3365,7 +3365,7 @@ dependencies = [ [[package]] name = "akode-utils-plugins" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-exec-server", "akode-exec-server-protocol", @@ -3379,7 +3379,7 @@ dependencies = [ [[package]] name = "akode-utils-process" -version = "0.3.0" +version = "0.3.1" dependencies = [ "pretty_assertions", "tokio", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "akode-utils-pty" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-cargo-bin", "anyhow", @@ -3406,7 +3406,7 @@ dependencies = [ [[package]] name = "akode-utils-readiness" -version = "0.3.0" +version = "0.3.1" dependencies = [ "assert_matches", "thiserror 2.0.18", @@ -3416,7 +3416,7 @@ dependencies = [ [[package]] name = "akode-utils-redacted-string" -version = "0.3.0" +version = "0.3.1" dependencies = [ "schemars 0.8.22", "serde", @@ -3424,14 +3424,14 @@ dependencies = [ [[package]] name = "akode-utils-rustls-provider" -version = "0.3.0" +version = "0.3.1" dependencies = [ "rustls", ] [[package]] name = "akode-utils-sandbox-summary" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-protocol", "akode-utils-absolute-path", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "akode-utils-sleep-inhibitor" -version = "0.3.0" +version = "0.3.1" dependencies = [ "core-foundation 0.9.4", "libc", @@ -3451,14 +3451,14 @@ dependencies = [ [[package]] name = "akode-utils-stream-parser" -version = "0.3.0" +version = "0.3.1" dependencies = [ "pretty_assertions", ] [[package]] name = "akode-utils-string" -version = "0.3.0" +version = "0.3.1" dependencies = [ "pretty_assertions", "regex-lite", @@ -3468,14 +3468,14 @@ dependencies = [ [[package]] name = "akode-utils-template" -version = "0.3.0" +version = "0.3.1" dependencies = [ "pretty_assertions", ] [[package]] name = "akode-v8-poc" -version = "0.3.0" +version = "0.3.1" dependencies = [ "pretty_assertions", "v8", @@ -3483,7 +3483,7 @@ dependencies = [ [[package]] name = "akode-voice-host" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-install-context", "akode-process-hardening", @@ -3510,7 +3510,7 @@ dependencies = [ [[package]] name = "akode-web-search-extension" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-api", "akode-core", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "akode-web-tools" -version = "0.3.0" +version = "0.3.1" dependencies = [ "encoding_rs", "pretty_assertions", @@ -3554,7 +3554,7 @@ dependencies = [ [[package]] name = "akode-websocket-auth" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-utils-absolute-path", "anyhow", @@ -3573,7 +3573,7 @@ dependencies = [ [[package]] name = "akode-websocket-client" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-http-client", "akode-utils-rustls-provider", @@ -3589,7 +3589,7 @@ dependencies = [ [[package]] name = "akode-windows-sandbox" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-http-client", "akode-otel", @@ -3620,7 +3620,7 @@ dependencies = [ [[package]] name = "akode-windows-sandbox-service" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-config", "akode-core", @@ -3637,14 +3637,14 @@ dependencies = [ [[package]] name = "akode-windows-sandbox-test-support" -version = "0.3.0" +version = "0.3.1" dependencies = [ "dirs", ] [[package]] name = "akode-worktree" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-git-utils", "akode-protocol", @@ -3799,7 +3799,7 @@ checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" [[package]] name = "app_test_support" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-app-server-protocol", "akode-config", @@ -5616,7 +5616,7 @@ dependencies = [ [[package]] name = "core_test_support" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akode-agent-graph-store", "akode-agent-message-board-host", diff --git a/akode-rs/Cargo.toml b/akode-rs/Cargo.toml index 44286b32..62475c99 100644 --- a/akode-rs/Cargo.toml +++ b/akode-rs/Cargo.toml @@ -158,7 +158,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.3.0" +version = "0.3.1" # Track the edition for all workspace crates in one place. Individual # crates can still override this value, but keeping it here means new # crates created with `cargo new -w ...` automatically inherit the 2024 diff --git a/akode-rs/telegram/src/api.rs b/akode-rs/telegram/src/api.rs index bf3d2fe6..e0c7ebbe 100644 --- a/akode-rs/telegram/src/api.rs +++ b/akode-rs/telegram/src/api.rs @@ -401,6 +401,12 @@ impl TelegramApi { self.call_unit("editForumTopic", body).await } + /// Deletes a topic with all its messages (supergroups and private chats). + pub async fn delete_forum_topic(&self, chat_id: i64, thread: i64) -> Result<(), ApiError> { + let body = json!({ "chat_id": chat_id, "message_thread_id": thread }); + self.call_unit("deleteForumTopic", body).await + } + /// Streams a partial message (a temporary preview, replaced by the next message). pub async fn send_message_draft( &self, diff --git a/akode-rs/telegram/src/bridge.rs b/akode-rs/telegram/src/bridge.rs index 04dcaf91..11910e8f 100644 --- a/akode-rs/telegram/src/bridge.rs +++ b/akode-rs/telegram/src/bridge.rs @@ -84,7 +84,9 @@ use crate::settings::load_token; use crate::settings::set_toggle; use crate::text; use crate::text::Rich; +use crate::topics::TopicEntry; use crate::topics::Topics; +use crate::topics::has_rollout; /// Channels of one internal app-server connection. pub struct BridgeConnection { @@ -220,6 +222,10 @@ struct Session { reactions: Vec<(i64, i64)>, /// The running turn was asked for from Telegram: its answer is always sent. from_telegram: bool, + /// The session had a turn (its topic is created lazily, at the first one). + had_turn: bool, + /// `default`, `plan` or `accesso completo` (as cycled with Shift+Tab in the TUI). + mode: &'static str, } #[derive(Clone, Copy, PartialEq, Eq, Debug)] @@ -260,14 +266,22 @@ enum Action { NewSessionMenu, NewSession(String), SendTo { pending: u64, thread_id: String }, + /// Gives an unmapped topic to a session (`None`: a new one in `cwd`) and sends the text. + Adopt { + pending: u64, + thread_id: Option, + cwd: Option, + }, Toggle(Toggle), } -/// A main-chat message waiting for the user to pick its session. +/// A message waiting for the user to pick its session. struct PendingText { chat_id: i64, message_id: i64, text: String, + /// Written in this unmapped topic (created by the user with «Nuova chat»). + topic: Option, } enum Pending { @@ -277,6 +291,8 @@ enum Pending { NewThread { chat_id: i64, thread: Option, + /// A message written in an unmapped topic: that topic becomes the session's. + adopt: Option, }, Start { chat_id: i64, @@ -556,6 +572,7 @@ impl Bridge { }) else { return; }; + self.clean_topics(&list.data); for thread_id in list.data { if self.session(&thread_id).is_some() { continue; @@ -578,10 +595,15 @@ impl Bridge { .map_err(|err| err.to_string()) }) { let model = response.model.clone(); - self.add_session(&response.thread, Some(model)); + let mode = session_mode(None, &response.sandbox); + self.add_session(&response.thread, Some(model), mode); } } - Pending::NewThread { chat_id, thread } => { + Pending::NewThread { + chat_id, + thread, + adopt, + } => { let origin = Origin { chat_id, thread }; match result.and_then(|value| { serde_json::from_value::(value) @@ -589,14 +611,26 @@ impl Bridge { }) { Ok(response) => { let model = response.model.clone(); - self.add_session(&response.thread, Some(model)); - let name = self.topic_name(&response.thread.id); + let mode = session_mode(None, &response.sandbox); + self.add_session(&response.thread, Some(model), mode); + let thread_id = response.thread.id.clone(); + if let Some(text) = adopt { + self.adopt_topic(text, &thread_id); + return; + } + let name = self.topic_name(&thread_id); let note = if self.topics_enabled() { - format!("Nuova sessione avviata: {name}. Scrivi nel suo topic.") + format!( + "Nuova sessione avviata: {name}. Rispondi a questo messaggio con la \ + prima richiesta: il topic della sessione nasce con il primo turno." + ) } else { - format!("Nuova sessione avviata: {name}.") + format!( + "Nuova sessione avviata: {name}. Rispondi a questo messaggio con la \ + prima richiesta." + ) }; - self.say(origin, ¬e); + self.say_with(origin, Rich::plain(note), None, Tag::Session(thread_id)); } Err(err) => self.say(origin, &format!("Sessione non avviata: {err}")), } @@ -678,7 +712,7 @@ impl Bridge { } } - fn add_session(&mut self, thread: &Thread, model: Option) { + fn add_session(&mut self, thread: &Thread, model: Option, mode: &'static str) { if thread.parent_thread_id.is_some() || self.session(&thread.id).is_some() { return; } @@ -701,10 +735,13 @@ impl Bridge { plan: None, reactions: Vec::new(), from_telegram: false, + had_turn: !thread.turns.is_empty(), + mode, }); self.lock_topics() .remember_cwd(&thread.cwd.to_path_buf().display().to_string()); - self.ensure_topics(&thread.id); + // An existing topic gets its name back; a new one waits for the first turn. + self.ensure_topics(&thread.id, false); self.refresh_session_lists(); } @@ -742,37 +779,84 @@ impl Bridge { format!("[{}]", self.topic_name(thread_id)) } - /// Asks the outbox to create or rename the session's topic in every chat. - fn ensure_topics(&self, thread_id: &str) { + /// Asks the outbox to rename the session's topic in every chat and, with `create`, to + /// create it when missing. + fn ensure_topics(&self, thread_id: &str, create: bool) { let name = self.topic_name(thread_id); for chat_id in &self.settings.allowed_chat_ids { self.post(Outbox::Topic { chat_id: *chat_id, session: thread_id.to_string(), name: name.clone(), - create: true, + create, }); } } + /// The session is gone: its topic is deleted when the session never had a turn, + /// otherwise renamed to «… (chiusa)». + fn close_topics(&self, thread_id: &str) { + let Some(session) = self.session(thread_id) else { + return; + }; + let empty = !session.had_turn && !has_rollout(&self.options.codex_home, thread_id); + let name = closed_name(&self.topic_name(thread_id)); + for chat_id in &self.settings.allowed_chat_ids { + let thread = self.lock_topics().entry(*chat_id, thread_id).map(|e| e.thread); + match thread { + Some(thread) if empty => self.post(Outbox::DeleteTopic { + chat_id: *chat_id, + thread, + session: Some(thread_id.to_string()), + fallback_name: Some(name.clone()), + }), + Some(_) => self.post(Outbox::Topic { + chat_id: *chat_id, + session: thread_id.to_string(), + name: name.clone(), + create: false, + }), + None => {} + } + } + } + + /// At start: topics of sessions that are gone without ever having a turn are deleted, + /// renames that Telegram never confirmed are sent again. + fn clean_topics(&self, loaded: &[String]) { + let entries = self.lock_topics().entries(); + for entry in entries { + if !self.settings.is_allowed(entry.chat_id) + || loaded.iter().any(|id| id == &entry.session) + { + continue; + } + if !has_rollout(&self.options.codex_home, &entry.session) { + self.post(Outbox::DeleteTopic { + chat_id: entry.chat_id, + thread: entry.thread, + session: Some(entry.session.clone()), + fallback_name: Some(closed_name(&entry.name)), + }); + } else if let Some(name) = entry.pending_name { + self.post(Outbox::Topic { + chat_id: entry.chat_id, + session: entry.session, + name, + create: false, + }); + } + } + } + fn on_notification(&mut self, notification: ServerNotification) { match notification { ServerNotification::ThreadStarted(started) => { let model = started.thread.model.clone(); - self.add_session(&started.thread, model); + self.add_session(&started.thread, model, MODE_DEFAULT); } ServerNotification::ThreadClosed(closed) => { - let name = text::closed_topic_name(&self.topic_name(&closed.thread_id)); - if self.session(&closed.thread_id).is_some() { - for chat_id in &self.settings.allowed_chat_ids { - self.post(Outbox::Topic { - chat_id: *chat_id, - session: closed.thread_id.clone(), - name: name.clone(), - create: false, - }); - } - } + self.close_topics(&closed.thread_id); self.sessions .retain(|session| session.thread_id != closed.thread_id); self.refresh_session_lists(); @@ -783,10 +867,14 @@ impl Bridge { return; }; let cwd = settings.cwd.to_path_buf(); + session.mode = session_mode( + serde_json::to_value(settings.collaboration_mode.mode).ok(), + &settings.sandbox_policy, + ); if session.model != settings.model || session.cwd != cwd { session.model = settings.model; session.cwd = cwd; - self.ensure_topics(&updated.thread_id); + self.ensure_topics(&updated.thread_id, false); self.refresh_session_lists(); } } @@ -805,6 +893,8 @@ impl Bridge { session.active_turn = Some(started.turn.id); session.last_message = None; session.stream = None; + session.had_turn = true; + self.ensure_topics(&started.thread_id, true); } self.refresh_session_lists(); } @@ -1345,7 +1435,7 @@ impl Bridge { tag: Tag, ) { if self.session(thread_id).is_some() { - self.ensure_topics(thread_id); + self.ensure_topics(thread_id, true); } let dest = Dest::Session { id: thread_id.to_string(), @@ -1610,6 +1700,7 @@ impl Bridge { Pending::NewThread { chat_id, thread: origin.thread, + adopt: None, }, ); } @@ -1627,6 +1718,45 @@ impl Bridge { self.add_route(text.chat_id, text.message_id, thread_id.clone()); self.send_user_text(text.chat_id, &thread_id, text.text, Some(text.message_id)); } + Action::Adopt { + pending, + thread_id, + cwd, + } => { + let Some(text) = self.pending_texts.remove(&pending) else { + self.answer(callback_id, "Messaggio già inviato."); + return; + }; + match (thread_id, cwd) { + (Some(thread_id), _) => { + if self.session(&thread_id).is_none() { + self.pending_texts.insert(pending, text); + self.answer(callback_id, "Sessione chiusa."); + return; + } + let name = self.topic_name(&thread_id); + self.answer(callback_id, &format!("Inviato a {name}.")); + self.adopt_topic(text, &thread_id); + } + (None, cwd) => { + self.answer(callback_id, "Avvio la sessione."); + self.request( + |request_id| ClientRequest::ThreadStart { + request_id, + params: ThreadStartParams { + cwd, + ..Default::default() + }, + }, + Pending::NewThread { + chat_id, + thread: origin.thread, + adopt: Some(text), + }, + ); + } + } + } Action::Toggle(toggle) => { let value = !toggle.get(&self.settings); if let Err(err) = set_toggle(&self.options.codex_home, toggle, value) { @@ -1705,6 +1835,10 @@ impl Bridge { .find(|((chat, id), _)| *chat == chat_id && *id == replied.message_id) .map(|(_, thread_id)| thread_id.clone()) }); + if let Some(stray) = topic.filter(|_| topic_session.is_none() && replied.is_none()) { + self.on_stray_topic(chat_id, stray, message.message_id, trimmed, body.clone()); + return; + } let target = topic_session.or(replied); if is_command { let target = target.filter(|thread_id| self.session(thread_id).is_some()); @@ -1730,24 +1864,130 @@ impl Bridge { } } - /// Several sessions and no topic: asks with buttons where the message goes. - fn choose_session_for(&mut self, origin: Origin, message_id: i64, text: String) { + fn store_pending(&mut self, text: PendingText) -> u64 { self.next_pending_text += 1; let pending = self.next_pending_text; - self.pending_texts.insert( - pending, - PendingText { - chat_id: origin.chat_id, - message_id, - text, - }, - ); + self.pending_texts.insert(pending, text); while self.pending_texts.len() > 50 { let Some(oldest) = self.pending_texts.keys().min().copied() else { break; }; self.pending_texts.remove(&oldest); } + pending + } + + /// A message in a topic that belongs to no session: the user made it with «Nuova chat», + /// and Telegram named it after the text. A command is answered in the main chat and the + /// topic deleted; plain text asks which session the topic is for. + fn on_stray_topic(&mut self, chat_id: i64, topic: i64, message_id: i64, trimmed: &str, body: String) { + if trimmed.starts_with('/') { + let origin = Origin { + chat_id, + thread: None, + }; + self.on_command(origin, trimmed, None); + self.post(Outbox::DeleteTopic { + chat_id, + thread: topic, + session: None, + fallback_name: None, + }); + return; + } + let pending = self.store_pending(PendingText { + chat_id, + message_id, + text: body, + topic: Some(topic), + }); + let threads: Vec = self.sessions.iter().map(|s| s.thread_id.clone()).collect(); + let mut rows = Vec::new(); + for thread_id in threads { + let label = self.topic_name(&thread_id); + let token = self.register(Action::Adopt { + pending, + thread_id: Some(thread_id), + cwd: None, + }); + rows.push(vec![Button::callback(label, token)]); + } + let cwd = self + .lock_topics() + .recent_cwds() + .first() + .cloned() + .or_else(|| self.sessions.last().map(|s| s.cwd.display().to_string())); + if let Some(cwd) = cwd { + let token = self.register(Action::Adopt { + pending, + thread_id: None, + cwd: Some(cwd), + }); + rows.push(vec![Button::callback("Nuova sessione", token)]); + } + let origin = Origin { + chat_id, + thread: Some(topic), + }; + if rows.is_empty() { + self.say(origin, "Nessuna sessione di aKode attiva. Avvia una sessione dal Mac."); + return; + } + self.say_with( + origin, + Rich::plain("A quale sessione appartiene questo topic?"), + Some(rows), + Tag::None, + ); + } + + /// Maps the topic of `text` to `thread_id` and sends the text there. When the session + /// already has its own topic, the text goes to it and the extra topic is deleted. + fn adopt_topic(&mut self, text: PendingText, thread_id: &str) { + let Some(topic) = text.topic else { + return; + }; + let existing = self + .lock_topics() + .entry(text.chat_id, thread_id) + .map(|entry| entry.thread) + .filter(|thread| *thread != topic); + if existing.is_some() { + self.post(Outbox::DeleteTopic { + chat_id: text.chat_id, + thread: topic, + session: None, + fallback_name: None, + }); + self.send_user_text(text.chat_id, thread_id, text.text, None); + return; + } + self.lock_topics().insert(TopicEntry { + chat_id: text.chat_id, + session: thread_id.to_string(), + thread: topic, + name: String::new(), + pending_name: None, + }); + self.post(Outbox::Topic { + chat_id: text.chat_id, + session: thread_id.to_string(), + name: self.topic_name(thread_id), + create: false, + }); + self.add_route(text.chat_id, text.message_id, thread_id.to_string()); + self.send_user_text(text.chat_id, thread_id, text.text, Some(text.message_id)); + } + + /// Several sessions and no topic: asks with buttons where the message goes. + fn choose_session_for(&mut self, origin: Origin, message_id: i64, text: String) { + let pending = self.store_pending(PendingText { + chat_id: origin.chat_id, + message_id, + text, + topic: None, + }); let threads: Vec = self.sessions.iter().map(|s| s.thread_id.clone()).collect(); let mut rows = Vec::new(); for thread_id in threads { @@ -1871,8 +2111,9 @@ impl Bridge { ); if self.topics_enabled() { text.push_str( - "Ogni sessione ha il suo topic: scrivi nel topic per parlare con quella sessione. \ - Nella chat principale rispondi a un messaggio della sessione.", + "Ogni sessione ha il suo topic dal primo turno: scrivi nel topic per parlare con \ + quella sessione. Nella chat principale rispondi a un messaggio della sessione. \ + In una nuova chat di Telegram ti chiedo a quale sessione appartiene.", ); } else { text.push_str( @@ -2062,15 +2303,42 @@ impl Bridge { return "Sessione chiusa.".to_string(); }; format!( - "{} · {}\nCartella: {}", + "{} · {}\nModalità: {}\nCartella: {}", self.topic_name(thread_id), self.session_line(session), + session.mode, session.cwd.display() ) } } /// The end of the running answer, as shown in a draft. +const MODE_DEFAULT: &str = "default"; + +/// The session mode as the TUI shows it: plan, full access (no sandbox) or default. +fn session_mode(mode: Option, sandbox: &impl serde::Serialize) -> &'static str { + let plan = mode.is_some_and(|mode| mode == "plan"); + let full = serde_json::to_value(sandbox) + .ok() + .is_some_and(|sandbox| sandbox["type"] == "dangerFullAccess"); + if plan { + "plan" + } else if full { + "accesso completo" + } else { + MODE_DEFAULT + } +} + +/// «… (chiusa)», once. +fn closed_name(name: &str) -> String { + if name.ends_with("(chiusa)") { + name.to_string() + } else { + text::closed_topic_name(name) + } +} + fn draft_tail(text: &str) -> String { let count = text.chars().count(); if count <= DRAFT_TAIL { diff --git a/akode-rs/telegram/src/outbox.rs b/akode-rs/telegram/src/outbox.rs index 9a0890c2..fcbb15f2 100644 --- a/akode-rs/telegram/src/outbox.rs +++ b/akode-rs/telegram/src/outbox.rs @@ -30,6 +30,9 @@ pub(crate) const COMMANDS: [(&str, &str); 6] = [ ("aiuto", "Come si usa il bot"), ]; +/// Tries of one topic rename before it is left for the next start. +const RENAME_ATTEMPTS: u32 = 3; + /// Draft text limit (Telegram accepts 4096 characters). const DRAFT_LIMIT: usize = 4000; @@ -79,6 +82,14 @@ pub(crate) enum Outbox { name: String, create: bool, }, + /// Deletes a topic with its messages. With `session` the map entry goes too; when + /// Telegram refuses, the topic is renamed to `fallback_name` instead. + DeleteTopic { + chat_id: i64, + thread: i64, + session: Option, + fallback_name: Option, + }, Draft { chat_id: i64, session: String, @@ -216,6 +227,15 @@ impl OutboxTask { name, create, } => self.topic(chat_id, &session, &name, create).await, + Outbox::DeleteTopic { + chat_id, + thread, + session, + fallback_name, + } => { + self.delete_topic(chat_id, thread, session.as_deref(), fallback_name.as_deref()) + .await; + } Outbox::Draft { chat_id, session, @@ -293,11 +313,8 @@ impl OutboxTask { return; } match existing { - Some(entry) if entry.name != name => { - match self.api.edit_forum_topic(chat_id, entry.thread, name).await { - Ok(()) => lock(&self.topics).set_name(chat_id, session, name), - Err(err) => warn!("telegram: editForumTopic failed: {err}"), - } + Some(entry) if entry.name != name || entry.pending_name.is_some() => { + self.rename(chat_id, session, entry.thread, name).await; } Some(_) => {} None if create => match self.api.create_forum_topic(chat_id, name).await { @@ -306,6 +323,7 @@ impl OutboxTask { session: session.to_string(), thread: topic.message_thread_id, name: name.to_string(), + pending_name: None, }), Err(ApiError::Network(err)) => { warn!("telegram: createForumTopic failed, retrying later: {err}"); @@ -320,6 +338,64 @@ impl OutboxTask { } } + /// Renames a topic, retrying failures; a rename still failing is kept as pending in the + /// map and applied again when the bridge starts. + async fn rename(&self, chat_id: i64, session: &str, thread: i64, name: &str) -> bool { + lock(&self.topics).set_pending_name(chat_id, session, name); + for attempt in 1..=RENAME_ATTEMPTS { + let err = match self.api.edit_forum_topic(chat_id, thread, name).await { + Ok(()) => { + lock(&self.topics).set_name(chat_id, session, name); + return true; + } + Err(err) if mentions(&err, &["not modified"]) => { + lock(&self.topics).set_name(chat_id, session, name); + return true; + } + Err(err) => err, + }; + warn!("telegram: editForumTopic failed (attempt {attempt}/{RENAME_ATTEMPTS}): {err}"); + if is_bad_request(&err) && mentions(&err, &["not found", "invalid"]) { + // The user deleted the topic. + lock(&self.topics).remove(chat_id, session); + return false; + } + if err.is_unauthorized() || attempt == RENAME_ATTEMPTS { + break; + } + let wait = err.retry_after().unwrap_or(attempt as u64).min(30); + tokio::time::sleep(Duration::from_secs(wait)).await; + } + false + } + + async fn delete_topic( + &self, + chat_id: i64, + thread: i64, + session: Option<&str>, + fallback_name: Option<&str>, + ) { + if chat_id <= 0 { + return; + } + let result = self.with_retry(|| self.api.delete_forum_topic(chat_id, thread)).await; + match result { + Ok(()) => {} + Err(err) if mentions(&err, &["not found"]) => {} + Err(err) => { + warn!("telegram: deleteForumTopic failed: {err}"); + if let (Some(session), Some(name)) = (session, fallback_name) { + self.rename(chat_id, session, thread, name).await; + } + return; + } + } + if let Some(session) = session { + lock(&self.topics).remove(chat_id, session); + } + } + async fn send( &self, chat_id: i64, diff --git a/akode-rs/telegram/src/topics.rs b/akode-rs/telegram/src/topics.rs index e65856d1..e3b54844 100644 --- a/akode-rs/telegram/src/topics.rs +++ b/akode-rs/telegram/src/topics.rs @@ -21,6 +21,9 @@ pub struct TopicEntry { pub session: String, pub thread: i64, pub name: String, + /// A rename not yet confirmed by Telegram, applied again at the next start. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pending_name: Option, } #[derive(Debug, Default, Serialize, Deserialize)] @@ -102,14 +105,33 @@ impl Topics { self.save(); } - pub fn set_name(&mut self, chat_id: i64, session: &str, name: &str) { - if let Some(entry) = self - .file + /// Every mapped topic. + pub fn entries(&self) -> Vec { + self.file.topics.clone() + } + + fn entry_mut(&mut self, chat_id: i64, session: &str) -> Option<&mut TopicEntry> { + self.file .topics .iter_mut() .find(|entry| entry.chat_id == chat_id && entry.session == session) - { + } + + /// Records a confirmed rename. + pub fn set_name(&mut self, chat_id: i64, session: &str, name: &str) { + if let Some(entry) = self.entry_mut(chat_id, session) { entry.name = name.to_string(); + entry.pending_name = None; + self.save(); + } + } + + /// Records a rename before asking Telegram, so a failed one is retried at the next start. + pub fn set_pending_name(&mut self, chat_id: i64, session: &str, name: &str) { + if let Some(entry) = self.entry_mut(chat_id, session) + && entry.pending_name.as_deref() != Some(name) + { + entry.pending_name = Some(name.to_string()); self.save(); } } @@ -137,11 +159,45 @@ impl Topics { } } +/// The session has a rollout file under `AKODE_HOME`, that is it ever had a turn. +pub fn has_rollout(codex_home: &Path, session: &str) -> bool { + fn walk(dir: &Path, session: &str, depth: u8) -> bool { + let Ok(entries) = std::fs::read_dir(dir) else { + return false; + }; + entries.flatten().any(|entry| { + let path = entry.path(); + if path.is_dir() { + depth > 0 && walk(&path, session, depth - 1) + } else { + path.file_name() + .and_then(|name| name.to_str()) + .is_some_and(|name| name.starts_with("rollout-") && name.contains(session)) + } + }) + } + !session.is_empty() + && ["sessions", "archived_sessions"] + .iter() + .any(|dir| walk(&codex_home.join(dir), session, 4)) +} + #[cfg(test)] mod tests { use super::*; use pretty_assertions::assert_eq; + #[test] + fn rollouts_are_found_by_session_id() { + let home = tempfile::tempdir().unwrap(); + let day = home.path().join("sessions/2026/11/12"); + std::fs::create_dir_all(&day).unwrap(); + std::fs::write(day.join("rollout-2026-11-12T10-00-00-abc-123.jsonl"), "").unwrap(); + assert!(has_rollout(home.path(), "abc-123")); + assert!(!has_rollout(home.path(), "def-456")); + assert!(!has_rollout(home.path(), "")); + } + #[test] fn map_survives_a_reload() { let home = tempfile::tempdir().unwrap(); @@ -151,7 +207,9 @@ mod tests { session: "t1".to_string(), thread: 77, name: "alfa · Qwen".to_string(), + pending_name: None, }); + topics.set_pending_name(1, "t1", "alfa · Qwen (chiusa)"); topics.remember_cwd("/a"); topics.remember_cwd("/b"); topics.remember_cwd("/a"); @@ -160,6 +218,12 @@ mod tests { topics.enabled = true; assert_eq!(topics.thread_for(1, "t1"), Some(77)); assert_eq!(topics.session_for(1, 77), Some("t1")); + assert_eq!( + topics.entry(1, "t1").and_then(|e| e.pending_name.clone()).as_deref(), + Some("alfa · Qwen (chiusa)") + ); + topics.set_name(1, "t1", "alfa · Qwen (chiusa)"); + assert_eq!(topics.entry(1, "t1").unwrap().pending_name, None); assert_eq!(topics.recent_cwds(), ["/a".to_string(), "/b".to_string()]); } } diff --git a/akode-rs/telegram/tests/bridge.rs b/akode-rs/telegram/tests/bridge.rs index ea72a5e9..ec79644d 100644 --- a/akode-rs/telegram/tests/bridge.rs +++ b/akode-rs/telegram/tests/bridge.rs @@ -127,7 +127,7 @@ async fn mock_telegram(topics: bool) -> (MockServer, Arc>> .await; Mock::given(method("POST")) .and(path_regex( - ".*/(editMessageText|answerCallbackQuery|setMyCommands|editForumTopic|sendMessageDraft|setMessageReaction)$", + ".*/(editMessageText|answerCallbackQuery|setMyCommands|editForumTopic|deleteForumTopic|sendMessageDraft|setMessageReaction)$", )) .respond_with(ResponseTemplate::new(200).set_body_json(json!({"ok": true, "result": true}))) .mount(&telegram) @@ -541,6 +541,10 @@ async fn topics_are_created_mapped_and_reused_after_a_restart() { let h = Harness::with_topics().await; home = Arc::clone(&h.home); h.start_thread("t1", "/tmp/alfa"); + let mut h = h; + h.settle().await; + assert!(h.calls("createForumTopic").await.is_empty(), "no topic before the first turn"); + h.notify("turn/started", json!({"threadId": "t1", "turn": turn_json("turn-1", "inProgress")})); let topics = h.wait_for_calls("createForumTopic", 1).await; assert_eq!(topics[0]["chat_id"], json!(CHAT)); assert_eq!(topics[0]["name"], "alfa · Qwen 3.6"); @@ -570,6 +574,9 @@ async fn topics_are_created_mapped_and_reused_after_a_restart() { } // A new bridge on the same home writes into the same topic and reopens its name. + let day = home.path().join("sessions/2026/11/12"); + std::fs::create_dir_all(&day).unwrap(); + std::fs::write(day.join("rollout-2026-11-12T10-00-00-t1.jsonl"), "").unwrap(); let h = Harness::start_with(home, true).await; h.start_thread("t1", "/tmp/alfa"); let renames = h.wait_for_calls("editForumTopic", 1).await; @@ -585,9 +592,14 @@ async fn topic_messages_go_to_their_session() { let mut h = Harness::with_topics().await; h.start_thread("t1", "/tmp/alfa"); h.start_thread("t2", "/tmp/beta"); + for thread in ["t1", "t2"] { + h.notify("turn/started", json!({"threadId": thread, "turn": turn_json("turn-0", "inProgress")})); + h.notify("turn/completed", json!({"threadId": thread, "turn": turn_json("turn-0", "completed")})); + } h.wait_for_calls("createForumTopic", 2).await; // Let the outbox store both topics. h.settle().await; + let base = h.calls("sendMessage").await.len(); h.push_update(topic_message(CHAT, 501, "continua")); let start = h.expect_request("turn/start").await; @@ -597,14 +609,14 @@ async fn topic_messages_go_to_their_session() { // Commands in a topic act on its session and answer in the topic. h.push_update(topic_message(CHAT, 500, "/stato")); - let sends = h.wait_for_calls("sendMessage", 1).await; - assert_eq!(sends[0]["message_thread_id"], 500); - assert!(sends[0]["text"].as_str().unwrap().starts_with("alfa · Qwen 3.6 · libera")); + let sends = h.wait_for_calls("sendMessage", base + 1).await; + assert_eq!(sends[base]["message_thread_id"], 500); + assert!(sends[base]["text"].as_str().unwrap().starts_with("alfa · Qwen 3.6 · libera")); // The session list links each topic and refreshes in place. h.push_update(text_message(CHAT, "/sessioni", None)); - let sends = h.wait_for_calls("sendMessage", 2).await; - let list = &sends[1]; + let sends = h.wait_for_calls("sendMessage", base + 2).await; + let list = &sends[base + 1]; assert_eq!( labels(list), vec![ @@ -614,7 +626,7 @@ async fn topic_messages_go_to_their_session() { ] ); assert_eq!(list["reply_markup"]["inline_keyboard"][1][0]["url"], "https://t.me/akode_bot/501"); - let list_id = 1001; + let list_id = list_message_id(&h, base + 1).await; h.push_update(callback_on(CHAT, &button(list, "2 · Stato"), list_id)); let answers = h.wait_for_calls("answerCallbackQuery", 1).await; assert!(answers[0]["text"].as_str().unwrap().starts_with("beta · Qwen 3.6")); @@ -622,7 +634,7 @@ async fn topic_messages_go_to_their_session() { let edits = h.wait_for_calls("editMessageText", 1).await; assert_eq!(edits[0]["message_id"], list_id); assert!(edits[0]["text"].as_str().unwrap().contains("al lavoro")); - assert_eq!(h.calls("sendMessage").await.len(), 2, "refresh edits, never sends"); + assert_eq!(h.calls("sendMessage").await.len(), base + 2, "refresh edits, never sends"); h.push_update(callback_on(CHAT, &button(list, "1 · Stop"), list_id)); let interrupt = h.expect_request("turn/interrupt").await; assert_eq!(interrupt.params.unwrap()["turnId"], "turn-9"); @@ -726,8 +738,8 @@ async fn edited_commands_run_again_and_edited_text_is_ignored() { async fn drafts_are_throttled_and_stop_interrupts() { let mut h = Harness::with_topics().await; h.start_thread("t1", "/tmp/alfa"); - h.wait_for_calls("createForumTopic", 1).await; h.notify("turn/started", json!({"threadId": "t1", "turn": turn_json("turn-1", "inProgress")})); + h.wait_for_calls("createForumTopic", 1).await; for word in ["Sto ", "leggendo ", "i ", "file ", "del ", "progetto."] { h.notify( "item/agentMessage/delta", @@ -864,3 +876,187 @@ async fn nothing_is_polled_while_disabled() { assert_eq!(connects.load(Ordering::SeqCst), 0); assert!(telegram.received_requests().await.unwrap_or_default().is_empty()); } + +fn saved_topics(home: &Path) -> Value { + serde_json::from_str(&std::fs::read_to_string(home.join(topics::TOPICS_FILE)).unwrap()).unwrap() +} + +fn start_response(id: &str, cwd: &str) -> Value { + json!({"thread": thread_json(id, cwd), "model": "qwen", "modelProvider": "p", + "serviceTier": null, "cwd": cwd, "approvalPolicy": "never", + "approvalsReviewer": "user", "sandbox": {"type": "dangerFullAccess"}, + "reasoningEffort": null}) +} + +#[tokio::test] +async fn a_session_without_turns_gets_no_topic_and_its_topic_is_deleted_on_close() { + let mut h = Harness::with_topics().await; + h.start_thread("t1", "/tmp/alfa"); + h.settle().await; + assert!(h.calls("createForumTopic").await.is_empty()); + // An error creates the topic even without a turn. + h.notify("error", json!({"threadId": "t1", "turnId": "x", "willRetry": false, + "error": {"message": "server spento", "codexErrorInfo": null, "additionalDetails": null}})); + h.wait_for_calls("createForumTopic", 1).await; + h.wait_for_calls("sendMessage", 1).await; + h.notify("thread/closed", json!({"threadId": "t1"})); + let deleted = h.wait_for_calls("deleteForumTopic", 1).await; + assert_eq!(deleted[0]["message_thread_id"], 500); + h.settle().await; + assert!(h.calls("editForumTopic").await.is_empty(), "deleted, not renamed"); + assert_eq!(saved_topics(h.home.path())["topics"], json!([])); +} + +#[tokio::test] +async fn a_failed_close_rename_is_retried() { + let h = Harness::with_topics().await; + Mock::given(method("POST")) + .and(path_regex(".*/editForumTopic$")) + .respond_with(ResponseTemplate::new(500).set_body_json( + json!({"ok": false, "error_code": 500, "description": "Internal Server Error"}), + )) + .up_to_n_times(1) + .with_priority(1) + .mount(&h.telegram) + .await; + h.start_thread("t1", "/tmp/alfa"); + h.notify("turn/started", json!({"threadId": "t1", "turn": turn_json("turn-1", "inProgress")})); + complete_turn(&h, "t1", "turn-1", "Fatto."); + h.wait_for_calls("sendMessage", 1).await; + h.notify("thread/closed", json!({"threadId": "t1"})); + let renames = h.wait_for_calls("editForumTopic", 2).await; + assert_eq!(renames[1]["name"], "alfa · Qwen 3.6 (chiusa)"); + tokio::time::sleep(Duration::from_millis(200)).await; + let saved = saved_topics(h.home.path()); + assert_eq!(saved["topics"][0]["name"], "alfa · Qwen 3.6 (chiusa)"); + assert!(saved["topics"][0].get("pending_name").is_none(), "{saved}"); + assert!(h.calls("deleteForumTopic").await.is_empty()); +} + +#[tokio::test] +async fn a_command_in_a_stray_topic_is_answered_in_the_main_chat_and_the_topic_deleted() { + let h = Harness::with_topics().await; + h.start_thread("t1", "/tmp/alfa"); + h.push_update(topic_message(CHAT, 777, "/sessioni")); + let sends = h.wait_for_calls("sendMessage", 1).await; + assert!(sends[0].get("message_thread_id").is_none(), "{}", sends[0]); + let deleted = h.wait_for_calls("deleteForumTopic", 1).await; + assert_eq!(deleted[0]["message_thread_id"], 777); + assert!(h.calls("createForumTopic").await.is_empty()); +} + +#[tokio::test] +async fn plain_text_in_a_stray_topic_picks_its_session() { + let mut h = Harness::with_topics().await; + h.start_thread("t1", "/tmp/alfa"); + h.settle().await; + + // A new session in the cwd of the most recent one takes the topic. + h.push_update(topic_message(CHAT, 778, "ciao")); + let sends = h.wait_for_calls("sendMessage", 1).await; + assert_eq!(sends[0]["message_thread_id"], 778); + assert_eq!(labels(&sends[0]), vec![vec!["alfa · Qwen 3.6"], vec!["Nuova sessione"]]); + h.push_update(callback(CHAT, &button(&sends[0], "Nuova sessione"))); + let start = h.expect_request("thread/start").await; + assert_eq!(start.params.clone().unwrap()["cwd"], "/tmp/alfa"); + h.respond(start.id, start_response("t3", "/tmp/alfa")); + let turn = h.expect_request("turn/start").await; + let params = turn.params.unwrap(); + assert_eq!(params["threadId"], "t3"); + assert_eq!(params["input"][0]["text"], "ciao"); + let renames = h.wait_for_calls("editForumTopic", 1).await; + assert_eq!(renames[0]["message_thread_id"], 778); + assert_eq!(renames[0]["name"], "alfa · Qwen 3.6"); + + // An existing session without a topic takes the next one. + h.push_update(topic_message(CHAT, 779, "ancora")); + let sends = h.wait_for_calls("sendMessage", 2).await; + h.push_update(callback(CHAT, &button(&sends[1], "alfa · Qwen 3.6"))); + let turn = h.expect_request("turn/start").await; + assert_eq!(turn.params.unwrap()["threadId"], "t1"); + tokio::time::sleep(Duration::from_millis(200)).await; + let saved = saved_topics(h.home.path()); + let threads: Vec<(String, i64)> = saved["topics"] + .as_array() + .unwrap() + .iter() + .map(|e| (e["session"].as_str().unwrap().to_string(), e["thread"].as_i64().unwrap())) + .collect(); + assert_eq!(threads, vec![("t3".to_string(), 778), ("t1".to_string(), 779)]); + assert!(h.calls("createForumTopic").await.is_empty()); + assert!(h.calls("deleteForumTopic").await.is_empty()); +} + +#[tokio::test] +async fn startup_drops_empty_gone_sessions_and_reapplies_pending_renames() { + let home = Arc::new(tempfile::tempdir().unwrap()); + let day = home.path().join("sessions/2026/11/12"); + std::fs::create_dir_all(&day).unwrap(); + std::fs::write(day.join("rollout-2026-11-12T10-00-00-s2.jsonl"), "").unwrap(); + std::fs::write(day.join("rollout-2026-11-12T10-00-00-s4.jsonl"), "").unwrap(); + std::fs::write( + home.path().join(topics::TOPICS_FILE), + json!({"topics": [ + {"chat_id": CHAT, "session": "s1", "thread": 601, "name": "alfa · Qwen 3.6"}, + {"chat_id": CHAT, "session": "s2", "thread": 602, "name": "beta · Qwen 3.6", + "pending_name": "beta · Qwen 3.6 (chiusa)"}, + // Already renamed «(chiusa)» but never had a turn: deleted all the same. + {"chat_id": CHAT, "session": "s3", "thread": 603, "name": "gamma · Qwen 3.6 (chiusa)"}, + // Closed with a turn and nothing pending: kept as it is. + {"chat_id": CHAT, "session": "s4", "thread": 604, "name": "delta · Qwen 3.6 (chiusa)"}, + ], "recent_cwds": []}) + .to_string(), + ) + .unwrap(); + let h = Harness::start_with(Arc::clone(&home), true).await; + let deleted = h.wait_for_calls("deleteForumTopic", 2).await; + let mut threads: Vec = deleted.iter().map(|d| d["message_thread_id"].as_i64().unwrap()).collect(); + threads.sort_unstable(); + assert_eq!(threads, vec![601, 603]); + let renames = h.wait_for_calls("editForumTopic", 1).await; + assert_eq!(renames[0]["message_thread_id"], 602); + assert_eq!(renames[0]["name"], "beta · Qwen 3.6 (chiusa)"); + tokio::time::sleep(Duration::from_millis(200)).await; + let saved = saved_topics(home.path()); + assert_eq!( + saved["topics"], + json!([ + {"chat_id": CHAT, "session": "s2", "thread": 602, "name": "beta · Qwen 3.6 (chiusa)"}, + {"chat_id": CHAT, "session": "s4", "thread": 604, "name": "delta · Qwen 3.6 (chiusa)"}, + ]) + ); + assert_eq!(h.calls("editForumTopic").await.len(), 1, "s4 is not renamed again"); +} + +/// The message id the mock gave to the `index`-th sendMessage (ids start at 1000). +async fn list_message_id(_h: &Harness, index: usize) -> i64 { + 1000 + index as i64 +} + +fn settings_updated(thread: &str, mode: &str, sandbox: &str) -> Value { + json!({"threadId": thread, "threadSettings": { + "cwd": "/tmp/alfa", "approvalPolicy": "never", "approvalsReviewer": "user", + "sandboxPolicy": {"type": sandbox}, "activePermissionProfile": null, + "model": "qwen", "modelProvider": "p", "serviceTier": null, "effort": null, + "summary": null, "personality": null, + "collaborationMode": {"mode": mode, "settings": {"model": "qwen", + "reasoning_effort": null, "developer_instructions": null}}}}) +} + +#[tokio::test] +async fn status_reports_the_session_mode() { + let h = Harness::start().await; + h.start_thread("t1", "/tmp/alfa"); + let cases = [ + ("default", "dangerFullAccess", "Modalità: accesso completo"), + ("plan", "dangerFullAccess", "Modalità: plan"), + ("default", "readOnly", "Modalità: default"), + ]; + for (index, (mode, sandbox, expected)) in cases.into_iter().enumerate() { + h.notify("thread/settings/updated", settings_updated("t1", mode, sandbox)); + h.push_update(text_message(CHAT, "/stato", None)); + let sends = h.wait_for_calls("sendMessage", index + 1).await; + let text = sends[index]["text"].as_str().unwrap(); + assert!(text.contains(expected), "{text}"); + } +} diff --git a/akode-rs/tui/src/app/snapshots/akode_tui__app__daemon_menu__tests__daemon_cli_confirmation.snap b/akode-rs/tui/src/app/snapshots/akode_tui__app__daemon_menu__tests__daemon_cli_confirmation.snap index 979fb9cf..73ce169c 100644 --- a/akode-rs/tui/src/app/snapshots/akode_tui__app__daemon_menu__tests__daemon_cli_confirmation.snap +++ b/akode-rs/tui/src/app/snapshots/akode_tui__app__daemon_menu__tests__daemon_cli_confirmation.snap @@ -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. diff --git a/akode-rs/tui/src/app/snapshots/akode_tui__app__owned_transcript__empty_state_animation_tests__fresh_thread_header.snap b/akode-rs/tui/src/app/snapshots/akode_tui__app__owned_transcript__empty_state_animation_tests__fresh_thread_header.snap index f2fc4ae2..6972792d 100644 --- a/akode-rs/tui/src/app/snapshots/akode_tui__app__owned_transcript__empty_state_animation_tests__fresh_thread_header.snap +++ b/akode-rs/tui/src/app/snapshots/akode_tui__app__owned_transcript__empty_state_animation_tests__fresh_thread_header.snap @@ -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 ██▀████▀██ diff --git a/akode-rs/tui/src/app/snapshots/akode_tui__app__tests__app_server_thread_replacement_clears_previous_transcript_before_replay-2.snap b/akode-rs/tui/src/app/snapshots/akode_tui__app__tests__app_server_thread_replacement_clears_previous_transcript_before_replay-2.snap index 41d0f982..4f388127 100644 --- a/akode-rs/tui/src/app/snapshots/akode_tui__app__tests__app_server_thread_replacement_clears_previous_transcript_before_replay-2.snap +++ b/akode-rs/tui/src/app/snapshots/akode_tui__app__tests__app_server_thread_replacement_clears_previous_transcript_before_replay-2.snap @@ -3,7 +3,7 @@ source: tui/src/app/tests.rs expression: rendered --- - ▄▄████▄▄ aKode v0.2.0 + ▄▄████▄▄ aKode v0.3.1 ██▀▀██▀▀██ gpt-test · mock ██▄▄██▄▄██ ██▀████▀██ diff --git a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__active_reconnect__restored_conversation.snap b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__active_reconnect__restored_conversation.snap index df0ee6c0..06320b63 100644 --- a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__active_reconnect__restored_conversation.snap +++ b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__active_reconnect__restored_conversation.snap @@ -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) diff --git a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__disconnect__rejected_startup_reconnected.snap b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__disconnect__rejected_startup_reconnected.snap index f36d4537..1acdfda9 100644 --- a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__disconnect__rejected_startup_reconnected.snap +++ b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__disconnect__rejected_startup_reconnected.snap @@ -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) diff --git a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_buffered_replay_reconciles_captions.snap b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_buffered_replay_reconciles_captions.snap index 15dea402..20060205 100644 --- a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_buffered_replay_reconciles_captions.snap +++ b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_buffered_replay_reconciles_captions.snap @@ -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 ██▀████▀██ diff --git a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_completed_after_thread_switch.snap b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_completed_after_thread_switch.snap index c01cd7fc..7ea02d65 100644 --- a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_completed_after_thread_switch.snap +++ b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_completed_after_thread_switch.snap @@ -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 ██▀████▀██ diff --git a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_partial_completed_after_thread_switch.snap b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_partial_completed_after_thread_switch.snap index 2556c35c..71d26546 100644 --- a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_partial_completed_after_thread_switch.snap +++ b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_partial_completed_after_thread_switch.snap @@ -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 ██▀████▀██ diff --git a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_replay_reconciles_matching_captions.snap b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_replay_reconciles_matching_captions.snap index 8eb3703d..f96528b6 100644 --- a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_replay_reconciles_matching_captions.snap +++ b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__realtime_requests__voice_replay_reconciles_matching_captions.snap @@ -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 ██▀████▀██ diff --git a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__session_lifecycle_requests__new_session_tests__widget_replacement_preserves_mention_usage_with_history_disabled.snap b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__session_lifecycle_requests__new_session_tests__widget_replacement_preserves_mention_usage_with_history_disabled.snap index 220cf6d0..047b4f93 100644 --- a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__session_lifecycle_requests__new_session_tests__widget_replacement_preserves_mention_usage_with_history_disabled.snap +++ b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__session_lifecycle_requests__new_session_tests__widget_replacement_preserves_mention_usage_with_history_disabled.snap @@ -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 ██▀████▀██ diff --git a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__startup_frame_tests__startup_tip_in_transcript.snap b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__startup_frame_tests__startup_tip_in_transcript.snap index b9263e1e..7a934fc1 100644 --- a/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__startup_frame_tests__startup_tip_in_transcript.snap +++ b/akode-rs/tui/src/app/tests/snapshots/akode_tui__app__tests__startup_frame_tests__startup_tip_in_transcript.snap @@ -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 ██▀████▀██ diff --git a/akode-rs/tui/src/bottom_pane/chat_composer.rs b/akode-rs/tui/src/bottom_pane/chat_composer.rs index 0611433b..da16c7dd 100644 --- a/akode-rs/tui/src/bottom_pane/chat_composer.rs +++ b/akode-rs/tui/src/bottom_pane/chat_composer.rs @@ -1452,13 +1452,21 @@ impl ChatComposer { self.draft.textarea.vim_mode_indicator_span() } - fn mode_indicator_line(&self, show_cycle_hint: bool) -> Option> { + /// 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> { let mut spans: Vec> = 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 diff --git a/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__extension_layout_separate_status_row.snap b/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__extension_layout_separate_status_row.snap new file mode 100644 index 00000000..734fe50a --- /dev/null +++ b/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__extension_layout_separate_status_row.snap @@ -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 diff --git a/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__extension_layout_uses_the_width_left_by_the_mode_indicator_after_resize.snap b/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__extension_layout_uses_the_width_left_by_the_mode_indicator_after_resize.snap index b71c9c99..69dd8ff8 100644 --- a/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__extension_layout_uses_the_width_left_by_the_mode_indicator_after_resize.snap +++ b/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__extension_layout_uses_the_width_left_by_the_mode_indicator_after_resize.snap @@ -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 diff --git a/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__fullscreen_plan_cycle_hint.snap b/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__fullscreen_plan_cycle_hint.snap index a7feeb2a..17d1f064 100644 --- a/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__fullscreen_plan_cycle_hint.snap +++ b/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__fullscreen_plan_cycle_hint.snap @@ -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 diff --git a/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__persistent_status_and_messages.snap b/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__persistent_status_and_messages.snap index fb2db2f7..f8b76a62 100644 --- a/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__persistent_status_and_messages.snap +++ b/akode-rs/tui/src/bottom_pane/chat_composer/snapshots/akode_tui__bottom_pane__chat_composer__status_surface__tests__persistent_status_and_messages.snap @@ -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 diff --git a/akode-rs/tui/src/bottom_pane/chat_composer/status_surface.rs b/akode-rs/tui/src/bottom_pane/chat_composer/status_surface.rs index 79d44b18..3b22f0e9 100644 --- a/akode-rs/tui/src/bottom_pane/chat_composer/status_surface.rs +++ b/akode-rs/tui/src/bottom_pane/chat_composer/status_surface.rs @@ -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 diff --git a/akode-rs/tui/src/bottom_pane/chat_composer/status_surface_tests.rs b/akode-rs/tui/src/bottom_pane/chat_composer/status_surface_tests.rs index f43d966a..703e4cdc 100644 --- a/akode-rs/tui/src/bottom_pane/chat_composer/status_surface_tests.rs +++ b/akode-rs/tui/src/bottom_pane/chat_composer/status_surface_tests.rs @@ -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")); diff --git a/akode-rs/tui/src/bottom_pane/footer.rs b/akode-rs/tui/src/bottom_pane/footer.rs index b56818b0..b70205ac 100644 --- a/akode-rs/tui/src/bottom_pane/footer.rs +++ b/akode-rs/tui/src/bottom_pane/footer.rs @@ -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, show_cycle_hint: bool, ) -> Option> { - 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::>().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!( diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_full.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_full.snap index 2f0410fe..b3dfdefb 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_full.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_full.snap @@ -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 " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_cycle_with_context.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_cycle_with_context.snap index c8d1929d..b136a4ea 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_cycle_with_context.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_cycle_with_context.snap @@ -10,4 +10,4 @@ expression: terminal.backend() " " " " " " -" Plan mode (⇧tab to cycle) 100% context left " +" ⏸ plan mode attivo · ? for shortcuts " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_cycle_without_context.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_cycle_without_context.snap index 0f10aa65..cd808828 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_cycle_without_context.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_cycle_without_context.snap @@ -10,4 +10,4 @@ expression: terminal.backend() " " " " " " -" Plan mode (⇧tab to cycle) " +" ⏸ plan mode attivo · ? for shortcuts " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_only.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_only.snap index e64bcb3b..660d810c 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_only.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_empty_mode_only.snap @@ -10,4 +10,4 @@ expression: terminal.backend() " " " " " " -" Plan mode " +" ⏸ plan mode attivo " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_full.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_full.snap index 5f0f3538..6c428050 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_full.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_full.snap @@ -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 " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_message_without_context.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_message_without_context.snap index 017e3eb2..136a9405 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_message_without_context.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_message_without_context.snap @@ -10,4 +10,4 @@ expression: terminal.backend() " " " " " " -" tab to queue message · Plan mode " +" ⏸ plan mode attivo · tab to queue " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_mode_only.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_mode_only.snap index 35a94ac7..24929ff2 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_mode_only.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_mode_only.snap @@ -10,4 +10,4 @@ expression: terminal.backend() " " " " " " -" Plan mode " +" ⏸ plan mode attivo" diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_short_with_context.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_short_with_context.snap index 77f38dc4..b9a561f5 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_short_with_context.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_short_with_context.snap @@ -10,4 +10,4 @@ expression: terminal.backend() " " " " " " -" tab to queue · Plan mode 98% context left " +" ⏸ plan mode attivo · tab to queue message " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_short_without_context.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_short_without_context.snap index 91f917e9..62097113 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_short_without_context.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__chat_composer__tests__footer_collapse_plan_queue_short_without_context.snap @@ -10,4 +10,4 @@ expression: terminal.backend() " " " " " " -" tab to queue · Plan mode " +" ⏸ plan mode attivo " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_120.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_120.snap new file mode 100644 index 00000000..d2c63f41 --- /dev/null +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_120.snap @@ -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 " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_24.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_24.snap new file mode 100644 index 00000000..cdb62279 --- /dev/null +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_24.snap @@ -0,0 +1,5 @@ +--- +source: tui/src/bottom_pane/footer.rs +expression: terminal.backend() +--- +" accesso completo " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_40.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_40.snap new file mode 100644 index 00000000..7e181c4d --- /dev/null +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_40.snap @@ -0,0 +1,5 @@ +--- +source: tui/src/bottom_pane/footer.rs +expression: terminal.backend() +--- +" ⏵⏵ accesso completo attivo " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_80.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_80.snap new file mode 100644 index 00000000..accb15d0 --- /dev/null +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_accesso_completo_80.snap @@ -0,0 +1,5 @@ +--- +source: tui/src/bottom_pane/footer.rs +expression: terminal.backend() +--- +" ⏵⏵ accesso completo attivo · ? for shortcuts " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_120.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_120.snap new file mode 100644 index 00000000..91de2ed0 --- /dev/null +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_120.snap @@ -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 " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_24.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_24.snap new file mode 100644 index 00000000..f30f1c76 --- /dev/null +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_24.snap @@ -0,0 +1,5 @@ +--- +source: tui/src/bottom_pane/footer.rs +expression: terminal.backend() +--- +" ⏸ plan mode attivo " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_40.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_40.snap new file mode 100644 index 00000000..71f41bd8 --- /dev/null +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_40.snap @@ -0,0 +1,5 @@ +--- +source: tui/src/bottom_pane/footer.rs +expression: terminal.backend() +--- +" ⏸ plan mode attivo · ? for shortcuts " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_80.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_80.snap new file mode 100644 index 00000000..3f8638f6 --- /dev/null +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_cycle_plan_80.snap @@ -0,0 +1,5 @@ +--- +source: tui/src/bottom_pane/footer.rs +expression: terminal.backend() +--- +" ⏸ plan mode attivo · ? for shortcuts " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_narrow_overlap_hides.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_narrow_overlap_hides.snap index 2df60d95..71f41bd8 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_narrow_overlap_hides.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_narrow_overlap_hides.snap @@ -2,4 +2,4 @@ source: tui/src/bottom_pane/footer.rs expression: terminal.backend() --- -" Plan mode (⇧tab to cycle) " +" ⏸ plan mode attivo · ? for shortcuts " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_running_hides_hint.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_running_hides_hint.snap index 9f9be080..b5f4f9ce 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_running_hides_hint.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_running_hides_hint.snap @@ -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 " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_wide.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_wide.snap index bc04d167..91de2ed0 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_wide.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_mode_indicator_wide.snap @@ -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 " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_disabled_context_right.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_disabled_context_right.snap index df995888..11070d2e 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_disabled_context_right.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_disabled_context_right.snap @@ -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 " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_enabled_mode_and_ide_context_right.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_enabled_mode_and_ide_context_right.snap index b0160e6e..27ea4791 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_enabled_mode_and_ide_context_right.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_enabled_mode_and_ide_context_right.snap @@ -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 " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_enabled_mode_right.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_enabled_mode_right.snap index 95790299..d7aec2a6 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_enabled_mode_right.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_enabled_mode_right.snap @@ -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) " diff --git a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_truncated_with_gap.snap b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_truncated_with_gap.snap index cef1531f..d08cae48 100644 --- a/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_truncated_with_gap.snap +++ b/akode-rs/tui/src/bottom_pane/snapshots/akode_tui__bottom_pane__footer__tests__footer_status_line_truncated_with_gap.snap @@ -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 " diff --git a/akode-rs/tui/src/chatwidget.rs b/akode-rs/tui/src/chatwidget.rs index 9e29b9dd..c25a405f 100644 --- a/akode-rs/tui/src/chatwidget.rs +++ b/akode-rs/tui/src/chatwidget.rs @@ -671,6 +671,8 @@ pub(crate) struct ChatWidget { /// Ignore a held key after it dismisses the preset submenu. quick_dial_menu_key_guard: Option, permission_shortcut_pending: bool, + /// Permissions in use before Shift+Tab entered full access, restored when it leaves it. + mode_cycle_restore: Option, // Pending notification to show when unfocused on next Draw pub(crate) pending_notification: Option, /// When `Some`, the user has pressed a quit shortcut and the second press diff --git a/akode-rs/tui/src/chatwidget/constructor.rs b/akode-rs/tui/src/chatwidget/constructor.rs index 3dfcaa2d..409b65eb 100644 --- a/akode-rs/tui/src/chatwidget/constructor.rs +++ b/akode-rs/tui/src/chatwidget/constructor.rs @@ -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, diff --git a/akode-rs/tui/src/chatwidget/rendering.rs b/akode-rs/tui/src/chatwidget/rendering.rs index 9788345f..7a8a37b7 100644 --- a/akode-rs/tui/src/chatwidget/rendering.rs +++ b/akode-rs/tui/src/chatwidget/rendering.rs @@ -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())) diff --git a/akode-rs/tui/src/chatwidget/settings.rs b/akode-rs/tui/src/chatwidget/settings.rs index 2d0dab47..30e3df27 100644 --- a/akode-rs/tui/src/chatwidget/settings.rs +++ b/akode-rs/tui/src/chatwidget/settings.rs @@ -513,12 +513,15 @@ impl ChatWidget { .then_some(active_mode.display_name()) } - fn collaboration_mode_indicator(&self) -> Option { + pub(super) fn collaboration_mode_indicator(&self) -> Option { 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 { + 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 { + 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) { diff --git a/akode-rs/tui/src/chatwidget/snapshots/akode_tui__chatwidget__tests__reasoning_shortcut_max_plan_footer.snap b/akode-rs/tui/src/chatwidget/snapshots/akode_tui__chatwidget__tests__reasoning_shortcut_max_plan_footer.snap index 491d005a..dfcab4e9 100644 --- a/akode-rs/tui/src/chatwidget/snapshots/akode_tui__chatwidget__tests__reasoning_shortcut_max_plan_footer.snap +++ b/akode-rs/tui/src/chatwidget/snapshots/akode_tui__chatwidget__tests__reasoning_shortcut_max_plan_footer.snap @@ -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 " diff --git a/akode-rs/tui/src/chatwidget/snapshots/akode_tui__chatwidget__tests__status_line_model_with_reasoning_plan_mode_footer.snap b/akode-rs/tui/src/chatwidget/snapshots/akode_tui__chatwidget__tests__status_line_model_with_reasoning_plan_mode_footer.snap index 710d5046..a6ac81e7 100644 --- a/akode-rs/tui/src/chatwidget/snapshots/akode_tui__chatwidget__tests__status_line_model_with_reasoning_plan_mode_footer.snap +++ b/akode-rs/tui/src/chatwidget/snapshots/akode_tui__chatwidget__tests__status_line_model_with_reasoning_plan_mode_footer.snap @@ -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 " diff --git a/akode-rs/tui/src/chatwidget/status_surfaces.rs b/akode-rs/tui/src/chatwidget/status_surfaces.rs index 807005f6..cb68c61b 100644 --- a/akode-rs/tui/src/chatwidget/status_surfaces.rs +++ b/akode-rs/tui/src/chatwidget/status_surfaces.rs @@ -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(); diff --git a/akode-rs/tui/src/chatwidget/tests.rs b/akode-rs/tui/src/chatwidget/tests.rs index daa1c964..3043ba86 100644 --- a/akode-rs/tui/src/chatwidget/tests.rs +++ b/akode-rs/tui/src/chatwidget/tests.rs @@ -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"] diff --git a/akode-rs/tui/src/chatwidget/tests/mode_cycle_tests.rs b/akode-rs/tui/src/chatwidget/tests/mode_cycle_tests.rs new file mode 100644 index 00000000..de2c0847 --- /dev/null +++ b/akode-rs/tui/src/chatwidget/tests/mode_cycle_tests.rs @@ -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) -> Vec { + 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); +} diff --git a/akode-rs/tui/src/history_cell/snapshots/akode_tui__history_cell__tests__session_info_availability_nux_tooltip_snapshot.snap b/akode-rs/tui/src/history_cell/snapshots/akode_tui__history_cell__tests__session_info_availability_nux_tooltip_snapshot.snap index f22d9783..785d0738 100644 --- a/akode-rs/tui/src/history_cell/snapshots/akode_tui__history_cell__tests__session_info_availability_nux_tooltip_snapshot.snap +++ b/akode-rs/tui/src/history_cell/snapshots/akode_tui__history_cell__tests__session_info_availability_nux_tooltip_snapshot.snap @@ -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 ██▀████▀██ diff --git a/akode-rs/tui/src/onboarding/snapshots/akode_tui__onboarding__setup_wizard__tests__setup_theme_120.snap b/akode-rs/tui/src/onboarding/snapshots/akode_tui__onboarding__setup_wizard__tests__setup_theme_120.snap index f8b3c4c0..9ca84670 100644 --- a/akode-rs/tui/src/onboarding/snapshots/akode_tui__onboarding__setup_wizard__tests__setup_theme_120.snap +++ b/akode-rs/tui/src/onboarding/snapshots/akode_tui__onboarding__setup_wizard__tests__setup_theme_120.snap @@ -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 │ ██▀████▀██ diff --git a/akode-rs/tui/src/onboarding/snapshots/akode_tui__onboarding__setup_wizard__tests__setup_theme_80.snap b/akode-rs/tui/src/onboarding/snapshots/akode_tui__onboarding__setup_wizard__tests__setup_theme_80.snap index f389bbd1..7eec59b9 100644 --- a/akode-rs/tui/src/onboarding/snapshots/akode_tui__onboarding__setup_wizard__tests__setup_theme_80.snap +++ b/akode-rs/tui/src/onboarding/snapshots/akode_tui__onboarding__setup_wizard__tests__setup_theme_80.snap @@ -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 │ ██▀████▀██ diff --git a/akode-rs/tui/src/snapshots/akode_tui__app_server_session__tests__resumed_plan_mode.snap b/akode-rs/tui/src/snapshots/akode_tui__app_server_session__tests__resumed_plan_mode.snap index 5a223294..f02ebc59 100644 --- a/akode-rs/tui/src/snapshots/akode_tui__app_server_session__tests__resumed_plan_mode.snap +++ b/akode-rs/tui/src/snapshots/akode_tui__app_server_session__tests__resumed_plan_mode.snap @@ -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 diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_cached_limits_hide_credits_without_flag.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_cached_limits_hide_credits_without_flag.snap index cd359807..d4298c65 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_cached_limits_hide_credits_without_flag.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_cached_limits_hide_credits_without_flag.snap @@ -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]] diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_credits_and_limits.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_credits_and_limits.snap index 7d4df48e..d1f05518 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_credits_and_limits.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_credits_and_limits.snap @@ -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]] diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_forked_from.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_forked_from.snap index 1d8a6a98..64d77895 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_forked_from.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_forked_from.snap @@ -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]] diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_monthly_limit.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_monthly_limit.snap index e5f6ef40..23949d4a 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_monthly_limit.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_monthly_limit.snap @@ -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]] diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_reasoning_details.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_reasoning_details.snap index 672817dc..2279dd1f 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_reasoning_details.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_includes_reasoning_details.snap @@ -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]] diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_local_background_server.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_local_background_server.snap index c9be0fc3..1c420d67 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_local_background_server.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_local_background_server.snap @@ -4,7 +4,7 @@ expression: sanitized --- /status - >_ aKode (v0.2.0) + >_ aKode (v0.3.1) Server: Local background server diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_remote_server.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_remote_server.snap index 58b61119..301e800f 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_remote_server.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_remote_server.snap @@ -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) diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_active_user_defined_profile.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_active_user_defined_profile.snap index 757a6b21..d2f0bc2a 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_active_user_defined_profile.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_active_user_defined_profile.snap @@ -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]] diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_auto_review_permissions.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_auto_review_permissions.snap index 545ad5d6..a1d4bc4f 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_auto_review_permissions.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_auto_review_permissions.snap @@ -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]] diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_missing_limits_message.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_missing_limits_message.snap index ca0ea776..4c0781c5 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_missing_limits_message.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_missing_limits_message.snap @@ -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]] diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_stale_limits_message.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_stale_limits_message.snap index b7af64b7..93b1dedb 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_stale_limits_message.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_stale_limits_message.snap @@ -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]] diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_unavailable_limits_message.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_unavailable_limits_message.snap index 749c910d..e92c3628 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_unavailable_limits_message.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_shows_unavailable_limits_message.snap @@ -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]] diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_truncates_halfwidth_kana_in_narrow_terminal.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_truncates_halfwidth_kana_in_narrow_terminal.snap index d5e08dcb..44e067ab 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_truncates_halfwidth_kana_in_narrow_terminal.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_truncates_halfwidth_kana_in_narrow_terminal.snap @@ -4,7 +4,7 @@ expression: sanitized --- /status - >_ aKode (v0.2.0) + >_ aKode (v0.3.1) Model: ガパガパガパガ パ-model (reasoning diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_truncates_in_narrow_terminal.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_truncates_in_narrow_terminal.snap index 7ad27649..26fea45a 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_truncates_in_narrow_terminal.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_truncates_in_narrow_terminal.snap @@ -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) diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_uses_default_reasoning_when_config_empty.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_uses_default_reasoning_when_config_empty.snap index bc9c25b7..185d9849 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_uses_default_reasoning_when_config_empty.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_uses_default_reasoning_when_config_empty.snap @@ -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]] diff --git a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_uses_generic_limit_labels_for_unsupported_windows.snap b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_uses_generic_limit_labels_for_unsupported_windows.snap index 76d11b76..6607bd65 100644 --- a/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_uses_generic_limit_labels_for_unsupported_windows.snap +++ b/akode-rs/tui/src/status/snapshots/akode_tui__status__tests__status_snapshot_uses_generic_limit_labels_for_unsupported_windows.snap @@ -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]]