···12491249 webview.goBack();
12501250 return { handled: true };
12511251 }
12521252+ // In group mode, ESC at root should close this page and return to the group view.
12531253+ // The backend escPolicy returns 'nothing' for content windows in active sessions,
12541254+ // so we must close the window directly from the renderer.
12551255+ if (currentMode === 'group') {
12561256+ DEBUG && console.log('[page] ESC: group mode at root, closing window');
12571257+ window.close();
12581258+ return { handled: true };
12591259+ }
12521260 DEBUG && console.log('[page] ESC: at root, letting backend decide');
12531261 return { handled: false };
12541262});
+15-3
extensions/groups/home.js
···8585 untaggedCount: 0,
8686 selectedIndex: 0,
8787 searchQuery: '',
8888- showAllTags: false
8888+ showAllTags: false,
8989+ lastViewedTagId: null
8990};
90919192// Expose state for debugging in tests
···601602 * Show the groups (tags) view
602603 */
603604const showGroups = async () => {
605605+ // Remember which group was being viewed so we can focus it in the list
606606+ if (state.currentTag) {
607607+ state.lastViewedTagId = state.currentTag.id;
608608+ }
604609 state.view = VIEW_GROUPS;
605610 state.currentTag = null;
606611 state.searchQuery = '';
···694699 }
695700 }
696701697697- // Reset selection
698698- state.selectedIndex = 0;
702702+ // Select the last-viewed group if returning from addresses view, otherwise reset to 0
703703+ if (state.lastViewedTagId) {
704704+ const cards = Array.from(container.querySelectorAll('peek-card'));
705705+ const targetIndex = cards.findIndex(card => card.dataset.tagId === String(state.lastViewedTagId));
706706+ state.selectedIndex = targetIndex >= 0 ? targetIndex : 0;
707707+ state.lastViewedTagId = null;
708708+ } else {
709709+ state.selectedIndex = 0;
710710+ }
699711 updateSelection();
700712};
701713