iOS porting: Battery indicators, app icon, add the rest of the apps

This commit is contained in:
James Babcock committed 2026-09-07 10:18:30 -07:00
1 parent 00a5e38f75
commit e5ba7abc18
31 files changed
+501 -65

No files matched your search

+13 -1
View File
@@ -83,7 +83,7 @@ export function createSettingsPanelLayer(): SettingsPanelLayer {
}
function settingsSections(): SettingsSection[] {
return [
const sections: SettingsSection[] = [
{
label: "Display",
items: [
@@ -232,6 +232,18 @@ function settingsSections(): SettingsSection[] {
],
},
];
if (!global.isIOS) return sections;
const deferred = new Set(["Voice", "Assistant", "Navigate", "Watch", "Developer"]);
return sections.map(section => {
if (deferred.has(section.label)) return { label: section.label, items: [{
label: "Not available on iOS yet", disabled: true, onSelect: () => {},
description: `${section.label} integration has not been ported to iOS.`,
}] };
if (section.label === "Display") return { ...section, items: section.items.filter(item =>
![brightnessSetting.label, screenTimeoutSetting.label, lockScreenEnabledSetting.label].includes(item.label)) };
if (section.label === "Phone display") return { ...section, items: section.items.filter(item => item.label !== mirrorTouchSetting.label) };
return section;
});
}
const LOCAL_MODEL_GB = `${(LOCAL_MODEL.sizeBytes / 1e9).toFixed(1)}GB`;
+3 -2
View File
@@ -278,6 +278,7 @@ export class FontPickerLayer implements Layer {
/** Installed fonts grouped into families (styles sorted by weight). */
function collectFamilies(monospaceOnly: boolean): FontFamily[] {
if (global.isIOS) return []; // Native TTF rendering has not been ported.
const byLabel = new Map<string, FontFamily>();
for (const font of listInstalledFonts()) {
if (monospaceOnly && !font.monospace) continue;
@@ -326,7 +327,7 @@ export function terminalFontPickerMenuItem(): MenuItem {
function fontPickerMenuItem(options: FontPickerOptions & { rowLabel: string; description: string }): MenuItem {
return {
label: options.rowLabel,
description: options.description,
description: global.isIOS ? "Choose a bundled bitmap font. Native TTF rendering is not available on iOS yet." : options.description,
onSelect: (ctx) => {
ctx.stack.push(new FontPickerLayer(options));
},
@@ -338,7 +339,7 @@ function fontPickerMenuItem(options: FontPickerOptions & { rowLabel: string; des
y,
width,
options.rowLabel,
fontSelectionLabel(options.get()),
global.isIOS && options.get().kind === "ttf" ? "Terminus (iOS)" : fontSelectionLabel(options.get()),
);
},
};
+16 -4
View File
@@ -10,7 +10,7 @@ import { shell, type ShellWindow } from "./shell";
* Messages between the shell (main thread) and an app worker. One worker
* hosts one app, which may have several windows; messages are routed by
* windowId. Everything crossing this boundary is small JSON; pixels go
* worker→Java directly.
* worker→Java directly on Android; iOS posts baked frames to the main host.
*/
export type WorkerAppMessage =
| { type: "open-window"; windowId: string; surfaceId: string; title: string; viewport: { width: number; height: number } }
@@ -25,6 +25,7 @@ export type WorkerAppMessage =
| { type: "tool-call"; callId: string; windowId: string; name: string; args: unknown };
export type WorkerAppReply =
| { type: "surface-frame"; surfaceId: string; width: number; height: number; pixels: string }
| {
/**
* The worker's bundle has evaluated and its onmessage handler is
@@ -163,6 +164,8 @@ export type WorkerAppHostOptions = {
setSurfaceVisible: (surfaceId: string, visible: boolean) => void;
removeSurface: (surfaceId: string) => void;
requestShellRender: () => void;
submitPixels?: (surfaceId: string, pixels: Uint8Array, width: number, height: number) => void;
startTextInput?: () => void;
/** Open or focus the Settings app, optionally selecting a section. */
openSettings: (section?: string) => void;
/** Open the phone app's text editor on a string setting (by id). */
@@ -175,8 +178,8 @@ export type WorkerAppHostOptions = {
* Owns the Worker for one app and adapts its windows to the shell's window
* interface: forwards input and lifecycle over postMessage, relays worker
* requests (yield-focus, new windows, attention flags) back to the shell,
* and manages compositor surfaces for the app's windows. The worker submits
* frames straight to the Java compositor, so no pixels cross this boundary.
* and manages compositor surfaces for the app's windows. Android workers send
* frames straight to Java; iOS workers use surface-frame replies.
*/
/** A tool-call awaiting its worker reply; also its own leak-safety timeout. */
type PendingToolCall = {
@@ -212,6 +215,14 @@ export class WorkerAppHost {
const message = event.data as WorkerAppReply | undefined;
if (!message) return;
switch (message.type) {
case "surface-frame": {
if (!global.isIOS || !this.options.submitPixels || !this.openWindows.has(message.surfaceId.replace(/^window:/, ""))) break;
const { width, height } = message;
if (!Number.isInteger(width) || !Number.isInteger(height) || width < 1 || height < 1 || width > 640 || height > 480) break;
const data = NSData.alloc().initWithBase64EncodedStringOptions(message.pixels, 0 as NSDataBase64DecodingOptions);
if (data?.length === width * height) this.options.submitPixels(message.surfaceId, new Uint8Array(interop.bufferFromData(data)), width, height);
break;
}
case "worker-ready":
this.workerReady = true;
for (const queued of this.queuedMessages.splice(0)) {
@@ -256,7 +267,8 @@ export class WorkerAppHost {
// Menus only open on the focused window, but re-check foreground:
// the reply crosses a thread boundary and focus may have moved.
if (shell.foregroundWindow()?.windowId === message.windowId) {
shell.startVoiceInput();
if (this.options.startTextInput) this.options.startTextInput();
else shell.startVoiceInput();
}
break;
case "close-window-request":