Skip to content

fix: preserve safety modes across session flows - #3848

Merged
dgageot merged 1 commit into
mainfrom
fix/safety-mode-state-and-tui
Jul 27, 2026
Merged

fix: preserve safety modes across session flows#3848
dgageot merged 1 commit into
mainfrom
fix/safety-mode-state-and-tui

Conversation

@Sayt-0

@Sayt-0 Sayt-0 commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

  • preserve stored autonomous and legacy approval state during plain session resume
  • carry explicit safety policy and YOLO toggle-back state through /new
  • keep wrapped tool-confirmation actions clickable across terminal widths
  • synchronize the cached YOLO indicator when a confirmation switches the session to Balanced

Context

Follow-up to #3835. The safety-mode implementation introduced session-state preservation gaps and two classic TUI regressions around wrapped confirmation actions and Balanced-mode state display.

Changes

Area Fix
Session resume Safety state changes only when --safety or --yolo is explicitly supplied. Plain resume preserves both explicit autonomous state and legacy tools_approved state.
/new Preserves effective SafetyPolicy and PriorSafetyPolicy, including toggle-back behavior after an Autonomous escalation.
Confirmation TUI Lays out complete action segments across rows, uses terminal-cell hit maps, truncates display-only labels when necessary, and preserves the full permission pattern.
YOLO indicator Clears cached YOLO state when selecting Balanced from a hook-forced confirmation.

Validation

  • go build ./...
  • go test ./pkg/tui/... ./pkg/leantui/... ./cmd/root/... ./pkg/app/...
  • go test -race ./pkg/tui/dialog ./pkg/tui/components/toolconfirm ./cmd/root ./pkg/app
  • go vet ./pkg/tui/... ./pkg/leantui/... ./cmd/root/... ./pkg/app/...
  • golangci-lint run
  • go run ./lint .
  • go mod tidy --diff

Full go test ./... was also run. Only environment-specific SSRF tests failed in pkg/config, pkg/httpclient, and pkg/tools/builtin/{api,fetch,openapi} because private-address traffic is intercepted by the sandbox network; all changed and related packages passed.

Keep autonomous and legacy approval state coherent when resuming sessions, and carry explicit safety policies through /new.

Make wrapped confirmation actions reliably clickable and synchronize the cached YOLO indicator when switching to balanced mode.
@Sayt-0
Sayt-0 requested a review from a team as a code owner July 27, 2026 12:28
@aheritier aheritier added area/cli CLI commands, flags, output formatting area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Jul 27, 2026
@dgageot
dgageot merged commit 617708c into main Jul 27, 2026
14 checks passed
@dgageot
dgageot deleted the fix/safety-mode-state-and-tui branch July 27, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli CLI commands, flags, output formatting area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants