Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
00316ab
feat: annotate figures cropped from the learner's PDFs
IsaacZhangg Nov 5, 2026
6badc17
fix(deps): clear production npm audit advisories
IsaacZhangg Nov 8, 2026
d3b5ddb
fix: tighten update-install IPC, CLI env, and ChatGPT credential reads
IsaacZhangg Nov 8, 2026
39babf1
feat(claude-code): offer Fable in the model list
IsaacZhangg Nov 10, 2026
4778911
Merge remote-tracking branch 'upstream/main' into claude/pdf-image-an…
IsaacZhangg Nov 10, 2026
dec5851
Merge remote-tracking branch 'upstream/main' into feat/dep-bumps
IsaacZhangg Nov 10, 2026
a7c0891
Merge remote-tracking branch 'upstream/main' into feat/ipc-env-hardening
IsaacZhangg Nov 10, 2026
a1363aa
ci: re-run checks (plugin type-build tests timed out on the runner)
IsaacZhangg Nov 10, 2026
7aee372
fix(side-chat): send the chat id as OpenCode's routing session
LexMalch Nov 12, 2026
18d77ec
test(side-chat): assert the provider session id at the service seam
LexMalch Nov 12, 2026
e8167fd
fix(chat): stop next dev from returning 500 on chat pages
SmitMachhi Nov 12, 2026
25922a5
refactor(plan): move plan layout into plan-layout.ts
SmitMachhi Nov 12, 2026
120c964
fix(plan): size plan boxes from labels laid out in the real font
SmitMachhi Nov 12, 2026
6870551
test(plan): check plan label fit in real Chrome, also in CI
SmitMachhi Nov 12, 2026
8ff4e99
fix(graph): split long labels between whole characters
SmitMachhi Nov 12, 2026
4c50018
fix(plan): cap plan labels at the chat's reading size
SmitMachhi Nov 12, 2026
40d970e
Merge upstream main (v0.6.1) into feat/ipc-env-hardening
IsaacZhangg Nov 12, 2026
1ab9da8
Merge remote-tracking branch 'upstream/main' into claude/pdf-image-an…
IsaacZhangg Nov 12, 2026
1692c54
Merge upstream/main into feat/claude-code-fable
IsaacZhangg Nov 12, 2026
3705a82
Merge upstream/main into feat/dep-bumps
IsaacZhangg Nov 12, 2026
c0291f4
fix(activity): keep the stop button on the task card's face
IsaacZhangg Nov 13, 2026
90535c9
Read nested token limits during custom model discovery
juswag Nov 14, 2026
29c0167
perf(drawing-pad): cache and incrementally resolve visible strokes
hrdkj Nov 16, 2026
60b5df5
perf(drawing-pad): stop per-stroke host refreshes and point serialisa…
hrdkj Nov 16, 2026
ad67ed7
perf(drawing-pad): repaint only what changed on the ink canvas
hrdkj Nov 16, 2026
c7dd027
fix: remove implicit background-agent turn caps
amosblomqvist Nov 16, 2026
6a88d01
Prepare PR #701 font-aware plan layout foundation
amosblomqvist Nov 16, 2026
a2a1b1a
fix(plan): invalidate label measurements on font changes
amosblomqvist Nov 16, 2026
fd8caf6
fix(drawing-pad): erase on a stationary eraser contact
hrdkj Nov 16, 2026
e534313
fix(flashcards): restore native Pi output handling
amosblomqvist Nov 16, 2026
0a417ba
Prepare PR #692 provider reliability foundation
amosblomqvist Nov 16, 2026
8f3307f
Prepare PR #745 provider reliability foundation
amosblomqvist Nov 16, 2026
65fbd2f
test(providers): cover side routing and nested-limit rediscovery
amosblomqvist Nov 16, 2026
399d6a7
fix(rich-code-blocks): heal common TeX omissions and surface diagnostics
amosblomqvist Nov 16, 2026
4bfbe8e
Merge renderer-only TeX compatibility and diagnostics
amosblomqvist Nov 16, 2026
4dfcbd4
fix(providers): route one-shot plugin inference with host-owned ids
amosblomqvist Nov 16, 2026
758f676
Merge provider routing identity and nested model limits
amosblomqvist Nov 16, 2026
79c93e3
Prepare contributor drawing-pad performance stack
amosblomqvist Nov 17, 2026
43ddc92
fix(drawing-pad): rebuild incremental ink after context restoration
amosblomqvist Nov 17, 2026
6407d37
fix(drawing-pad): reconcile canvas density during ordinary input
amosblomqvist Nov 17, 2026
d5be77f
Merge Flashcards native output and context delegation
amosblomqvist Nov 17, 2026
1107f17
Prepare selected PR #592 IPC and CLI environment changes
amosblomqvist Nov 17, 2026
c34505b
Prepare PR #632 desktop batch foundation
amosblomqvist Nov 17, 2026
128edea
Prepare PR #725 desktop batch foundation
amosblomqvist Nov 17, 2026
a908ae7
test: verify selected desktop improvements together
amosblomqvist Nov 17, 2026
9cf2a2f
Upgrade LearnHarness Pi libraries to 1.5.2
amosblomqvist Nov 18, 2026
ef17954
fix(drawing-pad): keep long code blocks and Undo/Clear steady
hrdkj Nov 18, 2026
3e6aafc
Prepare PR #528 PDF figure annotation foundation
amosblomqvist Nov 18, 2026
6123dec
Bound PDF figure reads and reuse the job's page snapshot
amosblomqvist Nov 18, 2026
76f04ab
Shared session folders in the sidebar and a view-only graph folder fi…
amosblomqvist Nov 18, 2026
f20aff1
Settle PDF open cancellation and clarify batched crop feedback
amosblomqvist Nov 18, 2026
f2cb91b
Prepare PR #798 Drawing Pad capture foundation
amosblomqvist Nov 18, 2026
65bada2
fix(drawing-pad): keep locked editing buttons visually steady
amosblomqvist Nov 18, 2026
81d7206
Sidebar polish: ruled rows, folders first, overlay scrollbar; Chains …
amosblomqvist Nov 18, 2026
7fd2076
fix(drawing-pad): preserve toolbar opacity through pressure gaps
amosblomqvist Nov 18, 2026
bfd6c40
Polish: list top rule, folder chevron alignment, graph folder button
amosblomqvist Nov 18, 2026
d363331
Sidebar: the topmost row carries the list's top rule instead of the f…
amosblomqvist Nov 18, 2026
0f6c47d
Sidebar folder Delete removes the folder with its sessions; empty fol…
amosblomqvist Nov 18, 2026
d4e6fca
Sidebar: draw separators only around folder branches
amosblomqvist Nov 18, 2026
fcad626
Upgrade Next.js to 16.4.6
amosblomqvist Nov 18, 2026
dafed7c
Update Pi OAuth trace expectation for trusted URL helper
amosblomqvist Nov 18, 2026
97454cb
Use a funnel and an unfiltered ghost state for the graph filter
amosblomqvist Nov 19, 2026
530cc9f
Add compact session sidebar and make row hover immediate
amosblomqvist Nov 19, 2026
53f9238
feat(settings): add a per-segment prompt editor
amosblomqvist Nov 19, 2026
80803ce
Remove sidebar hover fade and compact list hint
amosblomqvist Nov 19, 2026
6493a4b
Use regular weight for sidebar folder and session names
amosblomqvist Nov 19, 2026
7c65e37
Require a fresh folder deletion scope before removing sessions
amosblomqvist Nov 19, 2026
252b587
Fix graph folder filter visibility and keyboard focus; reconcile fold…
amosblomqvist Nov 19, 2026
9c4a533
Merge shared folders and session sidebar improvements
amosblomqvist Nov 19, 2026
a9d062c
Merge Pi OAuth tracing test correction
amosblomqvist Nov 19, 2026
661cb09
Merge Next.js 16.4.6 security patch upgrade
amosblomqvist Nov 19, 2026
a1442fe
feat: transcript width setting and adaptive question layout
amosblomqvist Nov 19, 2026
7f8ac6b
Show startup announcements in the desktop app
amosblomqvist Nov 19, 2026
93133de
Reject expired startup announcements at modal registration
amosblomqvist Nov 19, 2026
f9d5178
fix: address independent review of adaptive question layout
amosblomqvist Nov 19, 2026
22c51bd
fix: keep question reading position across layout changes
amosblomqvist Nov 20, 2026
09d2caa
fix: preserve reading position when focused editor was hidden
amosblomqvist Nov 20, 2026
ecff87c
Consider only the latest startup announcement
amosblomqvist Nov 20, 2026
f3f7f74
Polish prompt settings and reconcile saved overrides
amosblomqvist Nov 20, 2026
6b1d2d1
Preserve settings acknowledgements and prompt return focus
amosblomqvist Nov 20, 2026
7b68534
Decline prompt deletion while settings are saving
amosblomqvist Nov 20, 2026
18b5d22
Merge the reviewed prompt editor UI adaptation
amosblomqvist Nov 20, 2026
c4f5a09
Probe for understanding that changes the teaching plan
amosblomqvist Nov 20, 2026
ca19647
Keep probing independent of the quizzing mechanic
amosblomqvist Nov 20, 2026
6842bd0
Keep evidence-led bracketing central to probing
amosblomqvist Nov 20, 2026
d2214b4
Remove obsolete wait instructions from blocking question tools
amosblomqvist Nov 20, 2026
0a8c044
Read reasoning across answer modes and calibrate confidence
amosblomqvist Nov 20, 2026
9d9a451
Merge evidence-led probing guidance
amosblomqvist Nov 20, 2026
c3ff55f
feat: label single-select question options
amosblomqvist Nov 20, 2026
55482a9
fix: match dock selection mode in open side chat
amosblomqvist Nov 20, 2026
7fa9e1f
fix: show historical option letters and center selection marks
amosblomqvist Nov 20, 2026
60b831d
fix: match side-chat answers to the preceding question call
amosblomqvist Nov 20, 2026
2edfbbf
Merge session appearance and quiz option letters
amosblomqvist Nov 20, 2026
b5668f5
Merge PDF figure annotation
amosblomqvist Nov 20, 2026
62a2da5
fix: hand off parked Claude processes between worker requests
amosblomqvist Nov 20, 2026
141c6d9
Merge the removal of implicit background turn limits
amosblomqvist Nov 20, 2026
4070d53
fix: prevent late Claude errors from restoring retired continuations
amosblomqvist Nov 20, 2026
710d10d
Preserve the startup message during same-URL hydration
amosblomqvist Nov 20, 2026
2c580d9
fix(deps): apply targeted root dependency cleanup
amosblomqvist Nov 20, 2026
5629fd9
Record #591 contributor ancestry for the selected dependency update
amosblomqvist Nov 20, 2026
dd773e4
Match startup announcement dialog to app typography
amosblomqvist Nov 20, 2026
e586df5
Merge the startup message viewer
amosblomqvist Nov 20, 2026
1cfb7ea
Add manual model catalog refresh in Agent settings
amosblomqvist Nov 21, 2026
1f77ebc
Validate imported model wire metadata before publishing catalog
amosblomqvist Nov 21, 2026
eca98d2
fix(plan): reuse layout across equivalent session snapshots
amosblomqvist Nov 21, 2026
3077538
perf(chat): omit transcript from session stats refreshes
amosblomqvist Nov 21, 2026
f715f6f
Preview faster long transcript rendering
amosblomqvist Nov 21, 2026
44bae34
Restore copying TeX from display equations
amosblomqvist Nov 21, 2026
7ff1505
Keep latest learner turn exempt after background updates
amosblomqvist Nov 21, 2026
7859421
Merge long-transcript rendering improvements from discussion #784
amosblomqvist Nov 21, 2026
c0cb275
perf(css): omit unused container breakpoints
amosblomqvist Nov 21, 2026
3a8d4d9
fix(plan): measure labels outside scaled diagrams
amosblomqvist Nov 21, 2026
e95529c
Merge session resize performance improvements
amosblomqvist Nov 21, 2026
c3d3682
fix(plan): keep label glyph advances stable under scaling
amosblomqvist Nov 21, 2026
390f609
Merge the plan-label alignment and smoke correction
amosblomqvist Nov 21, 2026
0292b85
release: prepare 0.7.0
amosblomqvist Nov 21, 2026
069a6a1
Dispatch a single website update per desktop release
amosblomqvist Nov 21, 2026
48dc216
Merge upstream LearnHarness 0.7.0 (upstream-main) into main
max-miller1204 Nov 21, 2026
eab07a2
Fix round 1 of the 0.7.0 sync: smoke login, folder Delete, threads, r…
max-miller1204 Nov 21, 2026
31e28af
Fix round 2 of the 0.7.0 sync: thread credential, stats hold, retired…
max-miller1204 Nov 21, 2026
83ca438
Merge origin/main (#318) into sync/upstream-0.7.0
max-miller1204 Nov 21, 2026
66842cc
Merge origin/main (#326, #330, #331) into sync/upstream-0.7.0
max-miller1204 Nov 22, 2026
a216139
Fix the 0.7.0 sync's verify findings: first-visit 500 and the root dr…
max-miller1204 Nov 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ jobs:
key: nextjs-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json', 'plugins/*/package-lock.json') }}-${{ github.sha }}
# Check the fresh trace before any static copying/curation.
- run: node scripts/smoke-provider-runtime.mjs
# Plan map labels fit their boxes in real Chrome, in any font (#671).
- run: node scripts/smoke-plan-labels.mjs
- run: node scripts/build-server.mjs
- run: node scripts/smoke-server.mjs --electron

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Instead of just giving you an explanation, it uses your answers and thinking to

**Bring your files.** In the desktop app, attach PDFs, photos, or any other file with the paperclip, or drag them in. The file stays where it is: the message carries its path, and the agent reads it from there.

The agent can also research questions in the background, create visual explanations, show your own images in the lesson and mark them up with arrows and labels, and build interactive demonstrations.
The agent can also research questions in the background, create visual explanations, show your own images in the lesson and mark them up with arrows and labels (including figures it crops straight out of your PDFs, such as lecture slides), and build interactive demonstrations.

## Knowledge that carries forward

Expand Down
8 changes: 7 additions & 1 deletion app/api/chats/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ import { compactionInFlight, deleteChatSession, getChat, isTurnRunning, sessionC
import { pendingPluginQuestionOf, activeProblemOf } from "@/src/core";
import type { ChatResponse } from "@/src/server";

export async function GET(_req: Request, { params }: { params: Promise<{ id: string }> }) {
export async function GET(req: Request, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
if (new URL(req.url).searchParams.get("view") === "stats") {
// Stats refreshes don't adopt history or need plugin availability.
const chat = getChat(id);
return chat ? Response.json({ turns: chat.turns, pricing: sessionCost(chat) })
: Response.json({ error: "Not found" }, { status: 404 });
}
await reconcilePluginQuestionCompatibility(stores.chatStore, id);
let chat = getChat(id);
if (!chat) return Response.json({ error: "Not found" }, { status: 404 });
Expand Down
25 changes: 25 additions & 0 deletions app/api/graph/sources/folders/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { deleteFolderWithSessions, readOrganizationAction, SourceDeletionError, SourceOrganizationInputError } from "@/src/server";
import { emit, type ChatDeleteMode } from "@/src/core";

export const dynamic = "force-dynamic";

/**
* DELETE /api/graph/sources/folders/[id]?mode=preserve-graph|delete-nodes —
* the sidebar's folder Delete: the folder, its subfolders and every session
* inside; imported notes inside move to the folder's parent. The mode is
* required, as is the scope the user reviewed (JSON body). A stale scope
* returns 409 and requires a fresh confirmation; no records are deleted.
*/
export async function DELETE(request: Request, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const mode = new URL(request.url).searchParams.get("mode") as ChatDeleteMode;
try { return Response.json({ ok: true, ...(await deleteFolderWithSessions(id, mode, await readOrganizationAction(request))) }); }
catch (error) {
// A failure partway still names the sessions already removed.
if (error instanceof SourceDeletionError) return Response.json({ error: error.message, code: error.code, ...(error.deletedChatIds?.length ? { deletedChatIds: error.deletedChatIds } : {}) }, { status: error.status });
if (error instanceof SourceOrganizationInputError) return Response.json({ error: error.message, code: "bad_folder_scope" }, { status: 400 });
return Response.json({ error: "Could not finish deleting the folder. Some sessions may already have been removed; refresh or retry.", code: "error" }, { status: 500 });
} finally {
emit("sources-changed", {}); emit("chats-changed", {}); emit("activity-changed", {});
}
}
19 changes: 15 additions & 4 deletions app/api/models/route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import { modelCatalog, refreshConnectionCatalog } from "@/src/server";
import { modelCatalog, refreshConnectionCatalog, refreshModelCatalog } from "@/src/server";
import type { ModelCatalogRefreshResponse } from "@/src/core";

const headers = { "Cache-Control": "no-store" };

/**
* The model picker's data (model-control wave): pi-ai's configured-provider
* catalog as client-safe DTOs — id/name/cost/context/modality plus each
* model's SUPPORTED thinking levels (per its thinkingLevelMap). Static
* catalog: no network, stable within a pi-ai version.
* model's supported thinking levels. Reads bundled and locally saved
* metadata; the existing connection catalogs still refresh independently.
*/
export async function GET() {
await refreshConnectionCatalog();
return Response.json(modelCatalog(), { headers: { "Cache-Control": "no-store" } });
return Response.json(modelCatalog(), { headers });
}

/** Only this explicit action may contact pi.dev. The API Proxy guards it. */
export async function POST() {
let outcome;
try { outcome = await refreshModelCatalog(); }
catch { return Response.json({ error: "Model catalog refresh failed" }, { status: 502, headers }); }
return Response.json({ outcome, catalog: modelCatalog() } satisfies ModelCatalogRefreshResponse, { headers });
}
97 changes: 97 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@import "tailwindcss";
/* The bare .container utility is unused. Its viewport breakpoints still
trigger document-wide style/layout work on long transcripts. */
@source not inline("container");

@custom-variant dark (&:is(.dark *));
/* The sidebar is closed: components/sidebar-boot.ts sets this attribute on
Expand Down Expand Up @@ -184,6 +187,16 @@ body {
line-height: var(--lh-prose-leading);
}

/* Transcript width (Appearance → Transcript width; session pages). The
setting X (rem, on <html> as --lh-transcript-max) is a DOCK-container
width: at X the transcript's text column lines up with the edges of a
bottom-region card X wide (its px-4 + borders), so the column box is
X - 2rem of content plus its own px-6 (3rem). Unset = Full: the calc is
invalid at computed-value time and max-width falls back to none. */
.lh-transcript-column {
max-width: calc(var(--lh-transcript-max) + 1rem);
}

/* Session-name weight (owner, fix wave round 3): with the serif toggle
OFF, --font-title resolves to the prose font — Source Sans 3 is loaded
as a VARIABLE font, and without an explicit weight the titles render at
Expand Down Expand Up @@ -309,6 +322,67 @@ body {
overflow-y: hidden;
}

/* Inline code and inline math never wrap on the session page (owner,
* session-appearance-layout): a split box or formula reads badly. A span
* moves to the next line whole; one wider than its column scrolls sideways
* as the last resort (the adaptive question layout widens the card first).
* inline-block + baseline-source:first keeps the text on the line's
* baseline; a scroller's baseline would otherwise drop to its bottom edge.
* (KaTeX's glyph room: below.) */
[data-session-surface] [data-streamdown="inline-code"],
[data-session-surface] :not(.katex-display) > .katex {
display: inline-block;
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
vertical-align: baseline;
baseline-source: first;
}
/* A table's wrapper scrolls sideways only. Inline formulas' glyph room
* (the padding above) may reach past the last row by a fraction of a pixel,
* which would otherwise make the wrapper scroll vertically. */
[data-session-surface] [data-testid="md-table"] > .overflow-x-auto {
overflow-y: hidden;
}

/* Punctuation touching a span stays on its line (components/md-nobreak.ts):
* a line may otherwise break between an inline-block and a comma. The glued
* GROUP is then the unit that moves and, when wider than its column,
* scrolls — the punctuation included, never clipped outside it. Inside a
* group the spans themselves neither scroll nor cap their width. */
[data-session-surface] .lh-nobreak {
display: inline-block;
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
vertical-align: baseline;
baseline-source: first;
}
[data-session-surface] .lh-nobreak [data-streamdown="inline-code"],
[data-session-surface] .lh-nobreak .katex {
max-width: none;
overflow: visible;
}
/* KaTeX glyphs overhang their boxes: the padding (cancelled by the negative
* margin, so lines keep their height) keeps the clip and the scroller off
* them — on the formula's own scroller, or on its group's. */
[data-session-surface] :not(.katex-display) > .katex,
[data-session-surface] .lh-nobreak:has(.katex) {
padding: 0.5em 0.2em;
margin: -0.5em -0.2em;
/* The side margins shrink a shrink-to-fit parent (an option label) by
0.4em; the cap gives that back so a formula never scrolls in its own
label. The margin box still never exceeds the column. */
max-width: calc(100% + 0.4em);
}
/* (Display math is a block, never glued: every formula in a group is inline.) */
[data-session-surface] .lh-nobreak .katex {
padding: 0;
margin: 0;
}

/* ============================================================
* Chrome melt (owner wave, 2026-09-19) — tables and code blocks stop
* being boxes: blocks read as part of the message. These rules override
Expand Down Expand Up @@ -406,6 +480,13 @@ body {
height: auto !important;
}

/* Keep glyph advances (including fallback emoji) consistent between the
scaled plan and its unscaled label probe. Leave the HTML line breaker
and other SVGs alone. */
:is(svg[aria-label="Plan diagram"], svg[data-plan-probe]) text {
text-rendering: geometricPrecision;
}

/* ============================================================
* Session status — the braille spinner (the one working indicator)
* ============================================================ */
Expand Down Expand Up @@ -603,6 +684,15 @@ body {
display: none;
}

/* Overlay scroller (components/overlay-scroll.tsx): the native bar is hidden
so rows, rules and highlights run to the edge; a thin bar draws on top. */
.lh-overlay-scroll {
scrollbar-width: none;
}
.lh-overlay-scroll::-webkit-scrollbar {
display: none;
}

/* Runtime font contracts: Appearance overrides the reading family and,
independently, whether titles use serif or the reading family. Non-inline
utilities read these vars; Source Sans 3 remains the default/loading face. */
Expand Down Expand Up @@ -637,6 +727,13 @@ body {
}
}

/* Preview estimate: Chromium remembers the measured height once a row is
shown. Don't contain the newest turn or the question dock. */
[data-older-transcript-row] {
content-visibility: auto;
contain-intrinsic-block-size: auto 800px;
}

/* Source-message arrival: a brief, static theme-colored spotlight. */
.lh-source-passage {
scroll-margin-top: 1rem;
Expand Down
16 changes: 9 additions & 7 deletions apps/mobile/src/PlanDiagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useMemo } from "react";
import Svg, { Defs, FeGaussianBlur, Filter, G, Path, Rect, Text as SvgText } from "react-native-svg";
import type { PlanNodeStatus } from "../../../src/core/contracts/plan.ts";
import {
ARROW_HEAD, GLOW_BLUR, GLOW_MARGIN, HEAD_H, LINE_H, NODE_H, NODE_W_MIN, STROKE_W,
blockLayout, edgePathD, wrapTitle, type PlanLayoutNode,
ARROW_HEAD, GLOW_BLUR, GLOW_MARGIN, HEAD_H, NODE_W_MIN, STROKE_W,
blockLayout, edgePathD, type PlanLayoutNode,
} from "../../../src/core/plan-layout.ts";
import { pathEnd } from "./lesson";
import { alpha, fonts, useTheme } from "./theme";
Expand All @@ -18,6 +18,7 @@ export function PlanDiagram({ nodes, edges, statusOf, glowId, monochrome, pad, w
glowId?: string | null; monochrome?: boolean; pad: number; width?: number;
}) {
const { c } = useTheme();
// The chart measure (blockLayout's default): the phone can't measure its labels before drawing.
const layout = useMemo(() => blockLayout(nodes, edges), [nodes, edges]);
const vbW = Math.max(layout.width, 1) + 2 * pad;
const vbH = Math.max(layout.height, 1) + 2 * pad;
Expand All @@ -39,7 +40,7 @@ export function PlanDiagram({ nodes, edges, statusOf, glowId, monochrome, pad, w
if (!points) return null;
const tx = layout.x.get(edge.to), ty = layout.y.get(edge.to);
const target = tx !== undefined && ty !== undefined
? { x: tx, y: ty, w: layout.nodeW.get(edge.to) ?? NODE_W_MIN, h: layout.nodeH.get(edge.to) ?? NODE_H } : undefined;
? { x: tx, y: ty, w: layout.nodeW.get(edge.to) ?? NODE_W_MIN, h: layout.nodeH.get(edge.to) ?? 0 } : undefined;
const d = edgePathD(points, target);
const end = pathEnd(d);
const dim = !monochrome && (statusOf(edge.from) === "upcoming" || statusOf(edge.to) === "upcoming");
Expand All @@ -54,18 +55,19 @@ export function PlanDiagram({ nodes, edges, statusOf, glowId, monochrome, pad, w
})}
{nodes.map((node) => {
const status = statusOf(node.id);
const lines = wrapTitle(node.title);
const h = layout.nodeH.get(node.id) ?? NODE_H;
// The layout's own line breaks, as the web block draws them.
const lines = layout.lines.get(node.id) ?? [node.title];
const h = layout.nodeH.get(node.id) ?? 0;
const w = layout.nodeW.get(node.id) ?? NODE_W_MIN;
const top = (h - lines.length * LINE_H) / 2 + 10;
const top = (h - lines.length * layout.lineH) / 2 + 10;
const { fill, stroke } = box(status);
return (
<G key={node.id} transform={`translate(${layout.x.get(node.id) ?? 0} ${layout.y.get(node.id) ?? 0})`}>
<Rect width={w} height={h} fill={fill} stroke={stroke} strokeWidth={STROKE_W} />
{node.id === glowId && !monochrome && <Rect x={-GLOW_MARGIN} y={-GLOW_MARGIN} width={w + 2 * GLOW_MARGIN} height={h + 2 * GLOW_MARGIN}
fill="rgba(250, 204, 21, 0.25)" filter="url(#plan-glow)" />}
{lines.map((line, i) => (
<SvgText key={i} x={w / 2} y={top + i * LINE_H} textAnchor="middle" fontFamily={fonts.prose} fontSize={11}
<SvgText key={i} x={w / 2} y={top + i * layout.lineH} textAnchor="middle" fontFamily={fonts.prose} fontSize={layout.fontSize}
fontWeight={status === "current" && !monochrome ? "500" : "400"} fill={ink(status)}>{line}</SvgText>
))}
</G>
Expand Down
79 changes: 40 additions & 39 deletions components/activity-dock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,44 +441,48 @@ function ActivityBlobRow({
<div
data-testid={`activity-blob-${blob.process}`}
data-activity-id={blob.id}
className="relative rounded-lg px-2 py-1.5 text-xs transition-colors hover:bg-accent"
className="rounded-lg px-2 py-1.5 text-xs transition-colors hover:bg-accent"
>
<button
type="button"
onClick={onToggleDetail}
aria-expanded={detailOpen}
className="flex w-full items-center gap-2 pr-7 text-left"
>
<Icon className="size-3.5 shrink-0 text-muted-foreground" />
<span className="min-w-0 flex-1">
<span className="block truncate font-medium text-card-foreground">{blob.title}</span>
{blob.activity ? (
<span className="block truncate text-muted-foreground" title={blob.activity}>
{blob.activity}
<div className="relative">
<button
type="button"
onClick={onToggleDetail}
aria-expanded={detailOpen}
className="flex w-full items-center gap-2 pr-7 text-left"
>
<Icon className="size-3.5 shrink-0 text-muted-foreground" />
<span className="min-w-0 flex-1">
<span className="block truncate font-medium text-card-foreground" title={blob.title}>
{blob.title}
</span>
) : (
<span className="block truncate text-muted-foreground/80">{label}</span>
)}
</span>
<span className="flex shrink-0 items-center gap-2 tabular-nums text-muted-foreground">
<span data-testid="activity-blob-cost">{planCostLabel(blob.cost, subscriptionLabel(blob.model))}</span>
<span data-testid="activity-blob-elapsed">{formatElapsed(now - blob.startedAt)}</span>
</span>
</button>
{/* The explicit END always on the blob's face (SCOPE) — the popover
is for DETAIL, not the control. A failed abort locks the button and
says why; a succeeded one just makes the blob vanish on refresh. */}
<button
type="button"
data-testid="activity-abort"
onClick={onAbort}
disabled={abortState !== undefined}
title={abortState === "failed" ? "Abort failed — try again" : "End this background process"}
aria-label={`End ${label} in ${blob.title}`}
className="absolute right-1 top-1/2 -translate-y-1/2 rounded-md p-1 text-muted-foreground/70 transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-50"
>
<SquareIcon className="size-3" />
</button>
{blob.activity ? (
<span className="block truncate text-muted-foreground" title={blob.activity}>
{blob.activity}
</span>
) : (
<span className="block truncate text-muted-foreground/80">{label}</span>
)}
</span>
<span className="flex shrink-0 items-center gap-2 tabular-nums text-muted-foreground">
<span data-testid="activity-blob-cost">{planCostLabel(blob.cost, subscriptionLabel(blob.model))}</span>
<span data-testid="activity-blob-elapsed">{formatElapsed(now - blob.startedAt)}</span>
</span>
</button>
{/* The explicit END always on the blob's face (SCOPE) — the popover
is for DETAIL, not the control. A failed abort locks the button and
says why; a succeeded one just makes the blob vanish on refresh. */}
<button
type="button"
data-testid="activity-abort"
onClick={onAbort}
disabled={abortState !== undefined}
title={abortState === "failed" ? "Abort failed — try again" : "End this background process"}
aria-label={`End ${label} in ${blob.title}`}
className="absolute right-1 top-1/2 -translate-y-1/2 rounded-md p-1 text-muted-foreground/70 transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-50"
>
<SquareIcon className="size-3" />
</button>
</div>

{detailOpen && (
<div
Expand All @@ -493,9 +497,6 @@ function ActivityBlobRow({
</span>
</div>
<div className="flex flex-col gap-1 text-muted-foreground">
<div className="truncate text-card-foreground" title={blob.title}>
{blob.title}
</div>
{blob.activity && <div className="break-words">{blob.activity}</div>}
<div className="flex justify-between gap-2">
<span>Cost</span>
Expand Down
Loading
Loading