Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

30y phone-browser-hint: idle phone pane points at Take over, not a hidden address bar (#906)

Oleksandr Ivanchenkodfd9b4e47fe4
diff --git a/frontend/src/components/VirtualMachinePane.tsx b/frontend/src/components/VirtualMachinePane.tsx
index c81fe07d..42eb4606 100644
--- a/frontend/src/components/VirtualMachinePane.tsx
+++ b/frontend/src/components/VirtualMachinePane.tsx
@@ -643,6 +643,15 @@ export const VirtualMachinePane: React.FC<VirtualMachinePaneProps> = ({
</button>
) : null;
+ // 30y: a phone has no address bar (typing a URL is a Take over job), so the idle hint points at what is there.
+ // It names Take over only when the action row under the preview shows it (same rule as that row).
+ const takeOverShown = !isWindow && Boolean(pointButtonEl || stream.connected || isControlMode);
+ const readyHint = !narrow
+ ? 'Enter a URL above to open a page'
+ : takeOverShown
+ ? 'Ask a bot to open a page, or use Take over below'
+ : 'Ask a bot to open a page';
+
return (
// 0.9.8 E: on a phone the panel is a 70 % bottom sheet over a scrim; the chat stays readable above it.
<>
@@ -1081,7 +1090,7 @@ export const VirtualMachinePane: React.FC<VirtualMachinePaneProps> = ({
<div className="text-center p-6 text-zinc-500 text-xs">
<Globe size={32} className="mx-auto mb-2 opacity-40 text-zinc-500" />
<p>{browserReady ? 'Browser idle' : 'Browser unavailable'}</p>
- <p className="text-[10px] text-zinc-500 mt-1">{browserReady ? 'Enter a URL above to open a page' : isLocal ? 'Check that Chrome is installed, then use Restart browser below' : 'Start Docker, then use Restart browser below'}</p>
+ <p className="text-[10px] text-zinc-500 mt-1">{browserReady ? readyHint : isLocal ? 'Check that Chrome is installed, then use Restart browser below' : 'Start Docker, then use Restart browser below'}</p>
</div>
)}
</div>
diff --git a/frontend/tests/phoneBrowserHint.test.mjs b/frontend/tests/phoneBrowserHint.test.mjs
new file mode 100644
index 00000000..db76e5b2
--- /dev/null
+++ b/frontend/tests/phoneBrowserHint.test.mjs
@@ -0,0 +1,97 @@
+// 30y phone-browser-hint: Mira's 0.9.31 UX pass, fix #4 (autonomy/ux-pass-0931/report.md "4."). On a phone the idle
+// bot browser said "Enter a URL above to open a page", but the address bar is hidden below 640 px on purpose
+// (typing a URL is a Take over job). On a phone the hint now points at what is on screen: ask a bot, or Take over
+// below, and names Take over only while that button is under the preview. Wide keeps today's sentence.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { JSDOM } from 'jsdom';
+import { loadBundled } from './bundle.mjs';
+
+const dom = new JSDOM('<!doctype html><html><body></body></html>', { url: 'http://localhost/s/spc_default', pretendToBeVisual: true });
+const g = globalThis;
+for (const k of ['window', 'document', 'navigator', 'HTMLElement', 'HTMLImageElement', 'Element', 'Node', 'Event', 'FocusEvent', 'MouseEvent', 'KeyboardEvent', 'requestAnimationFrame', 'cancelAnimationFrame', 'getComputedStyle', 'localStorage', 'sessionStorage']) {
+ if (!(k in dom.window)) continue;
+ Object.defineProperty(g, k, { value: dom.window[k], configurable: true, writable: true });
+}
+g.ResizeObserver = g.window.ResizeObserver = class { observe() {} unobserve() {} disconnect() {} };
+let phone = false; // what the width media queries answer
+g.window.matchMedia = (q) => ({ matches: phone && /max-width/.test(q), media: q, addEventListener() {}, removeEventListener() {}, addListener() {}, removeListener() {} });
+g.fetch = g.window.fetch = async () => ({ ok: false, status: 404, json: async () => ({}), text: async () => '' });
+
+const sockets = [];
+class FakeWebSocket {
+ static OPEN = 1;
+ constructor(url) { this.url = url; this.readyState = 1; this.sent = []; this.bufferedAmount = 0; sockets.push(this); }
+ send(text) { this.sent.push(JSON.parse(text)); }
+ close() { this.readyState = 3; }
+ receive(message) { this.onmessage?.({ data: JSON.stringify(message) }); }
+}
+g.WebSocket = g.window.WebSocket = FakeWebSocket;
+
+const m = await loadBundled(`
+ export { default as React } from 'react';
+ export { createRoot } from 'react-dom/client';
+ export { flushSync } from 'react-dom';
+ export { VirtualMachinePane } from './src/components/VirtualMachinePane';
+`);
+const settle = async () => { for (let i = 0; i < 30; i++) await new Promise((r) => setTimeout(r, 0)); };
+
+const WIDE_HINT = 'Enter a URL above to open a page';
+const PHONE_HINT = 'Ask a bot to open a page, or use Take over below';
+
+/** The idle, ready pane; `live` sends a blank tab's frame so the stream is connected. */
+async function idlePane({ narrow, live }) {
+ phone = narrow;
+ const host = document.createElement('div');
+ document.body.appendChild(host);
+ const root = m.createRoot(host);
+ m.flushSync(() => root.render(m.React.createElement(m.VirtualMachinePane, {
+ isOpen: true, onClose: () => {}, teamId: 'k1', teamName: 'Rook', isRunning: true, activeUrl: 'about:blank',
+ })));
+ await settle();
+ if (live) {
+ const ws = sockets.at(-1);
+ assert.ok(ws, 'the pane opened a live-view socket');
+ ws.onopen?.();
+ ws.receive({ type: 'location', url: 'about:blank', title: '' });
+ ws.receive({ type: 'frame', id: 1, image: 'AAAA', width: 1280, height: 800 });
+ await settle();
+ }
+ const text = host.textContent;
+ const takeOver = host.querySelector('[data-takeover-button]');
+ const done = () => { m.flushSync(() => root.unmount()); host.remove(); };
+ return { text, takeOver, done };
+}
+
+test('phone, idle and live: no "Enter a URL above"; the hint names the Take over button that is under the preview', async () => {
+ const p = await idlePane({ narrow: true, live: true });
+ try {
+ assert.match(p.text, /Browser idle/);
+ assert.ok(!p.text.includes('Enter a URL above'), 'a phone has no address bar above the preview');
+ assert.ok(p.text.includes(PHONE_HINT), `phone hint: ${p.text}`);
+ assert.ok(p.takeOver, 'the Take over button shows in the idle state');
+ assert.equal(p.takeOver.textContent.trim(), 'Take over', 'the hint uses the button\'s real label');
+ } finally { p.done(); }
+});
+
+test('phone, ready but no live view yet: only "Ask a bot", never a Take over that is not there', async () => {
+ const p = await idlePane({ narrow: true, live: false });
+ try {
+ assert.match(p.text, /Browser idle/);
+ assert.equal(p.takeOver, null);
+ assert.ok(p.text.includes('Ask a bot to open a page'));
+ assert.ok(!p.text.includes('Take over below'));
+ assert.ok(!p.text.includes('Enter a URL above'));
+ } finally { p.done(); }
+});
+
+test('wide, idle: the address bar is there and the hint is unchanged', async () => {
+ for (const live of [true, false]) {
+ const p = await idlePane({ narrow: false, live });
+ try {
+ assert.match(p.text, /Browser idle/);
+ assert.ok(p.text.includes(WIDE_HINT), `wide hint (live ${live}): ${p.text}`);
+ assert.ok(!p.text.includes('Ask a bot to open a page'));
+ } finally { p.done(); }
+ }
+});