App menu: the titlebar's "Settings and more" (Alt+F, F10, the palette, the account menu's last row) with rows from the site config; page zoom per tab in the host

Frame: AppMenu.tsx is a menu at the end of the titlebar cluster (before the caption buttons; macOS has none there). Its rows are `ShellSite.menu`: ordered groups of built-in rows by name and the app's own ({id, label, icon, shortcut, hint, when, checked, run | submenu}); `DEFAULT_MENU`, `menuWith` and `menuWithout` order, add and remove. A built-in row shows only when the app serves it (decks, `menu.languages`, themes, `menu.modes`, and `features`: zoom, store, workspaces, developer, updates), so no app gets a dead row. Language, Theme, Mode, Workspaces and Developer are submenus; Language and Theme apply live and keep the menu open, Mode asks the same keep-my-changes question as Settings (panel `menuModes()`). Keyboard: arrows, Home/End, type-ahead, the arrow along the reading direction opens a submenu, Esc closes one level; ARIA menu roles; submenus stay inside the window; one highlight for pointer and keys. It is an overlay like the other shell menus (the shell is raised, panes stay visible, nothing is dimmed).

Words: menuMessages.en.json (`wb.menu.*`), read through the framework i18n with that English as the fallback until the catalogs have them; words the panel already has are reused.

Host: `tab_zoom {id, factor}` (shell-only) sets a tab's page zoom with the engine's own zoom, clamped to 25%..500% and remembered per tab id in app data `zoom.json` (a number per tab id, nothing else; a closed tab's entry goes); without a factor it reads. A tab may forward four more shortcut names: `app-menu`, `zoom-in`, `zoom-out`, `zoom-reset`. The titlebar shows a zoom chip only while the pane in front is not at 100%.

create-waybetter: `tab_zoom` in the shell capability list; the template says which panel sections it lacks (store, updates) and how to add menu rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
CRTkafa 2026-09-30 21:52:51 +07:00
parent eed6bdd8f4
commit e5d43afffc
27 changed files with 1587 additions and 18 deletions

View file

@ -16,6 +16,7 @@ import { besideGroup } from '../paneModel.ts';
import { tabProfile } from '../profileModel.ts';
import { accountAction } from './accountModel.ts';
import { accountLabel } from './AccountSwitcher.tsx';
import { openAppMenu } from './AppMenu.tsx';
import { invoke, listen } from './bridge.ts';
import { CommandPalette } from './CommandPalette.tsx';
import { DeckTabBadge, DeckView, focusColumn, runDeckCommand } from './DeckView.tsx';
@ -40,6 +41,7 @@ import { openWorkspaceSave } from './TitlebarExtras.tsx';
import { WebPanel } from './WebPanel.tsx';
import { frameless, isTauri, onMaximizedChange, os } from './windowBinding.ts';
import { loadWorkspaces, restoreWorkspace, workspaceList, workspaces } from './workspaces.ts';
import { stepZoom, zoomTarget } from './zoomStore.ts';
import './shell.css';
type Placement = { referencePanel: string; direction: 'within' | 'right' | 'below' };
@ -262,6 +264,7 @@ function runPalette(action: PaletteAction) {
case 'plugin-command': runPluginCommand(action.tab, action.command); break;
case 'workspace': void restoreWorkspace(action.id); break;
case 'workspace-save': openWorkspaceSave(); break;
case 'menu': openAppMenu({ keyboard: true }); break;
}
}
@ -269,6 +272,13 @@ function runShortcut(shortcut: string, id?: string) {
const api = shell.api;
if (!api) return;
if (shortcut === 'command-palette') { togglePalette(); return; }
// Alt+F / F10: the app menu, opened for the keyboard (pressed again, it closes).
if (shortcut === 'app-menu') { openAppMenu({ keyboard: true, toggle: true }); return; }
// Page zoom of the tab the keys were pressed in (a deck column zooms itself), else the pane in front.
if (shortcut === 'zoom-in' || shortcut === 'zoom-out' || shortcut === 'zoom-reset') {
void stepZoom(shortcut === 'zoom-in' ? 1 : shortcut === 'zoom-out' ? -1 : 0, id ?? zoomTarget());
return;
}
if (shortcut === 'deck-toggle') { toggleDeck(); return; }
if (shortcut.startsWith('column-') || shortcut === 'deck-compose') {
const deckId = deckFor(id);
@ -333,7 +343,15 @@ function shortcutFor(event: KeyboardEvent): string | null {
if (key === 'tab') return event.shiftKey ? 'prev-tab' : 'next-tab';
if (key === 'r') return 'reload';
if (event.code === 'Backslash' || event.code === 'IntlBackslash') return event.shiftKey ? 'split-down' : 'split-right';
if (hasFeature('zoom')) {
if (key === '=' || key === '+' || event.code === 'NumpadAdd') return 'zoom-in';
if (key === '-' || event.code === 'NumpadSubtract') return 'zoom-out';
if (key === '0' || event.code === 'Numpad0') return 'zoom-reset';
}
}
// The app menu, like a browser's: F10, and Alt+F where Alt is not a typing key (not on macOS).
if (event.key === 'F10' && !mod && !event.altKey && !event.shiftKey) return 'app-menu';
if (event.altKey && !mod && !event.shiftKey && event.code === 'KeyF' && os !== 'macos') return 'app-menu';
if (event.altKey && !mod && key === 'arrowleft') return 'back';
if (event.altKey && !mod && key === 'arrowright') return 'forward';
return null;
@ -542,6 +560,8 @@ export default function Shell() {
shell.openAccount = openAccount;
shell.openUrl = (url, profile) => { addWeb(url, undefined, true, profile); };
shell.openPanelSection = section => openPanel(section, shell.api?.activePanel?.id);
shell.shortcut = name => runShortcut(name);
shell.run = runPalette;
useEffect(() => {
document.documentElement.dataset.os = os;