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 — fix: invalidate full-auto offers at BTW session boundaries · Twigpine/zero@535a80b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • internal
    • cli
      • root_flag_order_test.go
    • tui
      • btw.go
      • btw_test.go
      • model.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎internal/cli/root_flag_order_test.go‎

Copy file name to clipboardExpand all lines: internal/cli/root_flag_order_test.go
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func rootFlagOrderings(groups [][]string) [][]string {
3535
// order the operator wrote them in load-bearing: `zero --allow-escalation
3636
// --theme auto` stranded `--theme auto` as an unknown command and exited with
3737
// an argument error instead of launching. Every ordering of the three root
38-
// flags, with --skip-permissions-unsafe absent or at any position, has to reach
39-
// the TUI with all three applied.
38+
// flags, with either spelling of --full-auto at any position or omitted, has
39+
// to reach the TUI with all three applied.
4040
func TestRootFlagsComposeInAnyOrder(t *testing.T) {
4141
extra := t.TempDir()
4242
resolvedExtra, err := filepath.EvalSymlinks(extra)
@@ -45,16 +45,18 @@ func TestRootFlagsComposeInAnyOrder(t *testing.T) {
4545
}
4646
groups := [][]string{{"--add-dir", extra}, {"--theme", "auto"}, {"--allow-escalation"}}
4747
cases := rootFlagOrderings(groups)
48-
cases = append(cases, rootFlagOrderings(append(groups, []string{"--skip-permissions-unsafe"}))...)
49-
if len(cases) != 6+24 {
50-
t.Fatalf("SETUP INVALID: %d orderings, want 30", len(cases))
48+
for _, flag := range []string{"--full-auto", "--skip-permissions-unsafe"} {
49+
cases = append(cases, rootFlagOrderings(append(groups, []string{flag}))...)
50+
}
51+
if len(cases) != 6+2*24 {
52+
t.Fatalf("SETUP INVALID: %d orderings, want 54", len(cases))
5153
}
5254
for _, args := range cases {
5355
t.Run(strings.Join(args, " "), func(t *testing.T) {
5456
options := captureTUIOptions(t, args...)
5557
wantMode := agent.PermissionModeAsk
5658
for _, arg := range args {
57-
if arg == "--skip-permissions-unsafe" {
59+
if arg == "--full-auto" || arg == "--skip-permissions-unsafe" {
5860
wantMode = agent.PermissionModeFullAuto
5961
}
6062
}
Collapse file

‎internal/tui/btw.go‎

Copy file name to clipboardExpand all lines: internal/tui/btw.go
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ func (m model) handleBTWCommand(question string) (model, tea.Cmd) {
7373
// Foreground loops are session-scoped. Stop them only after the side session
7474
// is ready, so a failed fork cannot destroy work in the main session.
7575
parent := m
76+
// The offer belongs to the foreground surface. Clear it before copying the
77+
// side model so neither the fork nor the saved parent can carry it forward.
78+
parent.unsafeArmed = false
7679
clearedLoops := 0
7780
if updated, cleared := parent.clearLoopsForSessionSwitch(); cleared > 0 {
7881
parent = updated
@@ -344,6 +347,9 @@ func (m model) refreshHiddenParentFileView() (model, tea.Cmd) {
344347
}
345348

346349
func (m model) routeBTWMessageToParent(msg tea.Msg) (model, tea.Cmd, bool) {
350+
// Cross-session delivery ends the offer on the visible side. The hidden
351+
// parent's update cannot clear the side model's confirmation state.
352+
m.unsafeArmed = false
347353
parentNext, cmd := m.btw.parent.updateModel(msg)
348354
parent, ok := parentNext.(model)
349355
if !ok {
Collapse file

‎internal/tui/btw_test.go‎

Copy file name to clipboardExpand all lines: internal/tui/btw_test.go
+90Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
tea "charm.land/bubbletea/v2"
1313

14+
"github.com/Twigpine/zero/internal/agent"
1415
"github.com/Twigpine/zero/internal/config"
1516
"github.com/Twigpine/zero/internal/notify"
1617
"github.com/Twigpine/zero/internal/sessions"
@@ -113,6 +114,95 @@ func TestBTWCreatesIsolatedForkAndReturnsWithoutMerge(t *testing.T) {
113114
}
114115
}
115116

117+
func TestBTWForkDiscardsFullAutoOffer(t *testing.T) {
118+
main := newBTWTestModel(t)
119+
main.width = 96
120+
main.permissionMode = agent.PermissionModeAsk
121+
main = pressKey(t, main, tea.Key(testKeyShift(tea.KeyTab)))
122+
if !main.offerOwnsStatusChip() {
123+
t.Fatal("expected a live full-auto offer on main")
124+
}
125+
126+
// Test the fork boundary directly. The Enter key would clear the offer
127+
// before calling it, masking an offer copied into the fork or saved parent.
128+
side, _ := main.handleBTWCommand("")
129+
if !side.btw.active || side.btw.parent == nil {
130+
t.Fatal("expected a BTW fork")
131+
}
132+
confirmed, _ := side.Update(testKeyCtrl('g'))
133+
if got := confirmed.(model).permissionMode; got != agent.PermissionModeAsk {
134+
t.Errorf("Ctrl+G after forking = %s, want ask", got)
135+
}
136+
restored, _ := side.Update(testKeyCtrl('c'))
137+
if restored.(model).btw.active {
138+
t.Fatal("expected Ctrl+C to restore main")
139+
}
140+
confirmed, _ = restored.Update(testKeyCtrl('g'))
141+
if got := confirmed.(model).permissionMode; got != agent.PermissionModeAsk {
142+
t.Errorf("Ctrl+G after restoring main = %s, want ask", got)
143+
}
144+
}
145+
146+
func TestBTWParentDeliveryCancelsFullAutoOffer(t *testing.T) {
147+
const mainRunID = 7
148+
for _, tc := range []struct {
149+
name string
150+
msg tea.Msg
151+
parentNeedsInput bool
152+
}{
153+
{
154+
name: "completion",
155+
msg: agentResponseMsg{runID: mainRunID},
156+
},
157+
{
158+
name: "permission request",
159+
msg: permissionRequestMsg{
160+
runID: mainRunID,
161+
request: testPromptPermissionRequest(),
162+
},
163+
parentNeedsInput: true,
164+
},
165+
} {
166+
t.Run(tc.name, func(t *testing.T) {
167+
main := newBTWTestModel(t)
168+
main.width = 96
169+
main.permissionMode = agent.PermissionModeAsk
170+
main.runID, main.activeRunID, main.pending = mainRunID, mainRunID, true
171+
side, _ := main.handleBTWCommand("")
172+
if !side.btw.active || side.btw.parent == nil {
173+
t.Fatal("expected a BTW fork with main still running")
174+
}
175+
updated, _ := side.Update(testKeyShift(tea.KeyTab))
176+
side = updated.(model)
177+
if !side.offerOwnsStatusChip() {
178+
t.Fatal("expected a live full-auto offer in BTW")
179+
}
180+
181+
updated, _ = side.Update(tc.msg)
182+
side = updated.(model)
183+
parent := side.btw.parent
184+
if parent == nil || parent.pending != tc.parentNeedsInput ||
185+
(parent.pendingPermission != nil) != tc.parentNeedsInput {
186+
t.Fatal("delivery did not update the hidden main session")
187+
}
188+
if side.pendingPermission != nil {
189+
t.Fatal("main permission prompt leaked into BTW")
190+
}
191+
updated, _ = side.Update(testKeyCtrl('g'))
192+
side = updated.(model)
193+
if side.permissionMode != agent.PermissionModeAsk {
194+
t.Fatalf("Ctrl+G after main delivery = %s, want ask", side.permissionMode)
195+
}
196+
197+
updated, _ = side.Update(testKeyShift(tea.KeyTab))
198+
updated, _ = updated.Update(testKeyCtrl('g'))
199+
if got := updated.(model).permissionMode; got != agent.PermissionModeFullAuto {
200+
t.Errorf("Ctrl+G after a fresh BTW offer = %s, want full-auto", got)
201+
}
202+
})
203+
}
204+
}
205+
116206
func TestBTWCanOpenWhileParentRunContinues(t *testing.T) {
117207
m := newBTWTestModel(t)
118208
m.pending = true
Collapse file

‎internal/tui/model.go‎

Copy file name to clipboardExpand all lines: internal/tui/model.go
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,8 @@ func (m model) updateModel(msg tea.Msg) (tea.Model, tea.Cmd) {
14941494
if next, cmd, routed := m.routeBTWParentMessage(msg); routed {
14951495
return next, batchCommands(cmd, resizeCmd)
14961496
}
1497-
// CROSS-SESSION TRAFFIC ENDS A FULL-AUTO OFFER, every kind of it.
1497+
// CROSS-SESSION TRAFFIC ENDS A FULL-AUTO OFFER. BTW parent deliveries
1498+
// are handled by the router above. Peer deliveries continue here.
14981499
//
14991500
// The offer is valid only until the next user-visible input transition,
15001501
// whatever delivers it (see sttPartialMsg below). Paste, blur, mouse, the

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.