From 2e50c3d0bcf736a41fdf9cd5f04097e9966f6732 Mon Sep 17 00:00:00 2001 From: ancung Date: Wed, 11 Nov 2026 16:18:09 +0700 Subject: [PATCH 1/6] fix(fe): the live view's graph appears settled instead of bouncing in Ancung, 11 Nov: when the live view appeared, its bubbles jiggled and bounced into place, too much. The first graph is settled before drawing only when it has more than one bubble, and it often holds only the Mind: the skills and history arrive a moment later, all at once, were placed in a pile near their parents and left to bounce apart. Now: - A graph that grows by three or more bubbles at once is settled before drawing too, like the first one, so they appear in place. - One or two new bubbles only nudge the layout (heat 0.25, was 0.5). - Settling on its own uses more friction (0.74); dragging keeps 0.86, so a released bubble still sways back like Obsidian's. Doesn't overlap #253 (its cap on the push between near bubbles is another line of sim.ts). Tests: typecheck, lint, vitest 266/266 (graph.test's layout checks still pass). Checked in Chrome: two screenshots taken one after the other after loading the chat show the same, settled graph. Co-Authored-By: Claude Opus 5.5 --- apps/fe/CLAUDE.md | 2 +- apps/fe/src/modules/graph/components/MindGraph.tsx | 8 ++++++-- apps/fe/src/modules/graph/data/sim.ts | 13 +++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apps/fe/CLAUDE.md b/apps/fe/CLAUDE.md index cffc309c..3f874475 100644 --- a/apps/fe/CLAUDE.md +++ b/apps/fe/CLAUDE.md @@ -102,7 +102,7 @@ Chat (`/minds/[mindId]/chat` and `/chat/[threadId]`, `src/modules/chat`, design Live view (beside the chat, `src/modules/graph`, design C2 "What Penny is doing", #17), like Obsidian's graph view (Axel, via Ancung, 10 Nov): - `data/graph.ts` `buildGraph` (app bubbles follow engine/src/graph.ts: every app's tools, the track apps of #211 included, are one App bubble, hung off the skill that uses it, so it reads Mind, skill, app; named "Your Notion" beside the Notion skill, with its logo from `APPS`; Ancung, 11 Nov: the track apps showed twice and without a logo): the Mind in the centre, each equipped skill (not blocked ones), the tools, apps and wallet each skill reaches (`GET /skills` `tools` and `connections`), then anything the events touched; node ids are the engine's (`nodeIdFor`, docs/api-contract.md §4), so live events light the nodes the history built. `uses` counts calls, the last state is running, waiting (an approval), ok, error or denied (`policy_denied`, `wallet_frozen`). A meeting with a Meet link lights Google Meet too. Only live states pulse (`liveStates`): running for the run on screen, waiting for an approval still in `GET …/approvals`; history only sizes the bubbles (Ancung, 10 Nov: Meet and Wallet pulsed from an old, declined approval, which never gets a result event). Mastra's `updateWorkingMemory` is the Memory node. - Events: the last 7 days from `GET /minds/{id}/events?limit=2000`, plus `ChatRunProvider`'s run on screen; read again when a run ends. -- `components/MindGraph.tsx` draws on a canvas: `data/sim.ts` (every pair pushes apart, links pull like springs, a pull to the centre, cools down; the Mind stays in the centre), bubbles coloured by kind from the `node-*` tokens (read from CSS, again when the theme changes), the Mind's avatar in the centre, Gmail, Google Calendar and Google Meet with their own logos (`AppLogos`, serialised to images), labels under every bubble, drawn last with an outline in the background colour so lines and bubbles never hide them (tools quieter). The layout keeps room for the labels (stronger push, longer links; Ancung, 10 Nov: the first one was too tight): each bubble with its label is a box and overlapping boxes are pushed apart, bubbles keep off lines that aren't theirs, and a tool several skills share hangs off the first one only, a tree, so lines don't cross (`tests/graph.test.ts` checks a seven-skill Mind settles with no box on another and no bubble on a line). The built-in HelloNear guide isn't drawn; a job is named from its id ("wallet-watch" reads "Wallet watch"). While a tool works, dots travel along the links from the Mind and its bubble pulses (blue running, amber waiting); a result rings green, a failure or a blocked payment red. The reply on screen leaves a trail (Ancung, 10 Nov: a 1 s calendar call showed nothing): the links from the Mind to every node it used stay blue with slow dots while it streams, and stay softly lit for the last reply, with a ring on those bubbles. Pulses are timed from when this page saw the state change, not the event's server time, and only the run on screen pulses (history loading in after the first draw lit up the whole graph on open, Ancung, 10 Nov). From Obsidian's graph (Axel's screen recording, 10 Nov), keeping the colours that say what each node is and how it went: dragging keeps the layout warm so linked bubbles follow like rubber bands and sway back on release. Labels always show and hover doesn't glow (tried, then dropped with Ancung the same day). A torch follows the mouse instead: the parts of the lines near the cursor catch a lime light (`--focus`, a radial gradient over the lines within reach) that fades with distance. Hover dims nothing (Ancung, 10 Nov: dimming the rest felt odd), its label turns bold, and the cursor is a magnet anywhere on the canvas: every bubble within 120 screen px leans toward it, the nearer the stronger (up to a third of the way, at most 8 units, eased), and its lines follow (drawn only, the layout never sees it; none while dragging or with reduced motion; Ancung, 11 Nov); drag a bubble, drag the background (or Space + drag, or the middle button, even over a bubble) to pan; the wheel works like the Builder's canvas (Ancung, 11 Nov): scroll or two fingers pan, Shift + scroll pans sideways, Ctrl/Cmd + scroll or a trackpad pinch zooms around the pointer (the Builder's `wheelPixels`, `wheelPan`, `wheelZoomFactor`); with the graph focused, + and - zoom, 0 is 100%, 1 or F fits; a two-finger pinch on a touch screen zooms (around the point between the fingers; a second finger ends a bubble drag; Ancung, 10 Nov), Fit to frame it again. Clicking a node glides the camera to it and zooms in (Esc, X or a click on empty canvas lets go; Fit goes back), and a card under the graph says what it is (`describe`), how often it was used, and its latest five calls as the chat's step rows that open to show what went in and came back (`callsOf`; a skill shows the calls of the tools under it, the Mind all of them) (Axel, via Ancung, 10 Nov). Reduced motion keeps the colours without moving dots or rings. It stops drawing while off screen. The layout and the camera are kept per Mind across mounts (`KEPT` in `MindGraph.tsx`), so sending from New chat (which moves to the thread's URL and mounts a new page) doesn't replay the settling, and only new bubbles warm the layout up; a state change or a count doesn't (Ancung, 10 Nov: every event of a reply set it bouncing). The first graph of a Mind on a page is settled before it is drawn and framed at once (`settle`, no bounce or zoom out), and the layout remembers where every bubble sat (`Sim.seen`), so one that drops out for a moment while a chat page mounts comes back to its place without warming anything up (Ancung, 11 Nov: switching chats replayed the zoom out and the jiggle). The panel draws only the chat on screen's run: ChatScreen passes its `activeHere` (`LiveView` `active`), so after switching chats it no longer shows the other chat's reply, trail or steps. +- `components/MindGraph.tsx` draws on a canvas: `data/sim.ts` (every pair pushes apart, links pull like springs, a pull to the centre, cools down; the Mind stays in the centre), bubbles coloured by kind from the `node-*` tokens (read from CSS, again when the theme changes), the Mind's avatar in the centre, Gmail, Google Calendar and Google Meet with their own logos (`AppLogos`, serialised to images), labels under every bubble, drawn last with an outline in the background colour so lines and bubbles never hide them (tools quieter). The layout keeps room for the labels (stronger push, longer links; Ancung, 10 Nov: the first one was too tight): each bubble with its label is a box and overlapping boxes are pushed apart, bubbles keep off lines that aren't theirs, and a tool several skills share hangs off the first one only, a tree, so lines don't cross (`tests/graph.test.ts` checks a seven-skill Mind settles with no box on another and no bubble on a line). The built-in HelloNear guide isn't drawn; a job is named from its id ("wallet-watch" reads "Wallet watch"). While a tool works, dots travel along the links from the Mind and its bubble pulses (blue running, amber waiting); a result rings green, a failure or a blocked payment red. The reply on screen leaves a trail (Ancung, 10 Nov: a 1 s calendar call showed nothing): the links from the Mind to every node it used stay blue with slow dots while it streams, and stay softly lit for the last reply, with a ring on those bubbles. Pulses are timed from when this page saw the state change, not the event's server time, and only the run on screen pulses (history loading in after the first draw lit up the whole graph on open, Ancung, 10 Nov). From Obsidian's graph (Axel's screen recording, 10 Nov), keeping the colours that say what each node is and how it went: dragging keeps the layout warm so linked bubbles follow like rubber bands and sway back on release. Labels always show and hover doesn't glow (tried, then dropped with Ancung the same day). A torch follows the mouse instead: the parts of the lines near the cursor catch a lime light (`--focus`, a radial gradient over the lines within reach) that fades with distance. Hover dims nothing (Ancung, 10 Nov: dimming the rest felt odd), its label turns bold, and the cursor is a magnet anywhere on the canvas: every bubble within 120 screen px leans toward it, the nearer the stronger (up to a third of the way, at most 8 units, eased), and its lines follow (drawn only, the layout never sees it; none while dragging or with reduced motion; Ancung, 11 Nov); drag a bubble, drag the background (or Space + drag, or the middle button, even over a bubble) to pan; the wheel works like the Builder's canvas (Ancung, 11 Nov): scroll or two fingers pan, Shift + scroll pans sideways, Ctrl/Cmd + scroll or a trackpad pinch zooms around the pointer (the Builder's `wheelPixels`, `wheelPan`, `wheelZoomFactor`); with the graph focused, + and - zoom, 0 is 100%, 1 or F fits; a two-finger pinch on a touch screen zooms (around the point between the fingers; a second finger ends a bubble drag; Ancung, 10 Nov), Fit to frame it again. Clicking a node glides the camera to it and zooms in (Esc, X or a click on empty canvas lets go; Fit goes back), and a card under the graph says what it is (`describe`), how often it was used, and its latest five calls as the chat's step rows that open to show what went in and came back (`callsOf`; a skill shows the calls of the tools under it, the Mind all of them) (Axel, via Ancung, 10 Nov). Reduced motion keeps the colours without moving dots or rings. It stops drawing while off screen. The layout and the camera are kept per Mind across mounts (`KEPT` in `MindGraph.tsx`), so sending from New chat (which moves to the thread's URL and mounts a new page) doesn't replay the settling, and only new bubbles warm the layout up; a state change or a count doesn't (Ancung, 10 Nov: every event of a reply set it bouncing). The first graph of a Mind on a page is settled before it is drawn and framed at once (`settle`, no bounce or zoom out); so is a graph that grows by three or more bubbles at once, since the first one often holds only the Mind before its skills and history arrive (they piled in and bounced, Ancung, 11 Nov: "too much jiggle"). One or two new bubbles only nudge it (0.25), and settling on its own uses more friction (0.74) than a drag does (0.86, so a released bubble still sways back), and the layout remembers where every bubble sat (`Sim.seen`), so one that drops out for a moment while a chat page mounts comes back to its place without warming anything up (Ancung, 11 Nov: switching chats replayed the zoom out and the jiggle). The panel draws only the chat on screen's run: ChatScreen passes its `activeHere` (`LiveView` `active`), so after switching chats it no longer shows the other chat's reply, trail or steps. - `components/LiveView.tsx`: the panel ("What {name} is doing", Live dot while streaming, the graph, the picked node, this reply's step rows, and "Waiting for you" from `GET …/approvals` linking to the chat that asked). Beside the chat from 1280 px (`xl`), 360 px wide, toggled with "Live view" in the chat header and remembered (`hellonear.chat.live`, read during render through `useLiveOpen` in `data/liveOpen.ts`, so moving between chats never flashes it open; Ancung, 10 Nov), opening and closing like the app's sidebar (the width slides 0 <-> 360 px, ease-in-out 200 ms, the panel fades; no slide on first paint); below 1280 px the same button opens it in a sheet. Phones have no chat header, so the Live view button sits in the phone's top bar on the chat (`MobileHeader`, opening the chat's drawer through `graph/data/liveDrawer.ts`; it floated over the messages until 11 Nov and hid words); on phones it opens as a drawer from the bottom (85% of the screen, swipe down to close; dragging on the graph moves the graph, not the drawer), on tablets as a sheet from the right (Ancung, 10 Nov). - Not checked in a browser yet. diff --git a/apps/fe/src/modules/graph/components/MindGraph.tsx b/apps/fe/src/modules/graph/components/MindGraph.tsx index 77c66c31..e6af6ee4 100644 --- a/apps/fe/src/modules/graph/components/MindGraph.tsx +++ b/apps/fe/src/modules/graph/components/MindGraph.tsx @@ -89,10 +89,14 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, } lastSelected.current = selected const first = sim.current === null + const before = sim.current?.bodies.size ?? 0 sim.current = syncSim(sim.current, nodes, links, mind) // The first graph of this Mind on this page shows settled and framed at once: no bounce, no - // zoom out (Ancung, 11 Nov). Later, only bubbles that are really new nudge it. - if (first && nodes.length > 1) { + // zoom out (Ancung, 11 Nov). So does a graph that grows by several bubbles at once: the first + // one often holds only the Mind, before its skills and history arrive, and they then piled in + // and bounced into place (Ancung, 11 Nov: "too much jiggle"). One or two new ones only nudge it. + const grew = sim.current.bodies.size - before + if ((first && nodes.length > 1) || grew >= 3) { settle(sim.current, new Map(nodes.map((n) => [n.id, n.kind]))) snap.current = true } diff --git a/apps/fe/src/modules/graph/data/sim.ts b/apps/fe/src/modules/graph/data/sim.ts index 9d1d0229..eb20a127 100644 --- a/apps/fe/src/modules/graph/data/sim.ts +++ b/apps/fe/src/modules/graph/data/sim.ts @@ -64,7 +64,9 @@ export function syncSim(prev: Sim | null, nodes: GraphNode[], links: GraphLink[] // reply set it bouncing again). const seen = new Map(prev?.seen) for (const b of prev?.bodies.values() ?? []) seen.set(b.id, { x: b.x, y: b.y }) - return { bodies, links, alpha: !prev ? 1 : added ? Math.max(prev.alpha, 0.5) : prev.alpha, seen } + // A bubble or two joining only nudges it (0.25, was 0.5: Ancung, 11 Nov, the entrance read as + // too much jiggle); many at once are settled before drawing (MindGraph). + return { bodies, links, alpha: !prev ? 1 : added ? Math.max(prev.alpha, 0.25) : prev.alpha, seen } } /** Run the layout until it is still (or `max` ticks), so a first graph shows settled, without the bounce. */ @@ -77,6 +79,8 @@ export function stepSim(sim: Sim, kinds: Map): boolean { if (sim.alpha < 0.004) return false const list = [...sim.bodies.values()] const a = sim.alpha + // The Mind is always pinned; another pinned bubble is one being dragged. + const friction = list.filter((b) => b.pinned).length > 1 ? 0.86 : 0.74 // Every pair pushes apart, more when close. for (let i = 0; i < list.length; i++) { for (let j = i + 1; j < list.length; j++) { @@ -128,9 +132,10 @@ export function stepSim(sim: Sim, kinds: Map): boolean { // A pull to the centre, and friction. b.vx -= b.x * 0.0025 * a b.vy -= b.y * 0.0025 * a - // A little less friction than a dead stop, so a pulled bubble sways back (Obsidian). - b.vx *= 0.86 - b.vy *= 0.86 + // While a bubble is dragged, a little less friction than a dead stop, so it sways back on + // release (Obsidian). Settling on its own, more, so it comes to rest without bouncing. + b.vx *= friction + b.vy *= friction b.x += b.vx b.y += b.vy } From 1a41ff05b9ceba7b91aeb62afc430e234d7c0b3c Mon Sep 17 00:00:00 2001 From: ancung Date: Wed, 11 Nov 2026 16:46:57 +0700 Subject: [PATCH 2/6] fix(fe): the graph's camera snaps only while opening, and glides afterwards Ancung, 11 Nov, right after the calmer entrance: the graph zoomed by itself. The previous commit framed the camera at once whenever three or more bubbles joined, which is right while the graph opens but, during a reply that used several new tools, made the view jump. Now it snaps only while opening (nothing but the Mind before); later it glides to the new frame, and only if the owner hasn't moved the camera. Cause inferred from the code and the screenshot (a reply was running), not reproduced. Tests: typecheck, lint, vitest 266/266. Checked in Chrome: on load the whole graph is framed and still. Co-Authored-By: Claude Opus 5.5 --- apps/fe/CLAUDE.md | 2 +- apps/fe/src/modules/graph/components/MindGraph.tsx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/fe/CLAUDE.md b/apps/fe/CLAUDE.md index 3f874475..f30f494a 100644 --- a/apps/fe/CLAUDE.md +++ b/apps/fe/CLAUDE.md @@ -102,7 +102,7 @@ Chat (`/minds/[mindId]/chat` and `/chat/[threadId]`, `src/modules/chat`, design Live view (beside the chat, `src/modules/graph`, design C2 "What Penny is doing", #17), like Obsidian's graph view (Axel, via Ancung, 10 Nov): - `data/graph.ts` `buildGraph` (app bubbles follow engine/src/graph.ts: every app's tools, the track apps of #211 included, are one App bubble, hung off the skill that uses it, so it reads Mind, skill, app; named "Your Notion" beside the Notion skill, with its logo from `APPS`; Ancung, 11 Nov: the track apps showed twice and without a logo): the Mind in the centre, each equipped skill (not blocked ones), the tools, apps and wallet each skill reaches (`GET /skills` `tools` and `connections`), then anything the events touched; node ids are the engine's (`nodeIdFor`, docs/api-contract.md §4), so live events light the nodes the history built. `uses` counts calls, the last state is running, waiting (an approval), ok, error or denied (`policy_denied`, `wallet_frozen`). A meeting with a Meet link lights Google Meet too. Only live states pulse (`liveStates`): running for the run on screen, waiting for an approval still in `GET …/approvals`; history only sizes the bubbles (Ancung, 10 Nov: Meet and Wallet pulsed from an old, declined approval, which never gets a result event). Mastra's `updateWorkingMemory` is the Memory node. - Events: the last 7 days from `GET /minds/{id}/events?limit=2000`, plus `ChatRunProvider`'s run on screen; read again when a run ends. -- `components/MindGraph.tsx` draws on a canvas: `data/sim.ts` (every pair pushes apart, links pull like springs, a pull to the centre, cools down; the Mind stays in the centre), bubbles coloured by kind from the `node-*` tokens (read from CSS, again when the theme changes), the Mind's avatar in the centre, Gmail, Google Calendar and Google Meet with their own logos (`AppLogos`, serialised to images), labels under every bubble, drawn last with an outline in the background colour so lines and bubbles never hide them (tools quieter). The layout keeps room for the labels (stronger push, longer links; Ancung, 10 Nov: the first one was too tight): each bubble with its label is a box and overlapping boxes are pushed apart, bubbles keep off lines that aren't theirs, and a tool several skills share hangs off the first one only, a tree, so lines don't cross (`tests/graph.test.ts` checks a seven-skill Mind settles with no box on another and no bubble on a line). The built-in HelloNear guide isn't drawn; a job is named from its id ("wallet-watch" reads "Wallet watch"). While a tool works, dots travel along the links from the Mind and its bubble pulses (blue running, amber waiting); a result rings green, a failure or a blocked payment red. The reply on screen leaves a trail (Ancung, 10 Nov: a 1 s calendar call showed nothing): the links from the Mind to every node it used stay blue with slow dots while it streams, and stay softly lit for the last reply, with a ring on those bubbles. Pulses are timed from when this page saw the state change, not the event's server time, and only the run on screen pulses (history loading in after the first draw lit up the whole graph on open, Ancung, 10 Nov). From Obsidian's graph (Axel's screen recording, 10 Nov), keeping the colours that say what each node is and how it went: dragging keeps the layout warm so linked bubbles follow like rubber bands and sway back on release. Labels always show and hover doesn't glow (tried, then dropped with Ancung the same day). A torch follows the mouse instead: the parts of the lines near the cursor catch a lime light (`--focus`, a radial gradient over the lines within reach) that fades with distance. Hover dims nothing (Ancung, 10 Nov: dimming the rest felt odd), its label turns bold, and the cursor is a magnet anywhere on the canvas: every bubble within 120 screen px leans toward it, the nearer the stronger (up to a third of the way, at most 8 units, eased), and its lines follow (drawn only, the layout never sees it; none while dragging or with reduced motion; Ancung, 11 Nov); drag a bubble, drag the background (or Space + drag, or the middle button, even over a bubble) to pan; the wheel works like the Builder's canvas (Ancung, 11 Nov): scroll or two fingers pan, Shift + scroll pans sideways, Ctrl/Cmd + scroll or a trackpad pinch zooms around the pointer (the Builder's `wheelPixels`, `wheelPan`, `wheelZoomFactor`); with the graph focused, + and - zoom, 0 is 100%, 1 or F fits; a two-finger pinch on a touch screen zooms (around the point between the fingers; a second finger ends a bubble drag; Ancung, 10 Nov), Fit to frame it again. Clicking a node glides the camera to it and zooms in (Esc, X or a click on empty canvas lets go; Fit goes back), and a card under the graph says what it is (`describe`), how often it was used, and its latest five calls as the chat's step rows that open to show what went in and came back (`callsOf`; a skill shows the calls of the tools under it, the Mind all of them) (Axel, via Ancung, 10 Nov). Reduced motion keeps the colours without moving dots or rings. It stops drawing while off screen. The layout and the camera are kept per Mind across mounts (`KEPT` in `MindGraph.tsx`), so sending from New chat (which moves to the thread's URL and mounts a new page) doesn't replay the settling, and only new bubbles warm the layout up; a state change or a count doesn't (Ancung, 10 Nov: every event of a reply set it bouncing). The first graph of a Mind on a page is settled before it is drawn and framed at once (`settle`, no bounce or zoom out); so is a graph that grows by three or more bubbles at once, since the first one often holds only the Mind before its skills and history arrive (they piled in and bounced, Ancung, 11 Nov: "too much jiggle"). One or two new bubbles only nudge it (0.25), and settling on its own uses more friction (0.74) than a drag does (0.86, so a released bubble still sways back), and the layout remembers where every bubble sat (`Sim.seen`), so one that drops out for a moment while a chat page mounts comes back to its place without warming anything up (Ancung, 11 Nov: switching chats replayed the zoom out and the jiggle). The panel draws only the chat on screen's run: ChatScreen passes its `activeHere` (`LiveView` `active`), so after switching chats it no longer shows the other chat's reply, trail or steps. +- `components/MindGraph.tsx` draws on a canvas: `data/sim.ts` (every pair pushes apart, links pull like springs, a pull to the centre, cools down; the Mind stays in the centre), bubbles coloured by kind from the `node-*` tokens (read from CSS, again when the theme changes), the Mind's avatar in the centre, Gmail, Google Calendar and Google Meet with their own logos (`AppLogos`, serialised to images), labels under every bubble, drawn last with an outline in the background colour so lines and bubbles never hide them (tools quieter). The layout keeps room for the labels (stronger push, longer links; Ancung, 10 Nov: the first one was too tight): each bubble with its label is a box and overlapping boxes are pushed apart, bubbles keep off lines that aren't theirs, and a tool several skills share hangs off the first one only, a tree, so lines don't cross (`tests/graph.test.ts` checks a seven-skill Mind settles with no box on another and no bubble on a line). The built-in HelloNear guide isn't drawn; a job is named from its id ("wallet-watch" reads "Wallet watch"). While a tool works, dots travel along the links from the Mind and its bubble pulses (blue running, amber waiting); a result rings green, a failure or a blocked payment red. The reply on screen leaves a trail (Ancung, 10 Nov: a 1 s calendar call showed nothing): the links from the Mind to every node it used stay blue with slow dots while it streams, and stay softly lit for the last reply, with a ring on those bubbles. Pulses are timed from when this page saw the state change, not the event's server time, and only the run on screen pulses (history loading in after the first draw lit up the whole graph on open, Ancung, 10 Nov). From Obsidian's graph (Axel's screen recording, 10 Nov), keeping the colours that say what each node is and how it went: dragging keeps the layout warm so linked bubbles follow like rubber bands and sway back on release. Labels always show and hover doesn't glow (tried, then dropped with Ancung the same day). A torch follows the mouse instead: the parts of the lines near the cursor catch a lime light (`--focus`, a radial gradient over the lines within reach) that fades with distance. Hover dims nothing (Ancung, 10 Nov: dimming the rest felt odd), its label turns bold, and the cursor is a magnet anywhere on the canvas: every bubble within 120 screen px leans toward it, the nearer the stronger (up to a third of the way, at most 8 units, eased), and its lines follow (drawn only, the layout never sees it; none while dragging or with reduced motion; Ancung, 11 Nov); drag a bubble, drag the background (or Space + drag, or the middle button, even over a bubble) to pan; the wheel works like the Builder's canvas (Ancung, 11 Nov): scroll or two fingers pan, Shift + scroll pans sideways, Ctrl/Cmd + scroll or a trackpad pinch zooms around the pointer (the Builder's `wheelPixels`, `wheelPan`, `wheelZoomFactor`); with the graph focused, + and - zoom, 0 is 100%, 1 or F fits; a two-finger pinch on a touch screen zooms (around the point between the fingers; a second finger ends a bubble drag; Ancung, 10 Nov), Fit to frame it again. Clicking a node glides the camera to it and zooms in (Esc, X or a click on empty canvas lets go; Fit goes back), and a card under the graph says what it is (`describe`), how often it was used, and its latest five calls as the chat's step rows that open to show what went in and came back (`callsOf`; a skill shows the calls of the tools under it, the Mind all of them) (Axel, via Ancung, 10 Nov). Reduced motion keeps the colours without moving dots or rings. It stops drawing while off screen. The layout and the camera are kept per Mind across mounts (`KEPT` in `MindGraph.tsx`), so sending from New chat (which moves to the thread's URL and mounts a new page) doesn't replay the settling, and only new bubbles warm the layout up; a state change or a count doesn't (Ancung, 10 Nov: every event of a reply set it bouncing). The first graph of a Mind on a page is settled before it is drawn and framed at once (`settle`, no bounce or zoom out); so is a graph that grows by three or more bubbles at once (framed at once only while opening, when nothing but the Mind was there; later the camera glides there, and only if the owner hasn't moved it, since a snap during a reply read as the graph zooming by itself), since the first one often holds only the Mind before its skills and history arrive (they piled in and bounced, Ancung, 11 Nov: "too much jiggle"). One or two new bubbles only nudge it (0.25), and settling on its own uses more friction (0.74) than a drag does (0.86, so a released bubble still sways back), and the layout remembers where every bubble sat (`Sim.seen`), so one that drops out for a moment while a chat page mounts comes back to its place without warming anything up (Ancung, 11 Nov: switching chats replayed the zoom out and the jiggle). The panel draws only the chat on screen's run: ChatScreen passes its `activeHere` (`LiveView` `active`), so after switching chats it no longer shows the other chat's reply, trail or steps. - `components/LiveView.tsx`: the panel ("What {name} is doing", Live dot while streaming, the graph, the picked node, this reply's step rows, and "Waiting for you" from `GET …/approvals` linking to the chat that asked). Beside the chat from 1280 px (`xl`), 360 px wide, toggled with "Live view" in the chat header and remembered (`hellonear.chat.live`, read during render through `useLiveOpen` in `data/liveOpen.ts`, so moving between chats never flashes it open; Ancung, 10 Nov), opening and closing like the app's sidebar (the width slides 0 <-> 360 px, ease-in-out 200 ms, the panel fades; no slide on first paint); below 1280 px the same button opens it in a sheet. Phones have no chat header, so the Live view button sits in the phone's top bar on the chat (`MobileHeader`, opening the chat's drawer through `graph/data/liveDrawer.ts`; it floated over the messages until 11 Nov and hid words); on phones it opens as a drawer from the bottom (85% of the screen, swipe down to close; dragging on the graph moves the graph, not the drawer), on tablets as a sheet from the right (Ancung, 10 Nov). - Not checked in a browser yet. diff --git a/apps/fe/src/modules/graph/components/MindGraph.tsx b/apps/fe/src/modules/graph/components/MindGraph.tsx index e6af6ee4..7935b715 100644 --- a/apps/fe/src/modules/graph/components/MindGraph.tsx +++ b/apps/fe/src/modules/graph/components/MindGraph.tsx @@ -98,7 +98,11 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, const grew = sim.current.bodies.size - before if ((first && nodes.length > 1) || grew >= 3) { settle(sim.current, new Map(nodes.map((n) => [n.id, n.kind]))) - snap.current = true + // Frame it at once only while the graph is opening (nothing but the Mind before). Later, the + // camera glides to the new frame, and only if the owner hasn't moved it: snapping during a + // reply read as the graph zooming by itself (Ancung, 11 Nov). + if (first || before <= 1) snap.current = true + else fitting.current = true } const now = performance.now() for (const n of nodes) { From c00a4d96c4c82d2368e25b885238255129efdb60 Mon Sep 17 00:00:00 2001 From: ancung Date: Wed, 11 Nov 2026 16:52:04 +0700 Subject: [PATCH 3/6] fix(fe): every chat opens its graph framed, never zoomed into the Mind Ancung, 11 Nov: switching to earlier chats, the live view's graph always opened zoomed into the Mind. The camera is kept per Mind across chat pages (`KEPT`) so the graph doesn't replay its settling, and it kept whatever the owner had last done: a zoom, a pan, or a click on a bubble (which zooms to it) turned automatic framing off for good. And a page that opened while the graph held only the Mind framed that one bubble, then never reframed when the others came back a few at a time. Now: - A new page keeps the layout but puts the camera back on automatic framing, framed at once. - The camera never frames the Mind alone; a pending frame waits for the other bubbles. - While automatic, a change in the number of bubbles reframes it, gliding. Tests: typecheck, lint, vitest 266/266. Checked in Chrome: zoomed into a bubble, opened New chat, came back: the whole graph was framed. Co-Authored-By: Claude Opus 5.5 --- apps/fe/CLAUDE.md | 2 +- .../modules/graph/components/MindGraph.tsx | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/fe/CLAUDE.md b/apps/fe/CLAUDE.md index f30f494a..9a8b8cf0 100644 --- a/apps/fe/CLAUDE.md +++ b/apps/fe/CLAUDE.md @@ -102,7 +102,7 @@ Chat (`/minds/[mindId]/chat` and `/chat/[threadId]`, `src/modules/chat`, design Live view (beside the chat, `src/modules/graph`, design C2 "What Penny is doing", #17), like Obsidian's graph view (Axel, via Ancung, 10 Nov): - `data/graph.ts` `buildGraph` (app bubbles follow engine/src/graph.ts: every app's tools, the track apps of #211 included, are one App bubble, hung off the skill that uses it, so it reads Mind, skill, app; named "Your Notion" beside the Notion skill, with its logo from `APPS`; Ancung, 11 Nov: the track apps showed twice and without a logo): the Mind in the centre, each equipped skill (not blocked ones), the tools, apps and wallet each skill reaches (`GET /skills` `tools` and `connections`), then anything the events touched; node ids are the engine's (`nodeIdFor`, docs/api-contract.md §4), so live events light the nodes the history built. `uses` counts calls, the last state is running, waiting (an approval), ok, error or denied (`policy_denied`, `wallet_frozen`). A meeting with a Meet link lights Google Meet too. Only live states pulse (`liveStates`): running for the run on screen, waiting for an approval still in `GET …/approvals`; history only sizes the bubbles (Ancung, 10 Nov: Meet and Wallet pulsed from an old, declined approval, which never gets a result event). Mastra's `updateWorkingMemory` is the Memory node. - Events: the last 7 days from `GET /minds/{id}/events?limit=2000`, plus `ChatRunProvider`'s run on screen; read again when a run ends. -- `components/MindGraph.tsx` draws on a canvas: `data/sim.ts` (every pair pushes apart, links pull like springs, a pull to the centre, cools down; the Mind stays in the centre), bubbles coloured by kind from the `node-*` tokens (read from CSS, again when the theme changes), the Mind's avatar in the centre, Gmail, Google Calendar and Google Meet with their own logos (`AppLogos`, serialised to images), labels under every bubble, drawn last with an outline in the background colour so lines and bubbles never hide them (tools quieter). The layout keeps room for the labels (stronger push, longer links; Ancung, 10 Nov: the first one was too tight): each bubble with its label is a box and overlapping boxes are pushed apart, bubbles keep off lines that aren't theirs, and a tool several skills share hangs off the first one only, a tree, so lines don't cross (`tests/graph.test.ts` checks a seven-skill Mind settles with no box on another and no bubble on a line). The built-in HelloNear guide isn't drawn; a job is named from its id ("wallet-watch" reads "Wallet watch"). While a tool works, dots travel along the links from the Mind and its bubble pulses (blue running, amber waiting); a result rings green, a failure or a blocked payment red. The reply on screen leaves a trail (Ancung, 10 Nov: a 1 s calendar call showed nothing): the links from the Mind to every node it used stay blue with slow dots while it streams, and stay softly lit for the last reply, with a ring on those bubbles. Pulses are timed from when this page saw the state change, not the event's server time, and only the run on screen pulses (history loading in after the first draw lit up the whole graph on open, Ancung, 10 Nov). From Obsidian's graph (Axel's screen recording, 10 Nov), keeping the colours that say what each node is and how it went: dragging keeps the layout warm so linked bubbles follow like rubber bands and sway back on release. Labels always show and hover doesn't glow (tried, then dropped with Ancung the same day). A torch follows the mouse instead: the parts of the lines near the cursor catch a lime light (`--focus`, a radial gradient over the lines within reach) that fades with distance. Hover dims nothing (Ancung, 10 Nov: dimming the rest felt odd), its label turns bold, and the cursor is a magnet anywhere on the canvas: every bubble within 120 screen px leans toward it, the nearer the stronger (up to a third of the way, at most 8 units, eased), and its lines follow (drawn only, the layout never sees it; none while dragging or with reduced motion; Ancung, 11 Nov); drag a bubble, drag the background (or Space + drag, or the middle button, even over a bubble) to pan; the wheel works like the Builder's canvas (Ancung, 11 Nov): scroll or two fingers pan, Shift + scroll pans sideways, Ctrl/Cmd + scroll or a trackpad pinch zooms around the pointer (the Builder's `wheelPixels`, `wheelPan`, `wheelZoomFactor`); with the graph focused, + and - zoom, 0 is 100%, 1 or F fits; a two-finger pinch on a touch screen zooms (around the point between the fingers; a second finger ends a bubble drag; Ancung, 10 Nov), Fit to frame it again. Clicking a node glides the camera to it and zooms in (Esc, X or a click on empty canvas lets go; Fit goes back), and a card under the graph says what it is (`describe`), how often it was used, and its latest five calls as the chat's step rows that open to show what went in and came back (`callsOf`; a skill shows the calls of the tools under it, the Mind all of them) (Axel, via Ancung, 10 Nov). Reduced motion keeps the colours without moving dots or rings. It stops drawing while off screen. The layout and the camera are kept per Mind across mounts (`KEPT` in `MindGraph.tsx`), so sending from New chat (which moves to the thread's URL and mounts a new page) doesn't replay the settling, and only new bubbles warm the layout up; a state change or a count doesn't (Ancung, 10 Nov: every event of a reply set it bouncing). The first graph of a Mind on a page is settled before it is drawn and framed at once (`settle`, no bounce or zoom out); so is a graph that grows by three or more bubbles at once (framed at once only while opening, when nothing but the Mind was there; later the camera glides there, and only if the owner hasn't moved it, since a snap during a reply read as the graph zooming by itself), since the first one often holds only the Mind before its skills and history arrive (they piled in and bounced, Ancung, 11 Nov: "too much jiggle"). One or two new bubbles only nudge it (0.25), and settling on its own uses more friction (0.74) than a drag does (0.86, so a released bubble still sways back), and the layout remembers where every bubble sat (`Sim.seen`), so one that drops out for a moment while a chat page mounts comes back to its place without warming anything up (Ancung, 11 Nov: switching chats replayed the zoom out and the jiggle). The panel draws only the chat on screen's run: ChatScreen passes its `activeHere` (`LiveView` `active`), so after switching chats it no longer shows the other chat's reply, trail or steps. +- `components/MindGraph.tsx` draws on a canvas: `data/sim.ts` (every pair pushes apart, links pull like springs, a pull to the centre, cools down; the Mind stays in the centre), bubbles coloured by kind from the `node-*` tokens (read from CSS, again when the theme changes), the Mind's avatar in the centre, Gmail, Google Calendar and Google Meet with their own logos (`AppLogos`, serialised to images), labels under every bubble, drawn last with an outline in the background colour so lines and bubbles never hide them (tools quieter). The layout keeps room for the labels (stronger push, longer links; Ancung, 10 Nov: the first one was too tight): each bubble with its label is a box and overlapping boxes are pushed apart, bubbles keep off lines that aren't theirs, and a tool several skills share hangs off the first one only, a tree, so lines don't cross (`tests/graph.test.ts` checks a seven-skill Mind settles with no box on another and no bubble on a line). The built-in HelloNear guide isn't drawn; a job is named from its id ("wallet-watch" reads "Wallet watch"). While a tool works, dots travel along the links from the Mind and its bubble pulses (blue running, amber waiting); a result rings green, a failure or a blocked payment red. The reply on screen leaves a trail (Ancung, 10 Nov: a 1 s calendar call showed nothing): the links from the Mind to every node it used stay blue with slow dots while it streams, and stay softly lit for the last reply, with a ring on those bubbles. Pulses are timed from when this page saw the state change, not the event's server time, and only the run on screen pulses (history loading in after the first draw lit up the whole graph on open, Ancung, 10 Nov). From Obsidian's graph (Axel's screen recording, 10 Nov), keeping the colours that say what each node is and how it went: dragging keeps the layout warm so linked bubbles follow like rubber bands and sway back on release. Labels always show and hover doesn't glow (tried, then dropped with Ancung the same day). A torch follows the mouse instead: the parts of the lines near the cursor catch a lime light (`--focus`, a radial gradient over the lines within reach) that fades with distance. Hover dims nothing (Ancung, 10 Nov: dimming the rest felt odd), its label turns bold, and the cursor is a magnet anywhere on the canvas: every bubble within 120 screen px leans toward it, the nearer the stronger (up to a third of the way, at most 8 units, eased), and its lines follow (drawn only, the layout never sees it; none while dragging or with reduced motion; Ancung, 11 Nov); drag a bubble, drag the background (or Space + drag, or the middle button, even over a bubble) to pan; the wheel works like the Builder's canvas (Ancung, 11 Nov): scroll or two fingers pan, Shift + scroll pans sideways, Ctrl/Cmd + scroll or a trackpad pinch zooms around the pointer (the Builder's `wheelPixels`, `wheelPan`, `wheelZoomFactor`); with the graph focused, + and - zoom, 0 is 100%, 1 or F fits; a two-finger pinch on a touch screen zooms (around the point between the fingers; a second finger ends a bubble drag; Ancung, 10 Nov), Fit to frame it again. Clicking a node glides the camera to it and zooms in (Esc, X or a click on empty canvas lets go; Fit goes back), and a card under the graph says what it is (`describe`), how often it was used, and its latest five calls as the chat's step rows that open to show what went in and came back (`callsOf`; a skill shows the calls of the tools under it, the Mind all of them) (Axel, via Ancung, 10 Nov). Reduced motion keeps the colours without moving dots or rings. It stops drawing while off screen. The layout and the camera are kept per Mind across mounts (`KEPT` in `MindGraph.tsx`), but a new page puts the camera back on automatic framing and frames the kept layout at once (a zoom or a click on a bubble used to stick, so every chat opened after it was zoomed into the Mind, Ancung, 11 Nov); the camera never frames the Mind alone, and while automatic it reframes, gliding, whenever the number of bubbles changes, so sending from New chat (which moves to the thread's URL and mounts a new page) doesn't replay the settling, and only new bubbles warm the layout up; a state change or a count doesn't (Ancung, 10 Nov: every event of a reply set it bouncing). The first graph of a Mind on a page is settled before it is drawn and framed at once (`settle`, no bounce or zoom out); so is a graph that grows by three or more bubbles at once (framed at once only while opening, when nothing but the Mind was there; later the camera glides there, and only if the owner hasn't moved it, since a snap during a reply read as the graph zooming by itself), since the first one often holds only the Mind before its skills and history arrive (they piled in and bounced, Ancung, 11 Nov: "too much jiggle"). One or two new bubbles only nudge it (0.25), and settling on its own uses more friction (0.74) than a drag does (0.86, so a released bubble still sways back), and the layout remembers where every bubble sat (`Sim.seen`), so one that drops out for a moment while a chat page mounts comes back to its place without warming anything up (Ancung, 11 Nov: switching chats replayed the zoom out and the jiggle). The panel draws only the chat on screen's run: ChatScreen passes its `activeHere` (`LiveView` `active`), so after switching chats it no longer shows the other chat's reply, trail or steps. - `components/LiveView.tsx`: the panel ("What {name} is doing", Live dot while streaming, the graph, the picked node, this reply's step rows, and "Waiting for you" from `GET …/approvals` linking to the chat that asked). Beside the chat from 1280 px (`xl`), 360 px wide, toggled with "Live view" in the chat header and remembered (`hellonear.chat.live`, read during render through `useLiveOpen` in `data/liveOpen.ts`, so moving between chats never flashes it open; Ancung, 10 Nov), opening and closing like the app's sidebar (the width slides 0 <-> 360 px, ease-in-out 200 ms, the panel fades; no slide on first paint); below 1280 px the same button opens it in a sheet. Phones have no chat header, so the Live view button sits in the phone's top bar on the chat (`MobileHeader`, opening the chat's drawer through `graph/data/liveDrawer.ts`; it floated over the messages until 11 Nov and hid words); on phones it opens as a drawer from the bottom (85% of the screen, swipe down to close; dragging on the graph moves the graph, not the drawer), on tablets as a sheet from the right (Ancung, 10 Nov). - Not checked in a browser yet. diff --git a/apps/fe/src/modules/graph/components/MindGraph.tsx b/apps/fe/src/modules/graph/components/MindGraph.tsx index 7935b715..bdac0ce6 100644 --- a/apps/fe/src/modules/graph/components/MindGraph.tsx +++ b/apps/fe/src/modules/graph/components/MindGraph.tsx @@ -59,14 +59,20 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, // not from the event's own time, which comes from the server's clock and can arrive late // (Ancung, 10 Nov: a 1 s calendar call never lit up). const seen = useRef(new Map()) - const view = useRef(KEPT.get(mindId)?.view ?? { x: 0, y: 0, k: 1, auto: true }) + // The camera kept from the last chat, but always back on automatic framing: a zoom or a click on + // a bubble (which zooms to it) used to stick, so every chat opened after it was zoomed into the + // Mind (Ancung, 11 Nov). The layout itself is kept, so nothing replays. + const view = useRef({ ...(KEPT.get(mindId)?.view ?? { x: 0, y: 0, k: 1 }), auto: true }) // The node the camera is gliding to after a click (Axel, via Ancung, 10 Nov: zoom to it). const focus = useRef(null) const lastSelected = useRef(null) - // Frame the layout at once on the next draw, instead of easing toward it. - const snap = useRef(false) + // Frame the layout at once on the next draw, instead of easing toward it. A page that finds a + // kept layout frames it at once too, without a glide. + const snap = useRef(KEPT.has(mindId)) // Fit was pressed: glide to the frame until there. const fitting = useRef(false) + // How many bubbles the camera last framed, so a change reframes it. + const framedCount = useRef(0) const hover = useRef(null) // How far each bubble leans toward the cursor right now (drawn only), and whether one is dragged. const magnet = useRef(new Map()) @@ -201,6 +207,9 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, } const to = framing({ x0, y0, x1, y1 }, size) const v = view.current + // The Mind alone is no frame: zooming to it is what stuck when a chat page opened before the + // other bubbles were back (Ancung, 11 Nov). Wait for them, keeping a pending snap. + if (bodies.length <= 1) return if (snap.current) { snap.current = false v.k = to.k @@ -236,6 +245,12 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, if (!s) return const kinds = new Map(data.current.nodes.map((n) => [n.id, n.kind])) const moving = stepSim(s, kinds) + // While the camera is automatic, a change in how many bubbles there are reframes it (gliding), + // so bubbles that come back one or two at a time are never left outside it. + if (view.current.auto && s.bodies.size !== framedCount.current && s.bodies.size > 1) { + framedCount.current = s.bodies.size + fitting.current = true + } if (view.current.auto && (moving || snap.current || fitting.current || now < 1500)) fit() // Glide to the picked node and zoom in a little; a jump with reduced motion. const f = focus.current ? s.bodies.get(focus.current) : null From 5aff59d703ce84a5b5c5f761985592cc4b1161bb Mon Sep 17 00:00:00 2001 From: ancung Date: Wed, 11 Nov 2026 17:04:25 +0700 Subject: [PATCH 4/6] feat(fe): the live view comes in with an ease-out zoom out Ancung, 11 Nov: the graph should come in zooming out, easing to a stop. The first real frame of a Mind's graph on a page now starts at 1.35 times the frame's zoom, scaled about the panel's middle, and eases out to the frame over 700 ms (quart). It runs once per page: switching chats finds the layout kept and frames it at once, so it doesn't replay (he didn't want replays on every chat). It waits for more than the Mind, so a graph that opens with only the Mind gets it when the others arrive. Reduced motion frames at once. Tests: typecheck, lint, vitest 266/266. In Chrome the end frame is right; the 700 ms itself is too quick to catch in a screenshot, so the feel is for Ancung to judge. Co-Authored-By: Claude Opus 5.5 --- apps/fe/CLAUDE.md | 2 +- .../modules/graph/components/MindGraph.tsx | 36 +++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/apps/fe/CLAUDE.md b/apps/fe/CLAUDE.md index 9a8b8cf0..71ce3b5d 100644 --- a/apps/fe/CLAUDE.md +++ b/apps/fe/CLAUDE.md @@ -102,7 +102,7 @@ Chat (`/minds/[mindId]/chat` and `/chat/[threadId]`, `src/modules/chat`, design Live view (beside the chat, `src/modules/graph`, design C2 "What Penny is doing", #17), like Obsidian's graph view (Axel, via Ancung, 10 Nov): - `data/graph.ts` `buildGraph` (app bubbles follow engine/src/graph.ts: every app's tools, the track apps of #211 included, are one App bubble, hung off the skill that uses it, so it reads Mind, skill, app; named "Your Notion" beside the Notion skill, with its logo from `APPS`; Ancung, 11 Nov: the track apps showed twice and without a logo): the Mind in the centre, each equipped skill (not blocked ones), the tools, apps and wallet each skill reaches (`GET /skills` `tools` and `connections`), then anything the events touched; node ids are the engine's (`nodeIdFor`, docs/api-contract.md §4), so live events light the nodes the history built. `uses` counts calls, the last state is running, waiting (an approval), ok, error or denied (`policy_denied`, `wallet_frozen`). A meeting with a Meet link lights Google Meet too. Only live states pulse (`liveStates`): running for the run on screen, waiting for an approval still in `GET …/approvals`; history only sizes the bubbles (Ancung, 10 Nov: Meet and Wallet pulsed from an old, declined approval, which never gets a result event). Mastra's `updateWorkingMemory` is the Memory node. - Events: the last 7 days from `GET /minds/{id}/events?limit=2000`, plus `ChatRunProvider`'s run on screen; read again when a run ends. -- `components/MindGraph.tsx` draws on a canvas: `data/sim.ts` (every pair pushes apart, links pull like springs, a pull to the centre, cools down; the Mind stays in the centre), bubbles coloured by kind from the `node-*` tokens (read from CSS, again when the theme changes), the Mind's avatar in the centre, Gmail, Google Calendar and Google Meet with their own logos (`AppLogos`, serialised to images), labels under every bubble, drawn last with an outline in the background colour so lines and bubbles never hide them (tools quieter). The layout keeps room for the labels (stronger push, longer links; Ancung, 10 Nov: the first one was too tight): each bubble with its label is a box and overlapping boxes are pushed apart, bubbles keep off lines that aren't theirs, and a tool several skills share hangs off the first one only, a tree, so lines don't cross (`tests/graph.test.ts` checks a seven-skill Mind settles with no box on another and no bubble on a line). The built-in HelloNear guide isn't drawn; a job is named from its id ("wallet-watch" reads "Wallet watch"). While a tool works, dots travel along the links from the Mind and its bubble pulses (blue running, amber waiting); a result rings green, a failure or a blocked payment red. The reply on screen leaves a trail (Ancung, 10 Nov: a 1 s calendar call showed nothing): the links from the Mind to every node it used stay blue with slow dots while it streams, and stay softly lit for the last reply, with a ring on those bubbles. Pulses are timed from when this page saw the state change, not the event's server time, and only the run on screen pulses (history loading in after the first draw lit up the whole graph on open, Ancung, 10 Nov). From Obsidian's graph (Axel's screen recording, 10 Nov), keeping the colours that say what each node is and how it went: dragging keeps the layout warm so linked bubbles follow like rubber bands and sway back on release. Labels always show and hover doesn't glow (tried, then dropped with Ancung the same day). A torch follows the mouse instead: the parts of the lines near the cursor catch a lime light (`--focus`, a radial gradient over the lines within reach) that fades with distance. Hover dims nothing (Ancung, 10 Nov: dimming the rest felt odd), its label turns bold, and the cursor is a magnet anywhere on the canvas: every bubble within 120 screen px leans toward it, the nearer the stronger (up to a third of the way, at most 8 units, eased), and its lines follow (drawn only, the layout never sees it; none while dragging or with reduced motion; Ancung, 11 Nov); drag a bubble, drag the background (or Space + drag, or the middle button, even over a bubble) to pan; the wheel works like the Builder's canvas (Ancung, 11 Nov): scroll or two fingers pan, Shift + scroll pans sideways, Ctrl/Cmd + scroll or a trackpad pinch zooms around the pointer (the Builder's `wheelPixels`, `wheelPan`, `wheelZoomFactor`); with the graph focused, + and - zoom, 0 is 100%, 1 or F fits; a two-finger pinch on a touch screen zooms (around the point between the fingers; a second finger ends a bubble drag; Ancung, 10 Nov), Fit to frame it again. Clicking a node glides the camera to it and zooms in (Esc, X or a click on empty canvas lets go; Fit goes back), and a card under the graph says what it is (`describe`), how often it was used, and its latest five calls as the chat's step rows that open to show what went in and came back (`callsOf`; a skill shows the calls of the tools under it, the Mind all of them) (Axel, via Ancung, 10 Nov). Reduced motion keeps the colours without moving dots or rings. It stops drawing while off screen. The layout and the camera are kept per Mind across mounts (`KEPT` in `MindGraph.tsx`), but a new page puts the camera back on automatic framing and frames the kept layout at once (a zoom or a click on a bubble used to stick, so every chat opened after it was zoomed into the Mind, Ancung, 11 Nov); the camera never frames the Mind alone, and while automatic it reframes, gliding, whenever the number of bubbles changes, so sending from New chat (which moves to the thread's URL and mounts a new page) doesn't replay the settling, and only new bubbles warm the layout up; a state change or a count doesn't (Ancung, 10 Nov: every event of a reply set it bouncing). The first graph of a Mind on a page is settled before it is drawn and framed at once (`settle`, no bounce or zoom out); so is a graph that grows by three or more bubbles at once (framed at once only while opening, when nothing but the Mind was there; later the camera glides there, and only if the owner hasn't moved it, since a snap during a reply read as the graph zooming by itself), since the first one often holds only the Mind before its skills and history arrive (they piled in and bounced, Ancung, 11 Nov: "too much jiggle"). One or two new bubbles only nudge it (0.25), and settling on its own uses more friction (0.74) than a drag does (0.86, so a released bubble still sways back), and the layout remembers where every bubble sat (`Sim.seen`), so one that drops out for a moment while a chat page mounts comes back to its place without warming anything up (Ancung, 11 Nov: switching chats replayed the zoom out and the jiggle). The panel draws only the chat on screen's run: ChatScreen passes its `activeHere` (`LiveView` `active`), so after switching chats it no longer shows the other chat's reply, trail or steps. +- `components/MindGraph.tsx` draws on a canvas: `data/sim.ts` (every pair pushes apart, links pull like springs, a pull to the centre, cools down; the Mind stays in the centre), bubbles coloured by kind from the `node-*` tokens (read from CSS, again when the theme changes), the Mind's avatar in the centre, Gmail, Google Calendar and Google Meet with their own logos (`AppLogos`, serialised to images), labels under every bubble, drawn last with an outline in the background colour so lines and bubbles never hide them (tools quieter). The layout keeps room for the labels (stronger push, longer links; Ancung, 10 Nov: the first one was too tight): each bubble with its label is a box and overlapping boxes are pushed apart, bubbles keep off lines that aren't theirs, and a tool several skills share hangs off the first one only, a tree, so lines don't cross (`tests/graph.test.ts` checks a seven-skill Mind settles with no box on another and no bubble on a line). The built-in HelloNear guide isn't drawn; a job is named from its id ("wallet-watch" reads "Wallet watch"). While a tool works, dots travel along the links from the Mind and its bubble pulses (blue running, amber waiting); a result rings green, a failure or a blocked payment red. The reply on screen leaves a trail (Ancung, 10 Nov: a 1 s calendar call showed nothing): the links from the Mind to every node it used stay blue with slow dots while it streams, and stay softly lit for the last reply, with a ring on those bubbles. Pulses are timed from when this page saw the state change, not the event's server time, and only the run on screen pulses (history loading in after the first draw lit up the whole graph on open, Ancung, 10 Nov). From Obsidian's graph (Axel's screen recording, 10 Nov), keeping the colours that say what each node is and how it went: dragging keeps the layout warm so linked bubbles follow like rubber bands and sway back on release. Labels always show and hover doesn't glow (tried, then dropped with Ancung the same day). A torch follows the mouse instead: the parts of the lines near the cursor catch a lime light (`--focus`, a radial gradient over the lines within reach) that fades with distance. Hover dims nothing (Ancung, 10 Nov: dimming the rest felt odd), its label turns bold, and the cursor is a magnet anywhere on the canvas: every bubble within 120 screen px leans toward it, the nearer the stronger (up to a third of the way, at most 8 units, eased), and its lines follow (drawn only, the layout never sees it; none while dragging or with reduced motion; Ancung, 11 Nov); drag a bubble, drag the background (or Space + drag, or the middle button, even over a bubble) to pan; the wheel works like the Builder's canvas (Ancung, 11 Nov): scroll or two fingers pan, Shift + scroll pans sideways, Ctrl/Cmd + scroll or a trackpad pinch zooms around the pointer (the Builder's `wheelPixels`, `wheelPan`, `wheelZoomFactor`); with the graph focused, + and - zoom, 0 is 100%, 1 or F fits; a two-finger pinch on a touch screen zooms (around the point between the fingers; a second finger ends a bubble drag; Ancung, 10 Nov), Fit to frame it again. Clicking a node glides the camera to it and zooms in (Esc, X or a click on empty canvas lets go; Fit goes back), and a card under the graph says what it is (`describe`), how often it was used, and its latest five calls as the chat's step rows that open to show what went in and came back (`callsOf`; a skill shows the calls of the tools under it, the Mind all of them) (Axel, via Ancung, 10 Nov). Reduced motion keeps the colours without moving dots or rings. It stops drawing while off screen. The layout and the camera are kept per Mind across mounts (`KEPT` in `MindGraph.tsx`), and the first frame of a Mind's graph on a page comes in with a zoom out (from 1.35 times the frame's zoom to it, 700 ms, ease-out quart; Ancung, 11 Nov), at once with reduced motion; a new page puts the camera back on automatic framing and frames the kept layout at once, with no entrance (a zoom or a click on a bubble used to stick, so every chat opened after it was zoomed into the Mind, Ancung, 11 Nov); the camera never frames the Mind alone, and while automatic it reframes, gliding, whenever the number of bubbles changes, so sending from New chat (which moves to the thread's URL and mounts a new page) doesn't replay the settling, and only new bubbles warm the layout up; a state change or a count doesn't (Ancung, 10 Nov: every event of a reply set it bouncing). The first graph of a Mind on a page is settled before it is drawn and framed at once (`settle`, no bounce or zoom out); so is a graph that grows by three or more bubbles at once (framed at once only while opening, when nothing but the Mind was there; later the camera glides there, and only if the owner hasn't moved it, since a snap during a reply read as the graph zooming by itself), since the first one often holds only the Mind before its skills and history arrive (they piled in and bounced, Ancung, 11 Nov: "too much jiggle"). One or two new bubbles only nudge it (0.25), and settling on its own uses more friction (0.74) than a drag does (0.86, so a released bubble still sways back), and the layout remembers where every bubble sat (`Sim.seen`), so one that drops out for a moment while a chat page mounts comes back to its place without warming anything up (Ancung, 11 Nov: switching chats replayed the zoom out and the jiggle). The panel draws only the chat on screen's run: ChatScreen passes its `activeHere` (`LiveView` `active`), so after switching chats it no longer shows the other chat's reply, trail or steps. - `components/LiveView.tsx`: the panel ("What {name} is doing", Live dot while streaming, the graph, the picked node, this reply's step rows, and "Waiting for you" from `GET …/approvals` linking to the chat that asked). Beside the chat from 1280 px (`xl`), 360 px wide, toggled with "Live view" in the chat header and remembered (`hellonear.chat.live`, read during render through `useLiveOpen` in `data/liveOpen.ts`, so moving between chats never flashes it open; Ancung, 10 Nov), opening and closing like the app's sidebar (the width slides 0 <-> 360 px, ease-in-out 200 ms, the panel fades; no slide on first paint); below 1280 px the same button opens it in a sheet. Phones have no chat header, so the Live view button sits in the phone's top bar on the chat (`MobileHeader`, opening the chat's drawer through `graph/data/liveDrawer.ts`; it floated over the messages until 11 Nov and hid words); on phones it opens as a drawer from the bottom (85% of the screen, swipe down to close; dragging on the graph moves the graph, not the drawer), on tablets as a sheet from the right (Ancung, 10 Nov). - Not checked in a browser yet. diff --git a/apps/fe/src/modules/graph/components/MindGraph.tsx b/apps/fe/src/modules/graph/components/MindGraph.tsx index bdac0ce6..2b775e72 100644 --- a/apps/fe/src/modules/graph/components/MindGraph.tsx +++ b/apps/fe/src/modules/graph/components/MindGraph.tsx @@ -39,6 +39,9 @@ const KEPT = new Map(null) + // No layout kept for this Mind yet: its first real frame on this page gets the entrance, even if + // the very first graph held only the Mind. + const fresh = useRef(!KEPT.has(mindId)) const hover = useRef(null) // How far each bubble leans toward the cursor right now (drawn only), and whether one is dragged. const magnet = useRef(new Map()) @@ -107,7 +115,12 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, // Frame it at once only while the graph is opening (nothing but the Mind before). Later, the // camera glides to the new frame, and only if the owner hasn't moved it: snapping during a // reply read as the graph zooming by itself (Ancung, 11 Nov). - if (first || before <= 1) snap.current = true + // The very first graph of this Mind on the page comes in with a zoom out (ENTER_MS); a page + // that finds the layout kept, or one still opening, frames at once. + if (fresh.current) { + fresh.current = false + entering.current = -1 + } else if (before <= 1) snap.current = true else fitting.current = true } const now = performance.now() @@ -210,6 +223,25 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, // The Mind alone is no frame: zooming to it is what stuck when a chat page opened before the // other bubbles were back (Ancung, 11 Nov). Wait for them, keeping a pending snap. if (bodies.length <= 1) return + // The entrance (Ancung, 11 Nov): start a little zoomed in on the frame's middle and ease out + // to it, fast at first and slowing at the end. Reduced motion frames at once. + if (entering.current !== null && !still.matches) { + const now = performance.now() + if (entering.current < 0) entering.current = now + const p = Math.min(1, (now - entering.current) / ENTER_MS) + const e = 1 - (1 - p) ** 4 + const from = ENTER_ZOOM + (1 - ENTER_ZOOM) * e + // Scaling the frame about the panel's middle keeps the same spot in the middle. + v.k = to.k * from + v.x = to.x * from + v.y = to.y * from + if (p >= 1) entering.current = null + return + } + if (entering.current !== null) { + entering.current = null + snap.current = true + } if (snap.current) { snap.current = false v.k = to.k @@ -251,7 +283,7 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, framedCount.current = s.bodies.size fitting.current = true } - if (view.current.auto && (moving || snap.current || fitting.current || now < 1500)) fit() + if (view.current.auto && (moving || snap.current || fitting.current || entering.current !== null || now < 1500)) fit() // Glide to the picked node and zoom in a little; a jump with reduced motion. const f = focus.current ? s.bodies.get(focus.current) : null if (f) { From 7e2456577906c8949de9b01f871f4702e8ac0d13 Mon Sep 17 00:00:00 2001 From: ancung Date: Wed, 11 Nov 2026 17:09:47 +0700 Subject: [PATCH 5/6] perf(fe): the live view settles in slices, plays its entrance on every chat, and isn't made on phones Ancung, 11 Nov: the zoom-out entrance on every chat is fine, as long as nothing lags, and phones shouldn't animate what they don't show. - Measured `settle` (one go, this laptop): 35 bubbles 23 to 58 ms, 60 bubbles 73 to 87 ms, so a phone would freeze for a few hundred. The draw loop now settles a new layout in slices of at most 6 ms a frame and draws it once still; then the entrance plays. A graph off screen doesn't draw, so it doesn't settle or animate either. - The entrance (a 700 ms ease-out zoom out over the kept layout) plays on every chat page; the layout itself stays put, so nothing jiggles. - The desktop panel's graph is only made on screens of 1280 px and up. Below, the panel was only hidden with CSS and still fetched the history and laid out the graph on every chat page. Phones and tablets make it only when the drawer or sheet opens. Tests: typecheck, lint, vitest 266/266. Checked in Chrome: after a reload and after switching chats, the graph is framed and still. Co-Authored-By: Claude Opus 5.5 --- apps/fe/CLAUDE.md | 2 +- .../modules/chat/components/ChatScreen.tsx | 8 ++++- .../modules/graph/components/MindGraph.tsx | 31 ++++++++++++++++--- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/apps/fe/CLAUDE.md b/apps/fe/CLAUDE.md index 71ce3b5d..88952596 100644 --- a/apps/fe/CLAUDE.md +++ b/apps/fe/CLAUDE.md @@ -102,7 +102,7 @@ Chat (`/minds/[mindId]/chat` and `/chat/[threadId]`, `src/modules/chat`, design Live view (beside the chat, `src/modules/graph`, design C2 "What Penny is doing", #17), like Obsidian's graph view (Axel, via Ancung, 10 Nov): - `data/graph.ts` `buildGraph` (app bubbles follow engine/src/graph.ts: every app's tools, the track apps of #211 included, are one App bubble, hung off the skill that uses it, so it reads Mind, skill, app; named "Your Notion" beside the Notion skill, with its logo from `APPS`; Ancung, 11 Nov: the track apps showed twice and without a logo): the Mind in the centre, each equipped skill (not blocked ones), the tools, apps and wallet each skill reaches (`GET /skills` `tools` and `connections`), then anything the events touched; node ids are the engine's (`nodeIdFor`, docs/api-contract.md §4), so live events light the nodes the history built. `uses` counts calls, the last state is running, waiting (an approval), ok, error or denied (`policy_denied`, `wallet_frozen`). A meeting with a Meet link lights Google Meet too. Only live states pulse (`liveStates`): running for the run on screen, waiting for an approval still in `GET …/approvals`; history only sizes the bubbles (Ancung, 10 Nov: Meet and Wallet pulsed from an old, declined approval, which never gets a result event). Mastra's `updateWorkingMemory` is the Memory node. - Events: the last 7 days from `GET /minds/{id}/events?limit=2000`, plus `ChatRunProvider`'s run on screen; read again when a run ends. -- `components/MindGraph.tsx` draws on a canvas: `data/sim.ts` (every pair pushes apart, links pull like springs, a pull to the centre, cools down; the Mind stays in the centre), bubbles coloured by kind from the `node-*` tokens (read from CSS, again when the theme changes), the Mind's avatar in the centre, Gmail, Google Calendar and Google Meet with their own logos (`AppLogos`, serialised to images), labels under every bubble, drawn last with an outline in the background colour so lines and bubbles never hide them (tools quieter). The layout keeps room for the labels (stronger push, longer links; Ancung, 10 Nov: the first one was too tight): each bubble with its label is a box and overlapping boxes are pushed apart, bubbles keep off lines that aren't theirs, and a tool several skills share hangs off the first one only, a tree, so lines don't cross (`tests/graph.test.ts` checks a seven-skill Mind settles with no box on another and no bubble on a line). The built-in HelloNear guide isn't drawn; a job is named from its id ("wallet-watch" reads "Wallet watch"). While a tool works, dots travel along the links from the Mind and its bubble pulses (blue running, amber waiting); a result rings green, a failure or a blocked payment red. The reply on screen leaves a trail (Ancung, 10 Nov: a 1 s calendar call showed nothing): the links from the Mind to every node it used stay blue with slow dots while it streams, and stay softly lit for the last reply, with a ring on those bubbles. Pulses are timed from when this page saw the state change, not the event's server time, and only the run on screen pulses (history loading in after the first draw lit up the whole graph on open, Ancung, 10 Nov). From Obsidian's graph (Axel's screen recording, 10 Nov), keeping the colours that say what each node is and how it went: dragging keeps the layout warm so linked bubbles follow like rubber bands and sway back on release. Labels always show and hover doesn't glow (tried, then dropped with Ancung the same day). A torch follows the mouse instead: the parts of the lines near the cursor catch a lime light (`--focus`, a radial gradient over the lines within reach) that fades with distance. Hover dims nothing (Ancung, 10 Nov: dimming the rest felt odd), its label turns bold, and the cursor is a magnet anywhere on the canvas: every bubble within 120 screen px leans toward it, the nearer the stronger (up to a third of the way, at most 8 units, eased), and its lines follow (drawn only, the layout never sees it; none while dragging or with reduced motion; Ancung, 11 Nov); drag a bubble, drag the background (or Space + drag, or the middle button, even over a bubble) to pan; the wheel works like the Builder's canvas (Ancung, 11 Nov): scroll or two fingers pan, Shift + scroll pans sideways, Ctrl/Cmd + scroll or a trackpad pinch zooms around the pointer (the Builder's `wheelPixels`, `wheelPan`, `wheelZoomFactor`); with the graph focused, + and - zoom, 0 is 100%, 1 or F fits; a two-finger pinch on a touch screen zooms (around the point between the fingers; a second finger ends a bubble drag; Ancung, 10 Nov), Fit to frame it again. Clicking a node glides the camera to it and zooms in (Esc, X or a click on empty canvas lets go; Fit goes back), and a card under the graph says what it is (`describe`), how often it was used, and its latest five calls as the chat's step rows that open to show what went in and came back (`callsOf`; a skill shows the calls of the tools under it, the Mind all of them) (Axel, via Ancung, 10 Nov). Reduced motion keeps the colours without moving dots or rings. It stops drawing while off screen. The layout and the camera are kept per Mind across mounts (`KEPT` in `MindGraph.tsx`), and the first frame of a Mind's graph on a page comes in with a zoom out (from 1.35 times the frame's zoom to it, 700 ms, ease-out quart; Ancung, 11 Nov), at once with reduced motion; a new page puts the camera back on automatic framing and frames the kept layout at once, with no entrance (a zoom or a click on a bubble used to stick, so every chat opened after it was zoomed into the Mind, Ancung, 11 Nov); the camera never frames the Mind alone, and while automatic it reframes, gliding, whenever the number of bubbles changes, so sending from New chat (which moves to the thread's URL and mounts a new page) doesn't replay the settling, and only new bubbles warm the layout up; a state change or a count doesn't (Ancung, 10 Nov: every event of a reply set it bouncing). The first graph of a Mind on a page is settled before it is drawn and framed at once (`settle`, no bounce or zoom out); so is a graph that grows by three or more bubbles at once (framed at once only while opening, when nothing but the Mind was there; later the camera glides there, and only if the owner hasn't moved it, since a snap during a reply read as the graph zooming by itself), since the first one often holds only the Mind before its skills and history arrive (they piled in and bounced, Ancung, 11 Nov: "too much jiggle"). One or two new bubbles only nudge it (0.25), and settling on its own uses more friction (0.74) than a drag does (0.86, so a released bubble still sways back), and the layout remembers where every bubble sat (`Sim.seen`), so one that drops out for a moment while a chat page mounts comes back to its place without warming anything up (Ancung, 11 Nov: switching chats replayed the zoom out and the jiggle). The panel draws only the chat on screen's run: ChatScreen passes its `activeHere` (`LiveView` `active`), so after switching chats it no longer shows the other chat's reply, trail or steps. +- `components/MindGraph.tsx` draws on a canvas: `data/sim.ts` (every pair pushes apart, links pull like springs, a pull to the centre, cools down; the Mind stays in the centre), bubbles coloured by kind from the `node-*` tokens (read from CSS, again when the theme changes), the Mind's avatar in the centre, Gmail, Google Calendar and Google Meet with their own logos (`AppLogos`, serialised to images), labels under every bubble, drawn last with an outline in the background colour so lines and bubbles never hide them (tools quieter). The layout keeps room for the labels (stronger push, longer links; Ancung, 10 Nov: the first one was too tight): each bubble with its label is a box and overlapping boxes are pushed apart, bubbles keep off lines that aren't theirs, and a tool several skills share hangs off the first one only, a tree, so lines don't cross (`tests/graph.test.ts` checks a seven-skill Mind settles with no box on another and no bubble on a line). The built-in HelloNear guide isn't drawn; a job is named from its id ("wallet-watch" reads "Wallet watch"). While a tool works, dots travel along the links from the Mind and its bubble pulses (blue running, amber waiting); a result rings green, a failure or a blocked payment red. The reply on screen leaves a trail (Ancung, 10 Nov: a 1 s calendar call showed nothing): the links from the Mind to every node it used stay blue with slow dots while it streams, and stay softly lit for the last reply, with a ring on those bubbles. Pulses are timed from when this page saw the state change, not the event's server time, and only the run on screen pulses (history loading in after the first draw lit up the whole graph on open, Ancung, 10 Nov). From Obsidian's graph (Axel's screen recording, 10 Nov), keeping the colours that say what each node is and how it went: dragging keeps the layout warm so linked bubbles follow like rubber bands and sway back on release. Labels always show and hover doesn't glow (tried, then dropped with Ancung the same day). A torch follows the mouse instead: the parts of the lines near the cursor catch a lime light (`--focus`, a radial gradient over the lines within reach) that fades with distance. Hover dims nothing (Ancung, 10 Nov: dimming the rest felt odd), its label turns bold, and the cursor is a magnet anywhere on the canvas: every bubble within 120 screen px leans toward it, the nearer the stronger (up to a third of the way, at most 8 units, eased), and its lines follow (drawn only, the layout never sees it; none while dragging or with reduced motion; Ancung, 11 Nov); drag a bubble, drag the background (or Space + drag, or the middle button, even over a bubble) to pan; the wheel works like the Builder's canvas (Ancung, 11 Nov): scroll or two fingers pan, Shift + scroll pans sideways, Ctrl/Cmd + scroll or a trackpad pinch zooms around the pointer (the Builder's `wheelPixels`, `wheelPan`, `wheelZoomFactor`); with the graph focused, + and - zoom, 0 is 100%, 1 or F fits; a two-finger pinch on a touch screen zooms (around the point between the fingers; a second finger ends a bubble drag; Ancung, 10 Nov), Fit to frame it again. Clicking a node glides the camera to it and zooms in (Esc, X or a click on empty canvas lets go; Fit goes back), and a card under the graph says what it is (`describe`), how often it was used, and its latest five calls as the chat's step rows that open to show what went in and came back (`callsOf`; a skill shows the calls of the tools under it, the Mind all of them) (Axel, via Ancung, 10 Nov). Reduced motion keeps the colours without moving dots or rings. It stops drawing while off screen. The layout and the camera are kept per Mind across mounts (`KEPT` in `MindGraph.tsx`), and every chat page's graph comes in with a zoom out over its layout (from 1.35 times the frame's zoom to it, 700 ms, ease-out quart; Ancung, 11 Nov: on every chat, like stepping in; the layout stays put, so nothing jiggles), at once with reduced motion; a new page also puts the camera back on automatic framing. A layout to settle (the first graph, or three or more new bubbles) is settled by the draw loop in slices of at most 6 ms a frame (`SETTLE_BUDGET_MS`) and drawn once still: 35 bubbles took 23 to 58 ms in one go on a laptop (60 took 73 to 87), so a phone would freeze. The desktop panel's graph is only made on screens of 1280 px and up (`ChatScreen`, `wide`): below, the hidden panel still fetched and laid out the graph on every chat page; phones and tablets make it only when the drawer or sheet opens. A graph off screen draws nothing, so it settles and animates nothing either (a zoom or a click on a bubble used to stick, so every chat opened after it was zoomed into the Mind, Ancung, 11 Nov); the camera never frames the Mind alone, and while automatic it reframes, gliding, whenever the number of bubbles changes, so sending from New chat (which moves to the thread's URL and mounts a new page) doesn't replay the settling, and only new bubbles warm the layout up; a state change or a count doesn't (Ancung, 10 Nov: every event of a reply set it bouncing). The first graph of a Mind on a page is settled before it is drawn and framed at once (`settle`, no bounce or zoom out); so is a graph that grows by three or more bubbles at once (framed at once only while opening, when nothing but the Mind was there; later the camera glides there, and only if the owner hasn't moved it, since a snap during a reply read as the graph zooming by itself), since the first one often holds only the Mind before its skills and history arrive (they piled in and bounced, Ancung, 11 Nov: "too much jiggle"). One or two new bubbles only nudge it (0.25), and settling on its own uses more friction (0.74) than a drag does (0.86, so a released bubble still sways back), and the layout remembers where every bubble sat (`Sim.seen`), so one that drops out for a moment while a chat page mounts comes back to its place without warming anything up (Ancung, 11 Nov: switching chats replayed the zoom out and the jiggle). The panel draws only the chat on screen's run: ChatScreen passes its `activeHere` (`LiveView` `active`), so after switching chats it no longer shows the other chat's reply, trail or steps. - `components/LiveView.tsx`: the panel ("What {name} is doing", Live dot while streaming, the graph, the picked node, this reply's step rows, and "Waiting for you" from `GET …/approvals` linking to the chat that asked). Beside the chat from 1280 px (`xl`), 360 px wide, toggled with "Live view" in the chat header and remembered (`hellonear.chat.live`, read during render through `useLiveOpen` in `data/liveOpen.ts`, so moving between chats never flashes it open; Ancung, 10 Nov), opening and closing like the app's sidebar (the width slides 0 <-> 360 px, ease-in-out 200 ms, the panel fades; no slide on first paint); below 1280 px the same button opens it in a sheet. Phones have no chat header, so the Live view button sits in the phone's top bar on the chat (`MobileHeader`, opening the chat's drawer through `graph/data/liveDrawer.ts`; it floated over the messages until 11 Nov and hid words); on phones it opens as a drawer from the bottom (85% of the screen, swipe down to close; dragging on the graph moves the graph, not the drawer), on tablets as a sheet from the right (Ancung, 10 Nov). - Not checked in a browser yet. diff --git a/apps/fe/src/modules/chat/components/ChatScreen.tsx b/apps/fe/src/modules/chat/components/ChatScreen.tsx index 2d23af71..2a5ffb4e 100644 --- a/apps/fe/src/modules/chat/components/ChatScreen.tsx +++ b/apps/fe/src/modules/chat/components/ChatScreen.tsx @@ -25,6 +25,7 @@ import { dayLabel } from "@/modules/chat/data/thread" import { Shown, TurnView } from "@/modules/chat/components/TurnView" import { FirstChat, Centered, ThreadSkeleton } from "@/modules/chat/components/ChatStates" import { onLiveDrawer } from "@/modules/graph/data/liveDrawer" +import { useMediaQuery } from "@/hooks/useMediaQuery" /** * Chat (design 4 · Chat, C1): the thread, what each run did, and the composer. `threadId` null @@ -51,6 +52,7 @@ export function ChatScreen({ mindId, threadId }: { mindId: string; threadId: str // The live view (C2, #17): beside the chat from 1280 px, remembered per device; a sheet below that. const liveOpen = useLiveOpen() + const wide = useMediaQuery(MEDIA.xl, false) const [liveSheet, setLiveSheet] = useState(false) // Phones get it as a drawer from the bottom (Ancung, 10 Nov), tablets as a sheet from the right. const [liveDrawer, setLiveDrawer] = useState(false) @@ -371,7 +373,11 @@ export function ChatScreen({ mindId, threadId }: { mindId: string; threadId: str liveOpen ? "opacity-100 delay-50" : "opacity-0" )} > - + {/* Only made on screens wide enough to show it (1280 px): below that the panel is hidden, + and it still fetched the history, laid out the graph and readied its entrance on + every chat page (Ancung, 11 Nov: no animating what a phone doesn't show). Phones and + tablets make it only when the drawer or sheet opens. */} + {wide && } diff --git a/apps/fe/src/modules/graph/components/MindGraph.tsx b/apps/fe/src/modules/graph/components/MindGraph.tsx index 2b775e72..0b7459f2 100644 --- a/apps/fe/src/modules/graph/components/MindGraph.tsx +++ b/apps/fe/src/modules/graph/components/MindGraph.tsx @@ -6,7 +6,7 @@ import { setFlag } from "@/modules/onboarding/data/progress" import { wheelPan, wheelPixels, wheelZoomFactor } from "@/modules/builder/hooks/useCanvasView" import { APPS } from "@/modules/connections/data/apps" import type { GraphLink, GraphNode } from "@/modules/graph/data/graph" -import { settle, stepSim, syncSim, type Sim } from "@/modules/graph/data/sim" +import { stepSim, syncSim, type Sim } from "@/modules/graph/data/sim" import { MEDIA } from "@/lib/media" import { clampZoom, framing, toWorld as worldAt, zoomAround } from "@/modules/graph/data/camera" import { readColors, FILL } from "@/modules/graph/data/colors" @@ -42,6 +42,8 @@ const AFTERGLOW = { ok: 1600, error: 4000, denied: 4000 } as const // The live view's entrance: from 1.35 times the frame's zoom out to it, over 700 ms, ease-out. const ENTER_ZOOM = 1.35 const ENTER_MS = 700 +/** How long a frame may spend settling a new layout, so the page never freezes for it. */ +const SETTLE_BUDGET_MS = 6 // The magnet: bubbles within 120 screen px of the cursor move toward it, up to a third of the // way when right under it, fading to nothing at the edge, at most 8 units. const MAGNET_REACH = 120 @@ -71,13 +73,17 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, const lastSelected = useRef(null) // Frame the layout at once on the next draw, instead of easing toward it. A page that finds a // kept layout frames it at once too, without a glide. - const snap = useRef(KEPT.has(mindId)) + const snap = useRef(false) // Fit was pressed: glide to the frame until there. const fitting = useRef(false) // How many bubbles the camera last framed, so a change reframes it. const framedCount = useRef(0) + // A layout to settle before it is drawn, a slice each frame (see SETTLE_BUDGET_MS). + const pendingSettle = useRef(false) // The entrance zoom out: null when none, -1 waiting for the first frame, else when it started. - const entering = useRef(null) + // Every chat page plays it over the kept layout (Ancung, 11 Nov: like stepping into the chat); + // the layout itself stays put, so nothing jiggles. + const entering = useRef(KEPT.has(mindId) ? -1 : null) // No layout kept for this Mind yet: its first real frame on this page gets the entrance, even if // the very first graph held only the Mind. const fresh = useRef(!KEPT.has(mindId)) @@ -111,7 +117,10 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, // and bounced into place (Ancung, 11 Nov: "too much jiggle"). One or two new ones only nudge it. const grew = sim.current.bodies.size - before if ((first && nodes.length > 1) || grew >= 3) { - settle(sim.current, new Map(nodes.map((n) => [n.id, n.kind]))) + // Settled in slices by the draw loop (SETTLE_BUDGET_MS a frame), not here at once: 35 + // bubbles took 23 to 58 ms on a laptop, so a phone would freeze for a few hundred. A graph + // that isn't on screen doesn't draw, so it doesn't settle either. + pendingSettle.current = true // Frame it at once only while the graph is opening (nothing but the Mind before). Later, the // camera glides to the new frame, and only if the owner hasn't moved it: snapping during a // reply read as the graph zooming by itself (Ancung, 11 Nov). @@ -120,7 +129,7 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, if (fresh.current) { fresh.current = false entering.current = -1 - } else if (before <= 1) snap.current = true + } else if (before <= 1 && entering.current === null) snap.current = true else fitting.current = true } const now = performance.now() @@ -276,6 +285,18 @@ export function MindGraph({ mindId, nodes, links, avatarSrc, selected, onSelect, const s = sim.current if (!s) return const kinds = new Map(data.current.nodes.map((n) => [n.id, n.kind])) + if (pendingSettle.current) { + const until = now + SETTLE_BUDGET_MS + let warm = true + while (warm && performance.now() < until) warm = stepSim(s, kinds) + // Not still yet: nothing drawn this frame, the rest next frame. Then it appears settled. + if (warm) { + ctx.setTransform(1, 0, 0, 1, 0, 0) + ctx.clearRect(0, 0, cv.width, cv.height) + return + } + pendingSettle.current = false + } const moving = stepSim(s, kinds) // While the camera is automatic, a change in how many bubbles there are reframes it (gliding), // so bubbles that come back one or two at a time are never left outside it. From 1596be309d25272ac3abd72fd93d15dbae2347b6 Mon Sep 17 00:00:00 2001 From: ancung Date: Wed, 11 Nov 2026 18:05:58 +0700 Subject: [PATCH 6/6] feat(fe): a lime beam runs along the composer while the Mind replies Ancung, 11 Nov: border-beam (libraries.dev, the same maker as thinking-orbs) on the prompt bar, in our lime. `border-beam` 1.4.1, pinned, MIT. `size="line"` sends a light along the box's bottom edge, and only while the Mind replies (`active={busy}`), like "Thinking...": nothing moves while the owner types, and the animation doesn't run the rest of the time. The library has no custom colour (only colorful, mono, ocean, sunset), so `mono` is tinted to the brand lime in globals.css, on the beam's own layers (::before, ::after and the bloom, which keeps its 6 px blur), so the composer's text keeps its colour. Strength 1, brightness 1.8: at the defaults the lime barely showed on the dark theme. The theme follows next-themes. Tests: typecheck, lint, vitest 266/266. Checked in Chrome, dark theme, with the beam forced on: the lime light travels along the bottom edge. Not checked: the light theme, a phone. Co-Authored-By: Claude Opus 5.5 --- apps/fe/CLAUDE.md | 2 +- apps/fe/bun.lock | 3 +++ apps/fe/package.json | 1 + apps/fe/src/modules/chat/components/Composer.tsx | 9 ++++++++- apps/fe/src/styles/globals.css | 11 +++++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/apps/fe/CLAUDE.md b/apps/fe/CLAUDE.md index 88952596..df84e766 100644 --- a/apps/fe/CLAUDE.md +++ b/apps/fe/CLAUDE.md @@ -13,7 +13,7 @@ Web app (Next.js App Router + NEAR Connect). Owner: Ancung. Design comes from Na - Streams: chat, approve/decline and builder runs are POST + SSE, so `EventSource` can't be used; read the `fetch` body with `eventsource-parser` 4.1.3. - Forms: `react-hook-form` 7.91.0 + `zod` 4.6.7 + `@hookform/resolvers` 7.0.3 (validate as you type, as in the design). - Bottom drawers on phones (`ResponsiveDialog`, "Add a block", a Builder block's settings, the live view) share one roomy spacing (Ancung, 11 Nov, after Welcome). `DrawerContent`'s classes go on the outer popup while its children sit in an inner element with no gap, so the spacing between parts lives on a wrapper inside it (`ResponsiveDialog`) or as margins ("Add a block"); a header there is left-aligned (the drawer centres it by default), except Welcome (`centered`). The sizes: 20 px sides, 20 px between parts, 8 px between a title and its text, 12 px between stacked buttons, and at least 24 px at the bottom (more with a home indicator). -- Toasts: `sonner` 2.0.8 (shadcn's). Theme: `next-themes` 0.4.6 (System, Light, Dark from the account menu). Mind replies: `react-markdown` 10.1.0 with `remark-gfm` 4.0.1 (tables, strikethrough, task lists, bare links; added 9 Nov when a reply's table showed as pipes). Wide tables scroll sideways inside the reply. Springs (Penny is ready, freeze, Builder drag): `motion` 14.10.0; everything else is CSS. Thinking indicators (Thinking... and every running step row, by kind of work: `orb` in `TOOLS` (`runs/data/tools.ts`, every tool's words in one list), read by `stepOrb`, reading searching, websites connecting, writing composing, acting working, time and sums solving, memory breathing, waiting for the owner listening): `thinking-orbs` 0.3.2 (MIT, no runtime dependencies; Axel's pick, 10 Nov): ``, a dotted canvas orb that follows the `dark` class, freezes with reduced motion and pauses off screen by itself. Only the free states and the 20 and 64 sizes (libraries.dev marks some as Pro). +- Toasts: `sonner` 2.0.8 (shadcn's). Theme: `next-themes` 0.4.6 (System, Light, Dark from the account menu). Mind replies: `react-markdown` 10.1.0 with `remark-gfm` 4.0.1 (tables, strikethrough, task lists, bare links; added 9 Nov when a reply's table showed as pipes). Wide tables scroll sideways inside the reply. Springs (Penny is ready, freeze, Builder drag): `motion` 14.10.0; everything else is CSS. Thinking indicators (Thinking... and every running step row, by kind of work: `orb` in `TOOLS` (`runs/data/tools.ts`, every tool's words in one list), read by `stepOrb`, reading searching, websites connecting, writing composing, acting working, time and sums solving, memory breathing, waiting for the owner listening): `thinking-orbs` 0.3.2 (MIT, no runtime dependencies; Axel's pick, 10 Nov): ``, a dotted canvas orb that follows the `dark` class, freezes with reduced motion and pauses off screen by itself. Only the free states and the 20 and 64 sizes (libraries.dev marks some as Pro). The composer's beam: `border-beam` 1.4.1 (MIT, the same maker; Ancung, 11 Nov), `size="line"` (a light travelling along the box's bottom edge), on only while the Mind replies (`active={busy}`), `mono` tinted to the brand lime in globals.css (`.composer-beam`: the library has no custom colour, so its own layers get `sepia saturate hue-rotate`, the bloom keeping its 6 px blur; the text is untouched). - Tests: `vitest` 5.1.0 (unit, `tests/*.test.ts`, config `vitest.config.mts`) with a 15 s test timeout (a few tests that import inside themselves timed out at 5 s on Windows beside the dev server), `@playwright/test` 1.65.0 (flows). - Motion: easing tokens are in `src/styles/globals.css` (`ease-out`, `ease-in-out`, `ease-drawer` utilities; Tailwind only emits them once used). Rules, durations and chat streaming: `design/CLAUDE.md` "Motion (v0.3)". shadcn components keep their own animation classes; set menus and popovers to grow from `--transform-origin` (Base UI provides it) and make exits faster than entries. - Scaffolded with `create-near-app` 10.0.0 (`--frontend next-app`). All versions in `package.json` are pinned exactly; do not upgrade during the hackathon. diff --git a/apps/fe/bun.lock b/apps/fe/bun.lock index d475efc0..26253ca5 100644 --- a/apps/fe/bun.lock +++ b/apps/fe/bun.lock @@ -10,6 +10,7 @@ "@hot-labs/near-connect": "0.12.0", "@tanstack/react-query": "5.106.1", "@xyflow/react": "12.12.1", + "border-beam": "1.4.1", "class-variance-authority": "0.7.1", "cn": "0.5.2", "eventsource-parser": "4.1.3", @@ -524,6 +525,8 @@ "bip39-light": ["bip39-light@1.0.7", "", { "dependencies": { "create-hash": "^1.1.0", "pbkdf2": "^3.0.9" } }, "sha512-WDTmLRQUsiioBdTs9BmSEmkJza+8xfJmptsNJjxnoq3EydSa/ZBXT6rm66KoT3PJIRYMnhSKNR7S9YL1l7R40Q=="], + "border-beam": ["border-beam@1.4.1", "", { "peerDependencies": { "react": ">=18.0.0", "react-dom": ">=18.0.0" } }, "sha512-YyugmKjrhkg1PBC1ZKX7JvFo/zYzha6NXOq24VWrnvBYmDRvGCgFS9oxZoKJ+oS9Kn436l1etYGlAdGiWK+3ag=="], + "borsh": ["borsh@2.0.0", "", {}, "sha512-kc9+BgR3zz9+cjbwM8ODoUB4fs3X3I5A/HtX7LZKxCLaMrEeDFoBpnhZY//DTS1VZBSs6S5v46RZRbZjRFspEg=="], "brace-expansion": ["brace-expansion@1.1.21", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw=="], diff --git a/apps/fe/package.json b/apps/fe/package.json index 24f41963..4766b796 100644 --- a/apps/fe/package.json +++ b/apps/fe/package.json @@ -19,6 +19,7 @@ "@hot-labs/near-connect": "0.12.0", "@tanstack/react-query": "5.106.1", "@xyflow/react": "12.12.1", + "border-beam": "1.4.1", "class-variance-authority": "0.7.1", "cn": "0.5.2", "eventsource-parser": "4.1.3", diff --git a/apps/fe/src/modules/chat/components/Composer.tsx b/apps/fe/src/modules/chat/components/Composer.tsx index 9565423d..acf5b872 100644 --- a/apps/fe/src/modules/chat/components/Composer.tsx +++ b/apps/fe/src/modules/chat/components/Composer.tsx @@ -6,6 +6,8 @@ import { Spinner } from "@/components/elements/Spinner" import { Button } from "@/components/ui/button" import { readPref, writePref } from "@/lib/storage" import { MEDIA, matches } from "@/lib/media" +import { BorderBeam } from "border-beam" +import { useTheme } from "next-themes" /** * The message box (C1.1). Enter sends, Shift+Enter adds a line. While the Mind replies, the send @@ -60,6 +62,7 @@ export function Composer({ } const message = value.trim() const canSend = !busy && !locked && message.length > 0 + const { resolvedTheme } = useTheme() function send() { if (!canSend) return @@ -82,7 +85,10 @@ export function Composer({ }} className="flex w-full flex-col gap-2" > -
+ {/* A beam travels along the box's bottom edge only while the Mind replies (Ancung, 11 Nov), + like "Thinking...": off otherwise, so nothing moves while the owner types. */} + +
@@ -108,6 +114,7 @@ export function Composer({ )}
+

{note}

) diff --git a/apps/fe/src/styles/globals.css b/apps/fe/src/styles/globals.css index 0f3ae482..5169ec5b 100644 --- a/apps/fe/src/styles/globals.css +++ b/apps/fe/src/styles/globals.css @@ -400,3 +400,14 @@ display: none; } } + +/* The composer's beam (border-beam, Composer.tsx) has no colour of its own to set: its "mono" light + is tinted to the brand lime here, on the beam's own layers only so the text keeps its colour. + The bloom keeps the 6 px blur the library gives it (Ancung, 11 Nov). */ +.composer-beam::before, +.composer-beam::after { + filter: sepia(1) saturate(6) hue-rotate(28deg) brightness(1.08); +} +.composer-beam [data-beam-bloom] { + filter: blur(6px) sepia(1) saturate(6) hue-rotate(28deg) brightness(1.08); +}