Add screen-size setting to Navigate and Terminal apps

This commit is contained in:
James Babcock committed 2026-09-05 10:45:39 -07:00
1 parent 50f2041eea
commit 1524766996
15 files changed
+501 -56

No files matched your search

+17 -1
View File
@@ -32,6 +32,9 @@ import {
navigateDestinationAddressDraftSetting,
navigateDestinationNameDraftSetting,
navigateRememberRecentSetting,
navigateDisplayModeSetting,
navigateVerticalPositionSetting,
enumSettingMenuItem,
type ConfigSettingString,
} from "../../ui/dashboard-settings";
import {
@@ -274,6 +277,15 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
};
post({ type: "set-tools", windowId: message.windowId, tools: NAVIGATE_TOOLS });
break;
case "resize-window":
if (!window || window.windowId !== message.windowId) break;
if (window.viewportWidth === message.viewport.width && window.viewportHeight === message.viewport.height) break;
window.viewportWidth = message.viewport.width;
window.viewportHeight = message.viewport.height;
window.menu?.resize(message.viewport);
window.lastSubmittedFingerprint = "";
render();
break;
case "close-window":
if (editing) {
// Window closed mid-edit: shut the phone editor down.
@@ -838,7 +850,7 @@ function describeRouteStatus(): string {
/**
* The window's context menu: Stop navigation while a route is up, then the
* saved-destination settings (Home, Work, custom named places) and the
* display and saved-destination settings (Home, Work, custom named places), and the
* recent-destinations preference.
*/
function windowMenuItems(win: NavWindow): MenuItem[] {
@@ -853,6 +865,10 @@ function windowMenuItems(win: NavWindow): MenuItem[] {
},
});
}
items.push(
enumSettingMenuItem(navigateDisplayModeSetting),
enumSettingMenuItem(navigateVerticalPositionSetting),
);
items.push({
label: "Saved destinations",
onSelect: (ctx) => {
+25 -2
View File
@@ -308,6 +308,30 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
case "open-window":
openWindow(message.windowId, message.surfaceId, message.title, message.viewport);
break;
case "resize-window": {
const window = windows.get(message.windowId);
if (!window || (window.viewportWidth === message.viewport.width && window.viewportHeight === message.viewport.height)) break;
window.viewportWidth = message.viewport.width;
window.viewportHeight = message.viewport.height;
window.menu?.resize(message.viewport);
window.lastSubmittedFingerprint = "";
if (window.kind === "view") {
window.gridCols = Math.floor(window.viewportWidth / window.cellWidth);
window.gridRows = Math.floor(window.viewportHeight / window.cellHeight);
if (window.reconnectTimer) clearTimeout(window.reconnectTimer);
window.reconnectTimer = null;
window.client.stop();
window.client.setViewport(window.gridCols, window.gridRows);
window.emulator.dispose();
window.emulator = new TerminalEmulator(window.gridCols, window.gridRows);
window.receivedData = false;
window.archive = [];
window.scrollTop = null;
reconnectView(window);
}
scheduleRender(window);
break;
}
case "close-window":
closeWindow(message.windowId);
break;
@@ -1434,8 +1458,7 @@ function openViewWindow(control: ControlConnection, socket: string, label: strin
icon: "terminal",
iconGlyph: glyph || undefined,
focus: true,
// Terminal views are the one full-height window kind: more rows matter
// more than a small on-screen footprint.
// Default to tall sessions; the app display setting can override this.
heightMode: "max",
});
}
+4
View File
@@ -53,6 +53,10 @@ export class TerminalEmulator {
this.term.write(data, onProcessed);
}
dispose(): void {
this.term.dispose();
}
/** Full reset; snapshots are defined as repainting from a cleared screen. */
reset(): void {
this.term.reset();