diff --git a/README.md b/README.md index 0671a48..dcb61ff 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ RunContainer tries to show the app in a separate RunContainer window. Depending ## From an iPhone -The iPhone companion shows an app that is already running on the PC. Scan the QR code in Settings with the phone camera, then **Share → Add to Home Screen**; it opens like an app, with no port to type. With Tailscale signed in, Settings can open a real `https://…ts.net` address through Funnel, so it also works away from home. Apps keep running on the PC, and pairing is required. +The iPhone companion shows an app that is already running on the PC. Scan the QR code in Settings with the phone camera, then **Share → Add to Home Screen**; it opens like an app, with no port to type. With Tailscale signed in, Settings can open a real `https://…ts.net` address through Funnel, so it also works away from home. Apps keep running on the PC, and pairing is required. While the companion is on, closing RunContainer's window leaves it running in the notification area, so the Home Screen shortcut keeps working; right-click that icon to reopen the window or to stop the companion and quit. ## Keeping apps apart diff --git a/package-lock.json b/package-lock.json index f2523a8..16b8688 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "RunContainer", - "version": "0.9.8", + "version": "0.9.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "RunContainer", - "version": "0.9.8", + "version": "0.9.9", "dependencies": { "electron-squirrel-startup": "^1.0.1", "qrcode-generator": "^1.4.4" diff --git a/package.json b/package.json index 02446ee..a9d6860 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "RunContainer", "productName": "RunContainer", - "version": "0.9.8", + "version": "0.9.9", "description": "A Windows-based container management application for running applications in a sandboxed environment.", "main": "public/main.js", "scripts": { diff --git a/public/companion/companion.css b/public/companion/companion.css index d5d680b..b089928 100644 --- a/public/companion/companion.css +++ b/public/companion/companion.css @@ -3,11 +3,11 @@ --bg: #080b10; --bg-soft: #0d1219; --panel: rgba(18, 24, 33, 0.86); - --line: rgba(79, 216, 180, 0.18); - --line-strong: rgba(79, 216, 180, 0.42); - --accent: #3fcfaa; - --accent-soft: rgba(63, 207, 170, 0.14); - --accent-text: #d6fbf1; + --line: rgba(176, 186, 200, 0.18); + --line-strong: rgba(176, 186, 200, 0.42); + --accent: #9aa3b0; + --accent-soft: rgba(154, 163, 176, 0.14); + --accent-text: #e6e9ee; --text: #e8eefc; --muted: #93a4bf; --danger: #ff7d7d; @@ -27,7 +27,7 @@ html, body { height: 100%; } body { margin: 0; background: - radial-gradient(1100px 620px at 78% -8%, rgba(63, 207, 170, 0.13), transparent 62%), + radial-gradient(1100px 620px at 78% -8%, rgba(154, 163, 176, 0.10), transparent 62%), radial-gradient(820px 520px at -12% 108%, rgba(38, 120, 255, 0.12), transparent 60%), linear-gradient(180deg, #0a0f15, #070a0e 62%); color: var(--text); @@ -43,8 +43,8 @@ body { inset: 0; pointer-events: none; background-image: - linear-gradient(rgba(120, 200, 180, 0.05) 1px, transparent 1px), - linear-gradient(90deg, rgba(120, 200, 180, 0.05) 1px, transparent 1px); + linear-gradient(rgba(176, 186, 200, 0.05) 1px, transparent 1px), + linear-gradient(90deg, rgba(176, 186, 200, 0.05) 1px, transparent 1px); background-size: 46px 46px; mask-image: radial-gradient(720px 520px at 50% 0%, #000 20%, transparent 78%); -webkit-mask-image: radial-gradient(720px 520px at 50% 0%, #000 20%, transparent 78%); @@ -59,23 +59,23 @@ body.nightly { } /* Daylight. The dark surface reads as flat grey on a bright screen, so the light theme - is a real palette rather than a lighter shade of the same one: pale mint paper, dark - ink, and the same teal accent for anything actionable. */ + is a real palette rather than a lighter shade of the same one: neutral paper, dark + ink, and the same grey accent for anything actionable. */ body[data-theme="light"] { color-scheme: light; --bg: #f1f6f5; --bg-soft: #ffffff; --panel: rgba(255, 255, 255, 0.92); - --line: rgba(11, 70, 59, 0.16); - --line-strong: rgba(11, 70, 59, 0.42); - --accent: #0f8c6f; - --accent-soft: rgba(15, 140, 111, 0.12); - --accent-text: #073c31; + --line: rgba(55, 65, 81, 0.16); + --line-strong: rgba(55, 65, 81, 0.42); + --accent: #4b5563; + --accent-soft: rgba(75, 85, 99, 0.12); + --accent-text: #1f2937; --text: #0c1a17; --muted: #4d625d; --danger: #b42318; background: - radial-gradient(1100px 620px at 78% -8%, rgba(15, 140, 111, 0.12), transparent 62%), + radial-gradient(1100px 620px at 78% -8%, rgba(75, 85, 99, 0.10), transparent 62%), radial-gradient(820px 520px at -12% 108%, rgba(38, 120, 255, 0.08), transparent 60%), linear-gradient(180deg, #f8fbfa, #eaf2f0 62%); } @@ -89,8 +89,8 @@ body[data-theme="light"].nightly { body[data-theme="light"] .halo { background-image: - linear-gradient(rgba(11, 70, 59, 0.07) 1px, transparent 1px), - linear-gradient(90deg, rgba(11, 70, 59, 0.07) 1px, transparent 1px); + linear-gradient(rgba(55, 65, 81, 0.07) 1px, transparent 1px), + linear-gradient(90deg, rgba(55, 65, 81, 0.07) 1px, transparent 1px); } body[data-theme="light"] input { @@ -109,7 +109,7 @@ body[data-theme="light"] .app-card { } body[data-theme="light"] .stage { - background: radial-gradient(700px 420px at 50% 0%, rgba(15, 140, 111, 0.08), transparent 70%), #ffffff; + background: radial-gradient(700px 420px at 50% 0%, rgba(75, 85, 99, 0.08), transparent 70%), #ffffff; } body[data-theme="light"] .stage-note, @@ -122,7 +122,7 @@ body[data-theme="light"] .primary { } body[data-theme="light"] .mark { - box-shadow: 0 10px 24px -16px rgba(11, 70, 59, 0.5); + box-shadow: 0 10px 24px -16px rgba(31, 41, 55, 0.45); } .screen { @@ -214,8 +214,8 @@ button:disabled { opacity: 0.55; } width: 100%; margin-top: 4px; padding: 15px 18px; - border: 1px solid rgba(140, 233, 208, 0.5); - background: linear-gradient(180deg, rgba(63, 207, 170, 0.92), rgba(40, 166, 136, 0.95)); + border: 1px solid rgba(214, 219, 227, 0.5); + background: linear-gradient(180deg, rgba(154, 163, 176, 0.95), rgba(107, 116, 128, 0.96)); color: #04120e; font-weight: 700; font-size: 16.5px; @@ -309,7 +309,7 @@ body.nightly .primary { place-items: center; border-radius: 11px; border: 1px solid var(--line); - background: rgba(63, 207, 170, 0.08); + background: rgba(154, 163, 176, 0.08); color: var(--accent-text); font-weight: 700; font-size: 16px; @@ -360,7 +360,7 @@ body.nightly .primary { border: 1px solid var(--line); border-radius: 18px; background: - radial-gradient(700px 420px at 50% 0%, rgba(63, 207, 170, 0.07), transparent 70%), + radial-gradient(700px 420px at 50% 0%, rgba(154, 163, 176, 0.07), transparent 70%), #05080c; overflow: hidden; box-shadow: 0 26px 70px -50px #000; @@ -423,6 +423,41 @@ body.nightly .primary { .screen { max-width: 980px; margin: 0 auto; } } +/* First-open sheet: explains Add to Home Screen once. */ +.install-tip[hidden] { display: none; } +.install-tip { + position: fixed; + inset: 0; + z-index: 10; + display: flex; + align-items: flex-end; + justify-content: center; + padding: 16px; + background: rgba(0, 0, 0, 0.45); +} +.install-card { + width: 100%; + max-width: 430px; + padding: 22px; + padding-bottom: calc(22px + var(--safe-bottom)); + border: 1px solid var(--line); + border-radius: 22px; + /* Opaque, so the pairing form does not show through the sheet. */ + background: var(--bg-soft); + box-shadow: 0 30px 80px -50px #000; +} +/* Only the sheet's own title; the steps also use and must stay inline. */ +.install-card > strong { display: block; margin-bottom: 10px; font-size: 18px; } +.install-card .steps { margin-bottom: 16px; } + +/* Shown while the PC is unreachable: the list is last-known, not live. */ +body.offline .hint { color: var(--danger); } +body.offline .app-card:disabled { opacity: 0.72; } + +@media (min-width: 700px) { + .screen { max-width: 980px; margin: 0 auto; } +} + @media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } } diff --git a/public/companion/companion.js b/public/companion/companion.js index 385cb7e..b0c9670 100644 --- a/public/companion/companion.js +++ b/public/companion/companion.js @@ -10,6 +10,10 @@ const TOKEN_KEY = 'rc-companion-token'; const DEVICE_KEY = 'rc-companion-device'; const THEME_KEY = 'rc-companion-theme'; + const APPS_KEY = 'rc-companion-apps'; + // iOS keeps a home-screen icon until its URL changes, so the icon URLs carry a + // version. Bumping it is how a shortcut that already exists picks up a new icon. + const ICON_VERSION = '2'; const screens = { pair: document.getElementById('screen-pair'), @@ -45,7 +49,7 @@ quality: 'auto', retry: 0, retryTimer: null, - retry: 0, + offline: false, }; function show(name) { @@ -66,9 +70,9 @@ const favicon = document.getElementById('app-favicon'); const manifest = document.getElementById('app-manifest'); const mark = document.getElementById('app-mark'); - if (icon) icon.href = `${base}/icon-180.png`; - if (favicon) favicon.href = `${base}/icon-192.png`; - if (mark) mark.src = `${base}/icon-192.png`; + if (icon) icon.href = `${base}/icon-180.png?v=${ICON_VERSION}`; + if (favicon) favicon.href = `${base}/icon-192.png?v=${ICON_VERSION}`; + if (mark) mark.src = `${base}/icon-192.png?v=${ICON_VERSION}`; if (manifest) manifest.href = nightly ? '/manifest-nightly.webmanifest' : '/manifest.webmanifest'; } @@ -221,6 +225,7 @@ state.connected = true; state.retry = 0; setPill(connection, 'Connected', 'live'); + setOffline(false); }); socket.addEventListener('message', (event) => { @@ -236,6 +241,7 @@ socket.addEventListener('close', () => { state.connected = false; if (state.socket === socket) state.socket = null; + setOffline(true); setPill(connection, 'Reconnecting…', 'bad'); if (screens.pair.hidden && !screens.apps.hidden) scheduleReconnect(); else if (screens.view.hidden) scheduleReconnect(); @@ -260,6 +266,8 @@ function handleMessage(payload) { if (payload.type === 'hello' || payload.type === 'apps') { state.apps = Array.isArray(payload.apps) ? payload.apps : []; + saveAppsCache(state.apps); + setOffline(false); renderApps(); return; } @@ -383,25 +391,54 @@ return (name || '?').trim().charAt(0).toUpperCase() || '?'; } + // The PC can be off, asleep, or simply not running. The last list it sent is kept so a + // shortcut opened on the home screen shows what this PC has instead of an empty page. + function saveAppsCache(apps) { + try { + localStorage.setItem(APPS_KEY, JSON.stringify({ at: Date.now(), apps: Array.isArray(apps) ? apps : [] })); + } catch (error) { /* private mode */ } + } + + function readAppsCache() { + try { + const parsed = JSON.parse(localStorage.getItem(APPS_KEY) || 'null'); + return Array.isArray(parsed?.apps) ? parsed.apps : []; + } catch (error) { + return []; + } + } + + function setOffline(offline) { + const next = Boolean(offline); + if (state.offline === next) return; + state.offline = next; + document.body.classList.toggle('offline', next); + renderApps(); + } + function renderApps() { appList.textContent = ''; const apps = state.apps.filter((app) => app && app.id); if (apps.length === 0) { const empty = document.createElement('li'); empty.className = 'empty'; - empty.textContent = 'No apps yet. Add one on the PC, then start it there.'; + empty.textContent = state.offline + ? 'This PC is not reachable. Open RunContainer on the PC; it keeps running in the notification area while the companion is on.' + : 'No apps yet. Add one on the PC, then start it there.'; appList.appendChild(empty); appsHint.hidden = true; return; } appsHint.hidden = false; - appsHint.textContent = 'Apps that are running can be opened here.'; + appsHint.textContent = state.offline + ? 'Last known list. Open RunContainer on the PC to use these apps.' + : 'Apps that are running can be opened here.'; for (const app of apps) { const item = document.createElement('li'); const button = document.createElement('button'); button.type = 'button'; button.className = 'app-card'; - button.disabled = !app.running; + button.disabled = !app.running || state.offline; const glyph = document.createElement('span'); glyph.className = 'glyph'; @@ -411,7 +448,9 @@ const title = document.createElement('strong'); title.textContent = app.name; const status = document.createElement('span'); - status.textContent = app.running ? 'Running — tap to open' : `${app.status} — start it on the PC`; + status.textContent = state.offline + ? `${app.status} — PC offline` + : app.running ? 'Running — tap to open' : `${app.status} — start it on the PC`; meta.append(title, status); const chevron = document.createElement('span'); chevron.className = 'chev'; @@ -465,15 +504,22 @@ if (result.ok && result.body) { applyChannel(result.body.channel); state.apps = result.body.apps || []; + saveAppsCache(state.apps); + setOffline(false); renderApps(); } } catch (error) { + setOffline(true); setPill(connection, 'PC not reachable', 'bad'); } } async function open() { show('apps'); + // A fresh launch from the home screen has no live list yet, so show the last one the + // PC sent while the real state is fetched. + if (state.apps.length === 0) state.apps = readAppsCache(); + renderApps(); await refresh(); connectSocket(); } @@ -536,6 +582,22 @@ // ------------------------------------------------------------------- start --- + // First open in a Safari tab: explain Add to Home Screen once. Hidden once the page is + // already installed (standalone), and never shown again after it is dismissed. + const INSTALL_KEY = 'rc-companion-install-seen'; + const installTip = document.getElementById('install-tip'); + const standalone = Boolean(window.navigator.standalone) + || (window.matchMedia && window.matchMedia('(display-mode: standalone)').matches); + let seenInstall = false; + try { seenInstall = localStorage.getItem(INSTALL_KEY) === '1'; } catch (error) { /* private mode */ } + if (installTip && !standalone && !seenInstall) { + installTip.hidden = false; + document.getElementById('install-dismiss').addEventListener('click', () => { + installTip.hidden = true; + try { localStorage.setItem(INSTALL_KEY, '1'); } catch (error) { /* private mode */ } + }); + } + applyTheme(preferredTheme()); for (const button of document.querySelectorAll('.theme-toggle')) { button.addEventListener('click', toggleTheme); diff --git a/public/companion/icons/icon-180.png b/public/companion/icons/icon-180.png index df9a8c8..1074160 100644 Binary files a/public/companion/icons/icon-180.png and b/public/companion/icons/icon-180.png differ diff --git a/public/companion/icons/icon-192.png b/public/companion/icons/icon-192.png index 70c1e2c..694b588 100644 Binary files a/public/companion/icons/icon-192.png and b/public/companion/icons/icon-192.png differ diff --git a/public/companion/icons/icon-512.png b/public/companion/icons/icon-512.png index 5323b51..abb3fba 100644 Binary files a/public/companion/icons/icon-512.png and b/public/companion/icons/icon-512.png differ diff --git a/public/companion/index.html b/public/companion/index.html index 405fae0..c70d76a 100644 --- a/public/companion/index.html +++ b/public/companion/index.html @@ -12,9 +12,11 @@ - - - + + + + RunContainer — Companion @@ -22,7 +24,7 @@
- +

Connect to your PC

This is the RunContainer companion. It shows an app that is running on your Windows PC @@ -106,6 +108,18 @@

Apps on this PC

- + + + diff --git a/public/companion/manifest-nightly.webmanifest b/public/companion/manifest-nightly.webmanifest index 299b747..feb14bf 100644 --- a/public/companion/manifest-nightly.webmanifest +++ b/public/companion/manifest-nightly.webmanifest @@ -10,19 +10,19 @@ "theme_color": "#0b0f14", "icons": [ { - "src": "/icons/nightly/icon-180.png", + "src": "/icons/nightly/icon-180.png?v=2", "sizes": "180x180", "type": "image/png", "purpose": "any" }, { - "src": "/icons/nightly/icon-192.png", + "src": "/icons/nightly/icon-192.png?v=2", "sizes": "192x192", "type": "image/png", "purpose": "any" }, { - "src": "/icons/nightly/icon-512.png", + "src": "/icons/nightly/icon-512.png?v=2", "sizes": "512x512", "type": "image/png", "purpose": "any" diff --git a/public/companion/manifest.webmanifest b/public/companion/manifest.webmanifest index fa8242e..6bc833d 100644 --- a/public/companion/manifest.webmanifest +++ b/public/companion/manifest.webmanifest @@ -10,19 +10,19 @@ "theme_color": "#0b0f14", "icons": [ { - "src": "/icons/icon-180.png", + "src": "/icons/icon-180.png?v=2", "sizes": "180x180", "type": "image/png", "purpose": "any" }, { - "src": "/icons/icon-192.png", + "src": "/icons/icon-192.png?v=2", "sizes": "192x192", "type": "image/png", "purpose": "any" }, { - "src": "/icons/icon-512.png", + "src": "/icons/icon-512.png?v=2", "sizes": "512x512", "type": "image/png", "purpose": "any" diff --git a/public/main.js b/public/main.js index 0a02432..9fe5b53 100644 --- a/public/main.js +++ b/public/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, dialog, ipcMain, shell, session, desktopCapturer } = require('electron'); +const { app, BrowserWindow, dialog, ipcMain, shell, session, desktopCapturer, Tray, Menu, nativeImage } = require('electron'); const fs = require('fs'); const path = require('path'); const { execFile, spawn, spawnSync } = require('child_process'); @@ -3893,6 +3893,79 @@ function createWindow() { const showFallback = setTimeout(showWindow, 4000); if (showFallback.unref) showFallback.unref(); mainWindow.webContents.once('did-finish-load', showWindow); + // With the companion on, closing the window keeps RunContainer running in the + // notification area. The phone's home-screen shortcut points at this PC, so quitting + // on close would leave it pointing at nothing. With the companion off, closing quits + // exactly as it did before. + mainWindow.on('close', (event) => { + if (isQuitting) return; + if (!loadCompanionState().enabled) return; + const activeTray = ensureTray(); + // No tray means no way back to the window, so closing behaves as usual instead. + if (!activeTray) return; + event.preventDefault(); + mainWindow.hide(); + showTrayHintOnce(); + }); +} + +let tray = null; +let isQuitting = false; +let trayHintShown = false; + +function ensureTray() { + if (tray && !tray.isDestroyed()) return tray; + const iconPath = path.join(__dirname, PRODUCT_ICON); + let image = nativeImage.createFromPath(iconPath); + if (image.isEmpty()) image = nativeImage.createEmpty(); + try { + tray = new Tray(image); + } catch (error) { + appendLog(path.join(app.getPath('userData'), 'runcontainer-error.log'), `The notification-area icon could not be created: ${error.message}`); + tray = null; + return null; + } + tray.setToolTip(`${PRODUCT_NAME} is still running so the iPhone companion stays reachable.`); + tray.setContextMenu(Menu.buildFromTemplate([ + { label: `Open ${PRODUCT_NAME}`, click: () => showMainWindow() }, + { type: 'separator' }, + { label: 'Stop the companion and quit', click: () => { isQuitting = true; app.quit(); } }, + ])); + tray.on('click', () => showMainWindow()); + return tray; +} + +function destroyTray() { + if (!tray) return; + try { + if (!tray.isDestroyed()) tray.destroy(); + } catch (error) { + // A tray that is already gone needs no cleanup. + } + tray = null; +} + +function showMainWindow() { + if (!mainWindow || mainWindow.isDestroyed()) { + createWindow(); + return; + } + if (!mainWindow.isVisible()) mainWindow.show(); + mainWindow.focus(); +} + +// Said once, because the window disappearing can otherwise look like a quit. +function showTrayHintOnce() { + if (trayHintShown || !tray) return; + trayHintShown = true; + try { + tray.displayBalloon({ + title: PRODUCT_NAME, + content: 'Still running so the iPhone companion stays reachable. Right-click this icon to quit.', + }); + } catch (error) { + // Balloons are not available on every shell; the tooltip already says it. + } } app.whenReady().then(() => { @@ -3955,6 +4028,8 @@ app.whenReady().then(() => { let quittingAfterCompanionWeb = false; app.on('before-quit', (event) => { + // The close handler must not turn a real quit into a hide. + isQuitting = true; // A funnel outlives the window unless it is closed first, so quitting waits for that // one command. The guard stops the second quit from waiting again. if (!quittingAfterCompanionWeb && loadCompanionState().webEnabled) { @@ -3971,6 +4046,7 @@ app.on('before-quit', (event) => { // Closing RunContainer closes the companion's server and the small input helper, so // nothing of the remote session outlives the window it belonged to. stopCompanionInput(); + destroyTray(); if (companionServer) { try { companionServer.stop(); } catch (error) { /* quitting */ } companionServer = null; @@ -3992,6 +4068,7 @@ app.on('window-all-closed', () => { app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow(); + else showMainWindow(); }); ipcMain.handle('open-file-dialog', async () => { @@ -5743,6 +5820,8 @@ async function startCompanionServer() { if (!server.currentPairingCode()) server.issuePairingCode(); companionServer = server; saveCompanionState({ enabled: true, port }); + // The companion is on, so the window may be closed without stopping it. + ensureTray(); emitCompanionStatus(); // The funnel points at a port, and the port can change when another program took the // saved one, so it is re-opened against the port the server actually got. @@ -5781,6 +5860,7 @@ async function stopCompanionServer() { companionServer = null; } saveCompanionState({ enabled: false }); + destroyTray(); emitCompanionStatus(); return { ok: true, status: companionStatus() }; } diff --git a/scripts/build-app-icon.js b/scripts/build-app-icon.js index 707a5a4..0d2805f 100644 --- a/scripts/build-app-icon.js +++ b/scripts/build-app-icon.js @@ -73,7 +73,7 @@ function sampleColor(px, py, accent = ACCENT, opaque = false) { } function renderRgba(size, options = {}) { - const accent = options.nightly ? NIGHTLY_ACCENT : ACCENT; + const accent = options.accent || (options.nightly ? NIGHTLY_ACCENT : ACCENT); const opaque = Boolean(options.opaque); const data = Buffer.alloc(size * size * 4); const scale = UNIT / size; diff --git a/scripts/build-companion-icons.js b/scripts/build-companion-icons.js index 86ba5ce..a6fcede 100644 --- a/scripts/build-companion-icons.js +++ b/scripts/build-companion-icons.js @@ -16,6 +16,11 @@ const ROOT = path.join(__dirname, '..'); const COMPANION_DIR = path.join(ROOT, 'public', 'companion'); const ICON_DIR = path.join(COMPANION_DIR, 'icons'); const SIZES = [180, 192, 512]; +// The stable home-screen icon is grey so it reads as a neutral bookmark; nightly keeps its blue. +const STABLE_ACCENT = [0x9a, 0xa3, 0xb0]; +// iOS keeps an installed home-screen icon until its URL changes, so icon URLs carry +// this version. Bump it whenever the artwork or accent changes. +const ICON_VERSION = '2'; const DESIGNS = [ { nightly: false, dir: ICON_DIR, manifest: path.join(COMPANION_DIR, 'manifest.webmanifest') }, @@ -24,7 +29,7 @@ const DESIGNS = [ function manifestFor(design) { const icons = SIZES.map((size) => ({ - src: `${design.nightly ? '/icons/nightly' : '/icons'}/icon-${size}.png`, + src: `${design.nightly ? '/icons/nightly' : '/icons'}/icon-${size}.png?v=${ICON_VERSION}`, sizes: `${size}x${size}`, type: 'image/png', purpose: 'any', @@ -51,7 +56,7 @@ function build() { files.push({ path: filePath, label: path.relative(ROOT, filePath).replace(/\\/g, '/'), - data: encodePng(size, renderRgba(size, { nightly: design.nightly, opaque: true })), + data: encodePng(size, renderRgba(size, { nightly: design.nightly, opaque: true, accent: design.nightly ? undefined : STABLE_ACCENT })), }); } files.push({ diff --git a/src/components/ContainerManager.jsx b/src/components/ContainerManager.jsx index a09d08a..f27a39f 100644 --- a/src/components/ContainerManager.jsx +++ b/src/components/ContainerManager.jsx @@ -44,7 +44,7 @@ function useBootAnimation() { // Used only until the main process reports the version from package.json. // Shown only for the moment before the main process reports the real version; the // test asserts that it tracks package.json, so it must be bumped with the release. -const APP_VERSION_FALLBACK = "0.9.8"; +const APP_VERSION_FALLBACK = "0.9.9"; // "4m 07s" - how long a setup has been running, for the one place a long wait // needs to be explained rather than look frozen. function formatElapsed(ms) { @@ -1514,10 +1514,7 @@ export default function ContainerManager() { {companion?.running ? ( <> - - On. The phone shows an app that is running here and sends your taps and typing back to it; nothing is - installed on the phone. - + On. The phone shows an app running here. Nothing is installed on the phone. {companionLinkUrl(companion) ? (
Scan this with the iPhone camera -
    -
  1. Point the camera at the code and tap the link it offers.
  2. -
  3. - Tap Share, then Add to Home Screen. From then on it opens - like an app. -
  4. -
  5. Type the pairing code below and give the phone a name.
  6. -
+ + Then tap Share and Add to Home Screen. The page also explains this when it opens. +
- The code works once and expires after five minutes. The phone keeps its place until you forget it. + The code works once and expires after five minutes. {companion.connected > 0 ? ` ${companion.connected} phone${companion.connected === 1 ? '' : 's'} connected now.` : ''} {companion.urls?.length > 0 && ( @@ -1639,14 +1630,8 @@ export default function ContainerManager() { ) : ( <> - - Off. Turn it on to use an app from an iPhone: the phone shows an app that is already running here and - sends your taps and typing to it. Nothing is installed on the phone. - - - You need the PC switched on and the phone on the same Wi-Fi, or on a private network such as Tailscale - when you are away. It is experimental, and it shows one app window rather than your screen. - + Off. Turn it on to use a running app from an iPhone. Nothing is installed on the phone. + Needs the PC on and the phone on the same Wi-Fi. )}
diff --git a/src/data/updates.js b/src/data/updates.js index d09d654..c8aa535 100644 --- a/src/data/updates.js +++ b/src/data/updates.js @@ -3,6 +3,17 @@ // badge is filled in at runtime from package.json via the main process. export const UPDATES = [ + { + version: '0.9.9', + date: '2026-11-05', + title: 'The iPhone companion stays reachable', + changes: [ + 'The companion is grey now: its Home Screen icon, pairing screen and app list match, instead of borrowing the desktop app\u2019s green. The desktop app keeps its own colour.', + 'Closing RunContainer\u2019s window no longer stops the companion. While it is on, the app keeps running in the notification area, so a Home Screen shortcut still reaches this PC; right-click that icon to reopen the window or to stop the companion and quit.', + 'If the PC is asleep or RunContainer is not running, the shortcut shows the last list of apps it knew about and says the PC is unreachable, rather than an empty page.', + 'The companion page, its styles and its icons carry a version now, so an update reaches a shortcut that was added earlier instead of serving the old page.', + ], + }, { version: '0.9.8', date: '2026-10-30', diff --git a/src/services/companionAssets.test.js b/src/services/companionAssets.test.js new file mode 100644 index 0000000..69008c8 --- /dev/null +++ b/src/services/companionAssets.test.js @@ -0,0 +1,105 @@ +// The phone's shortcut is a web page, so its icon, its palette and its offline state are +// static files. These checks catch the cases that only show up on a phone: a stale icon +// iOS never refetches, green left in the stylesheet, and an empty page when the PC is off. +const fs = require('fs'); +const path = require('path'); +const zlib = require('zlib'); + +const ROOT = path.join(__dirname, '..', '..'); +const COMPANION = path.join(ROOT, 'public', 'companion'); + +function pixelColours(file) { + const buffer = fs.readFileSync(file); + let offset = 8; + let width = 0; + let height = 0; + const idat = []; + while (offset < buffer.length) { + const length = buffer.readUInt32BE(offset); + const type = buffer.toString('ascii', offset + 4, offset + 8); + const data = buffer.subarray(offset + 8, offset + 8 + length); + if (type === 'IHDR') { + width = data.readUInt32BE(0); + height = data.readUInt32BE(4); + } + if (type === 'IDAT') idat.push(data); + offset += length + 12; + } + const raw = zlib.inflateSync(Buffer.concat(idat)); + const bpp = 4; + const stride = width * bpp; + const colours = []; + let previous = Buffer.alloc(stride); + for (let y = 0; y < height; y += 1) { + const start = y * (stride + 1); + const filter = raw[start]; + const line = Buffer.from(raw.subarray(start + 1, start + 1 + stride)); + for (let i = 0; i < stride; i += 1) { + const left = i >= bpp ? line[i - bpp] : 0; + const up = previous[i]; + const upLeft = i >= bpp ? previous[i - bpp] : 0; + if (filter === 1) line[i] = (line[i] + left) & 0xff; + else if (filter === 2) line[i] = (line[i] + up) & 0xff; + else if (filter === 3) line[i] = (line[i] + ((left + up) >> 1)) & 0xff; + else if (filter === 4) { + const p = left + up - upLeft; + const pa = Math.abs(p - left); + const pb = Math.abs(p - up); + const pc = Math.abs(p - upLeft); + line[i] = (line[i] + (pa <= pb && pa <= pc ? left : pb <= pc ? up : upLeft)) & 0xff; + } + } + for (let x = 0; x < stride; x += 4) colours.push(`${line[x]},${line[x + 1]},${line[x + 2]}`); + previous = line; + } + return colours; +} + +describe('companion appearance', () => { + it('draws the home-screen icon in grey, not the desktop green', () => { + const colours = pixelColours(path.join(COMPANION, 'icons', 'icon-180.png')); + expect(colours).toContain('154,163,176'); + expect(colours).not.toContain('63,207,170'); + expect(colours).not.toContain('79,216,180'); + }); + + it('gives icon URLs a version so an installed shortcut refetches them', () => { + const html = fs.readFileSync(path.join(COMPANION, 'index.html'), 'utf8'); + expect(html).toMatch(/apple-touch-icon[^>]+icon-180\.png\?v=/); + expect(html).toMatch(/rel="icon"[^>]+icon-192\.png\?v=/); + expect(html).toMatch(/href="\/companion\.css\?v=/); + expect(html).toMatch(/src="\/companion\.js\?v=/); + const script = fs.readFileSync(path.join(COMPANION, 'companion.js'), 'utf8'); + expect(script).toMatch(/icon-180\.png\?v=\$\{ICON_VERSION\}/); + for (const manifest of ['manifest.webmanifest', 'manifest-nightly.webmanifest']) { + expect(fs.readFileSync(path.join(COMPANION, manifest), 'utf8')).toMatch(/icon-\d+\.png\?v=/); + } + }); + + it('has no green left in the companion page styles', () => { + const css = fs.readFileSync(path.join(COMPANION, 'companion.css'), 'utf8'); + expect(css).not.toMatch(/3fcfaa|2bb390|0f8c6f|4fd8b4|120,\s*200,\s*180|140,\s*233,\s*208/i); + }); + + it('keeps the install sheet title rule off the inline s in its steps', () => { + const css = fs.readFileSync(path.join(COMPANION, 'companion.css'), 'utf8'); + expect(css).toContain('.install-card > strong'); + expect(css).not.toMatch(/^\.install-card strong \{/m); + }); + + it('keeps the last app list so the shortcut is not empty when the PC is off', () => { + const script = fs.readFileSync(path.join(COMPANION, 'companion.js'), 'utf8'); + expect(script).toMatch(/rc-companion-apps/); + expect(script).toMatch(/readAppsCache\(\)/); + expect(script).toMatch(/setOffline\(true\)/); + }); + + it('keeps RunContainer running when its window is closed and the companion is on', () => { + const main = fs.readFileSync(path.join(ROOT, 'public', 'main.js'), 'utf8'); + expect(main).toMatch(/mainWindow\.on\('close'/); + expect(main).toMatch(/if \(isQuitting\) return;/); + expect(main).toMatch(/if \(!loadCompanionState\(\)\.enabled\) return;/); + expect(main).toMatch(/event\.preventDefault\(\);/); + expect(main).toMatch(/function ensureTray\(\)/); + }); +});