diff --git a/app/ui/shell/shell.ts b/app/ui/shell/shell.ts index 0ceff2d1..51713fb1 100644 --- a/app/ui/shell/shell.ts +++ b/app/ui/shell/shell.ts @@ -1957,9 +1957,8 @@ class Shell { }, }); } - // Close current app sits first but the menu opens on Focus app switcher, so a - // reflexive tap never closes the window. - const initialSelection = items.length; + // Prefer closing the current app; pinned windows fall back to the switcher. + const initialSelection = 0; items.push( { // Defocus the app (hand focus to the sidebar) without closing it: the diff --git a/docs/validation-app-switcher-menu.md b/docs/validation-app-switcher-menu.md index 7ae0334f..45f87115 100644 --- a/docs/validation-app-switcher-menu.md +++ b/docs/validation-app-switcher-menu.md @@ -10,8 +10,7 @@ is closeable. It is absent for the pinned launcher (the large application grid). multiple windows belonging to one app. Pinned windows remain available. Both actions reuse the shell's normal close/cleanup path. The menu closes before -the windows do, and focus returns to the switcher. It opens on “Focus app switcher” -to avoid an accidental close. With no closeable windows, “Close all apps” is disabled. +the windows do, and focus returns to the switcher. It selects “Close current app” by default when available, otherwise “Focus app switcher”. With no closeable windows, “Close all apps” is disabled. No new preferences or persistence format are introduced. Software: `tests/app-switcher-menu.test.cjs` covers both gestures, apps claiming @@ -27,7 +26,7 @@ Manual validation on glasses remains pending: 4. Use “Close all apps”; verify the launcher remains usable and apps can reopen. 5. Repeat for left/right/bottom/popup switcher positions and with a running game, a hold-to-talk app and an app exposing multiple windows. -6. Check cancel/back and the initial selection do not close anything. Check both +6. Check cancel/back closes nothing; confirming the initial selection closes the current app when available. Check both menu gestures still work normally when focus is inside an app. Closing windows retains each app's existing lifecycle semantics; it does not diff --git a/tests/app-switcher-menu.test.cjs b/tests/app-switcher-menu.test.cjs index ff461063..cbfb6f6b 100644 --- a/tests/app-switcher-menu.test.cjs +++ b/tests/app-switcher-menu.test.cjs @@ -151,7 +151,7 @@ test('switcher opens its menu on hold or tap-hold even for an app claiming holds assert.ok(h.menu()); assert.ok(h.menu().items.some(item => item.label === 'Close current app')); assert.ok(h.menu().items.some(item => item.label === 'Close all apps')); - assert.equal(h.menu().items[h.menu().selectedIndex].label, 'Focus app switcher'); + assert.equal(h.menu().items[h.menu().selectedIndex].label, 'Close current app'); assert.deepEqual(h.delivered, [['current', 'system-menu-opened']]); assert.equal(h.s.escapeStarted, undefined); assert.equal(h.s.focus, 'sidebar'); @@ -163,7 +163,7 @@ test('close current app closes the captured window and preserves the launcher an const h = fixture(); await h.input('long-press'); h.s.selectedIndex = 2; // An asynchronous focus change must not redirect the close action. - h.choose('Close current app'); + h.menu().items[h.menu().selectedIndex].onSelect({ stack: h.s.stack }); assert.deepEqual(h.closed, ['current']); assert.deepEqual(h.s.windows.map(w => w.windowId), ['launcher', 'background']); assert.equal(h.s.focus, 'sidebar'); @@ -175,6 +175,7 @@ test('launcher offers close all but never close current; close all leaves only t h.s.selectedIndex = 0; await h.input('short-then-long-press'); assert.ok(!h.menu().items.some(item => item.label === 'Close current app')); + assert.equal(h.menu().items[h.menu().selectedIndex].label, 'Focus app switcher'); h.choose('Close all apps'); assert.deepEqual(h.closed, ['current', 'background']); assert.deepEqual(h.s.windows.map(w => w.windowId), ['launcher']); @@ -196,10 +197,10 @@ test('close all uses normal cleanup despite reentrant removal, multiple windows assert.equal(h.s.foregroundWindow().windowId, 'launcher'); }); -test('default selection and cancel do not close apps; an open overlay never receives a second menu', async () => { +test('focusing switcher and cancelling do not close apps; an open overlay never receives a second menu', async () => { const h = fixture(); await h.input('long-press'); - h.choose(h.menu().items[h.menu().selectedIndex].label); + h.choose('Focus app switcher'); assert.deepEqual(h.closed, []); await h.input('long-press'); const menu = h.menu();