GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test(tui): move the plan-mode guard onto advancePermissionMode · Twigpine/zero@0dd1a5b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • internal/tui
    • plan_mode_test.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎internal/tui/plan_mode_test.go‎

Copy file name to clipboardExpand all lines: internal/tui/plan_mode_test.go
+20-6Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,27 @@ func TestPlanCommandOnTwiceDoesNotClobberSavedMode(t *testing.T) {
119119
}
120120
}
121121

122-
// TestNextPermissionModeLeavesPlanUntouched confirms the shift+tab Auto<->Ask
123-
// toggle cannot silently exit plan mode: folding Plan to Ask would be a LESS
124-
// strict landing (Ask still permits write/shell tools with a prompt), so the
125-
// read-only guarantee must only be given up via the explicit /plan off exit.
122+
// TestNextPermissionModeLeavesPlanUntouched confirms the shift+tab cycle cannot
123+
// silently exit plan mode: folding Plan to Ask would be a LESS strict landing
124+
// (Ask still permits write/shell tools with a prompt), so the read-only
125+
// guarantee must only be given up via the explicit /plan off exit.
126+
//
127+
// The second return value matters as much as the first. Plan must never carry a
128+
// full-auto OFFER either, or two presses from Plan would reach the one mode that
129+
// turns permission prompts off entirely, starting from the one mode that
130+
// promises no mutation at all.
126131
func TestNextPermissionModeLeavesPlanUntouched(t *testing.T) {
127-
if got := nextPermissionMode(agent.PermissionModePlan); got != agent.PermissionModePlan {
128-
t.Fatalf("nextPermissionMode(Plan) = %s, want Plan unchanged", got)
132+
got, offered := advancePermissionMode(agent.PermissionModePlan, false)
133+
if got != agent.PermissionModePlan {
134+
t.Fatalf("advancePermissionMode(Plan) = %s, want Plan unchanged", got)
135+
}
136+
if offered {
137+
t.Fatal("shift+tab from Plan offered full-auto, so a second press would leave read-only mode for the least strict one")
138+
}
139+
// And from a live offer, which is the state a stray earlier press can leave
140+
// behind: still Plan, still no offer.
141+
if got, offered = advancePermissionMode(agent.PermissionModePlan, true); got != agent.PermissionModePlan || offered {
142+
t.Fatalf("advancePermissionMode(Plan, offered) = %s/%v, want Plan/false", got, offered)
129143
}
130144
}
131145

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.