Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
83 changes: 59 additions & 24 deletions public/companion/companion.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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%);
Expand All @@ -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%);
}
Expand All @@ -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 {
Expand All @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 <strong> 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; }
}
78 changes: 70 additions & 8 deletions public/companion/companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -45,7 +49,7 @@
quality: 'auto',
retry: 0,
retryTimer: null,
retry: 0,
offline: false,
};

function show(name) {
Expand All @@ -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';
}

Expand Down Expand Up @@ -221,6 +225,7 @@
state.connected = true;
state.retry = 0;
setPill(connection, 'Connected', 'live');
setOffline(false);
});

socket.addEventListener('message', (event) => {
Expand All @@ -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();
Expand All @@ -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;
}
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down
Binary file modified public/companion/icons/icon-180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/companion/icons/icon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/companion/icons/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading