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.

Browser pane: a page that renames itself keeps what you type (28y) (#823)

Oleksandr Ivanchenkof06d7132ed8e
diff --git a/frontend/src/components/VirtualMachinePane.tsx b/frontend/src/components/VirtualMachinePane.tsx
index 4f0f2744..06e1671e 100644
--- a/frontend/src/components/VirtualMachinePane.tsx
+++ b/frontend/src/components/VirtualMachinePane.tsx
@@ -327,11 +327,12 @@ export const VirtualMachinePane: React.FC<VirtualMachinePaneProps> = ({
const setInputUrl = (url: string) => setWritten({ key: fieldKey, url, typed: true });
// Then the stream takes over, but only the chosen page's own: a late message from the page just left
// never writes its address. A blank tab's own about:blank keeps the field empty (28u), as its chip says
- // "nothing open"; pageUrl keeps the raw value for the blank check and the picture.
+ // "nothing open"; pageUrl keeps the raw value for the blank check and the picture. 28y: only a new url or page
+ // writes it; a title that changes on its own ("(3) Inbox") never reaches the field or what the person typed.
useEffect(() => {
if (stream.location?.url && stream.location.page === chosenPage) setWritten({ key: fieldKey, url: isBlankPage(stream.location.url) ? '' : stream.location.url });
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [stream.location]);
+ }, [stream.location?.url, stream.location?.page]);
// The pane's own stream knows each page's title too, so the trail can name pages the bot opened
useEffect(() => {
noteTitle(stream.location?.url, stream.location?.title);
diff --git a/frontend/tests/typedAddressStays.test.mjs b/frontend/tests/typedAddressStays.test.mjs
index 1de8d54d..91b96f14 100644
--- a/frontend/tests/typedAddressStays.test.mjs
+++ b/frontend/tests/typedAddressStays.test.mjs
@@ -3,6 +3,8 @@
// `location` each time, even when nothing changed; each one rewrote the address field, so text the person was
// typing was wiped. Plus Rigel's 28r P1 (address-follows-the-tab/qa.md:48): a revisited tab showed its old
// stream-written address until its own stream spoke again.
+// 28y title-change-keeps-typing (Mira, typed-address-stays/design-check.md:19; Rigel's Q1): a page whose title
+// changes on its own no longer wipes what the person types; only a new url or page writes the field.
import assert from 'node:assert/strict';
import test from 'node:test';
import { JSDOM } from 'jsdom';
@@ -121,7 +123,7 @@ test('typing on a blank tab survives two identical location ticks', async () =>
} finally { m.done(); }
});
-test('typing on a tab with a real url survives identical ticks; a new url or title still lands', async () => {
+test('typing on a tab with a real url survives identical ticks and title-only changes; a new url still lands', async () => {
const k = threeTabs('x2');
answer = k.LIST;
const m = mount({ teamId: 'x2', browsingBot: 'Ben', botNames: NAMES, activeUrl: OTHER, onNavigate: () => {} });
@@ -137,10 +139,42 @@ test('typing on a tab with a real url survives identical ticks; a new url or tit
assert.equal(field(m.host).value, 'booktun.ing', 'two identical ticks: typing kept');
await tick(ben, 'https://shop.example.com/trail/checkout', 'Checkout');
assert.equal(field(m.host).value, 'https://shop.example.com/trail/checkout', 'a new url replaces it');
- // Same url, new title: the location changed, so the field is written again (with the same url)
+ // 28y: same url, new title (a page that renames itself, "(3) Inbox"): typed text stays, the title line follows
setVal(field(m.host), 'booktun.ing');
await tick(ben, 'https://shop.example.com/trail/checkout', 'Checkout - step 2');
- assert.equal(field(m.host).value, 'https://shop.example.com/trail/checkout');
+ assert.equal(field(m.host).value, 'booktun.ing', 'a title-only change keeps typed text');
+ assert.ok(m.host.textContent.includes('Checkout - step 2'), 'the title line shows the new title');
+ await tick(ben, 'https://shop.example.com/trail/checkout', '(3) Checkout - step 2');
+ assert.equal(field(m.host).value, 'booktun.ing', 'a second title change keeps it too');
+ assert.ok(m.host.textContent.includes('(3) Checkout - step 2'));
+ await tick(ben, 'https://shop.example.com/trail/done', 'Done');
+ assert.equal(field(m.host).value, 'https://shop.example.com/trail/done', 'a new url still replaces it');
+ } finally { m.done(); }
+});
+
+test('28y: after a stream reset the first location with the same url still writes the field', async () => {
+ const k = threeTabs('x5');
+ answer = k.LIST;
+ const m = mount({ teamId: 'x5', browsingBot: 'Ben', botNames: NAMES, activeUrl: OTHER, onNavigate: () => {} });
+ try {
+ await settle();
+ assert.equal(currentTab(m.host), 'x5#ben#c1');
+ await tick(sockets.at(-1), 'https://shop.example.com/trail/cart', 'Cart');
+ assert.equal(field(m.host).value, 'https://shop.example.com/trail/cart');
+ setVal(field(m.host), 'booktun.ing');
+ // Close and reopen the pane: the stream resets (location null) and a new socket opens on the same page
+ const before = sockets.length;
+ m.render({ isOpen: false });
+ await settle();
+ m.render({ isOpen: true });
+ await settle();
+ assert.ok(sockets.length > before, 'a new socket after the reset');
+ await tick(sockets.at(-1), 'https://shop.example.com/trail/cart', 'Cart');
+ assert.equal(field(m.host).value, 'https://shop.example.com/trail/cart', 'null -> same url writes the address again');
+ // and the 2 s tick after it is still quiet
+ setVal(field(m.host), 'booktun.ing');
+ await tick(sockets.at(-1), 'https://shop.example.com/trail/cart', 'Cart');
+ assert.equal(field(m.host).value, 'booktun.ing');
} finally { m.done(); }
});