refactor(launch-video): agent-driven capture infrastructure and scene - #782
refactor(launch-video): agent-driven capture infrastructure and scene#782elucid wants to merge 4 commits into
Conversation
Adds a video scene that demonstrates the 0.19 agent surfaces the way they are actually used: it launches Hunk against an isolated session daemon (scratch XDG_RUNTIME_DIR plus a pinned non-default port so a developer's live daemon is never touched) and drives the review with real `hunk session navigate` and `hunk session highlight` calls rather than keystrokes, so every captured frame shows the genuine agent-facing behavior: hunk-level vs line-exact landings, character- range attention marks, tone changes, a cross-file --focus jump, and an exact-count clear. The deep-line shot needs a hunk taller than the mini-app example provides, so buildReportModule() deterministically generates a long policy table with one behavioral comparator change buried below it, written only into the throwaway capture repo; the shipped example fixtures are untouched. Needle lines and mark offsets are computed from the generated text at capture time instead of being hand-counted. Empty changeset: maintainer-only tooling, not release-notes material.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryAdds an agent-attention launch-video scene that drives line navigation and character-range highlights through a session broker.
Confidence Score: 4/5The PR should not merge until the attention scene allocates a unique available broker port so captures cannot collide or control another capture's session. The scene isolates broker metadata but reuses a fixed host-global TCP port, allowing overlapping captures or a lingering broker to cause startup failure or cross-session commands. Files Needing Attention: scripts/launch-video/capture.ts Important Files Changed
Sequence DiagramsequenceDiagram
participant A as Attention capture A
participant B as Attention capture B
participant D as Broker on 127.0.0.1:47911
A->>D: Launch/discover broker
A->>D: Register session A
B->>D: Discover same healthy endpoint
B->>D: Register session B
B->>D: list sessions
D-->>B: Sessions ordered by latest update
B->>D: Navigate/highlight sessions[0]
Note over B,D: Command may target session A
Prompt To Fix All With AI### Issue 1
scripts/launch-video/capture.ts:217
**Fixed port breaks daemon isolation**
If two attention captures overlap or a previous capture's detached broker remains healthy, both runs use the host-global `127.0.0.1:47911` endpoint despite their separate runtime directories, causing an address-in-use failure or reuse of a broker where `sessions[0]` can belong to the other capture and receive its navigation and highlight commands.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "chore(launch-video): add agent-attention..." | Re-trigger Greptile |
| const attentionEnv: Record<string, string> = { | ||
| XDG_CONFIG_HOME: configHome, | ||
| XDG_RUNTIME_DIR: makeTempDir("hunk-video-runtime-"), | ||
| HUNK_MCP_PORT: "47911", |
There was a problem hiding this comment.
Fixed port breaks daemon isolation
If two attention captures overlap or a previous capture's detached broker remains healthy, both runs use the host-global 127.0.0.1:47911 endpoint despite their separate runtime directories, causing an address-in-use failure or reuse of a broker where sessions[0] can belong to the other capture and receive its navigation and highlight commands.
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/launch-video/capture.ts
Line: 217
Comment:
**Fixed port breaks daemon isolation**
If two attention captures overlap or a previous capture's detached broker remains healthy, both runs use the host-global `127.0.0.1:47911` endpoint despite their separate runtime directories, causing an address-in-use failure or reuse of a broker where `sessions[0]` can belong to the other capture and receive its navigation and highlight commands.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.A pinned port was a machine-wide resource: concurrent captures, a daemon left by a crashed run, or an unrelated listener on that port could make the scene talk to the wrong daemon or fail to start one. Binding port 0 and handing the OS-assigned port to the scene keeps daemon isolation true per run instead of true by convention.
…ture The attention scene hard-coded its isolated daemon, its session CLI runner, and its demo content inside one scene function, so any future scene that wants to show an agent driving Hunk would have had to copy all three. Split that glue out: agentDriver.ts owns the private daemon (scratch runtime dir plus an OS-assigned port, never HUNK_MCP_DISABLE), polls registration, and plays declarative gestures — silent commands issued off camera, shell commands typed on camera against the same daemon. demoContent.ts owns the generated report module and the demo repos, so every line and offset a scene points at is computed instead of hand-counted. The scene becomes captureAgentScene: it now also shows the CLI surface itself, a cross-file mark, and a comment persisting what a mark cannot, with frames renamed to the agent- prefix.
Capture scenes rot when nothing consumes their frames: the compose preflight only fails on frames a storyboard references. Append a six-shot agent segment to the canonical storyboard so the reworked scene's frame names are checked in and exercised by every full-capture preflight, and document how agent-driven scenes are authored — isolated daemon, declarative gestures, `--repo .` on camera, computed offsets.
What
Turns the one-off
attentionscene into reusable infrastructure for showcasing agent/CLI-driven Hunk in demo videos, and broadens the scene itself into a full agent story:scripts/launch-video/agentDriver.ts(new) —launchAgentDrivenHunk()runs a TUI against a daemon nobody else can see (scratchXDG_RUNTIME_DIR+ OS-assignedHUNK_MCP_PORT, neverHUNK_MCP_DISABLE), polls until the session registers, and hands backrun/runJsonsession-CLI handles plus an optional on-camera shell sharing the same isolated env.driveGestures()plays a declarative sequence:silentgestures issue a command off camera and snap the TUI reacting;shellgestures type the same kind of command on camera, then snap the shell and/or the TUI.scripts/launch-video/demoContent.ts(new) — the generated report module, the demo repos, andlocateNeedle, so every line number and character offset a scene points at is computed rather than hand-counted.captureAgentScene(wascaptureAttentionScene,SCENES=agent) — built entirely on the driver and gestures, withagent-frames.Why
The agent surfaces' whole point is that they arrive over the session daemon, so the scene must drive them for real. But the daemon setup, the CLI runner, and the demo content were all buried inside one scene function — a second agent scene would have had to copy all three. Splitting them out makes "an agent drives this review" a capability of the capture pipeline instead of a property of one shot.
The scene
Opening review shot →
hunk session listtyped on camera (the CLI surface, one live session) → hunk-level vs line-exact landing (--hunkparks at the top of a tall hunk;--new-line 86lands the buried comparator, typed on camera with the computed line) → character-range warning mark → tone-only repaint ascurrent(viewport untouched, isolating--tonefrom--focus) → cross-filehighlight add … --focustyped on camera → acomment addon that same line, showing what persists when a mark does not →highlight clear.On-camera commands select the session with
--repo .from the demo repo: a selector is mandatory (hunk session navigatewith neither<session-id>nor--repoerrors), and an absolute path or a UUID reads badly on screen.Storyboard consumer
compose.mjsgains a six-shot agent segment before the outro (agent-review,agent-shell-nav,agent-line-nav,agent-mark-warning,agent-mark-focus,agent-comment), withNEWbadges on the line-exact and mark claims. Capture scenes rot when nothing consumes their frames — the compose preflight only checks frames a storyboard references — so this keeps the scene exercised by every full-capture preflight. The rest of the storyboard is still the 0.18 reference and is unchanged.skills/hunk-launch-video/SKILL.mddocuments the pattern under "Authoring scenes".Verification
bun run typecheck,bun run lintclean.SCENES=agent bun run scripts/launch-video/capture.tsrun twice; both produced the same 17 frames with no errors.agent-shell-list,agent-shell-nav,agent-line-nav,agent-mark-warning,agent-mark-focus,agent-comment,agent-clear: typed commands and their real output are legible in the shell frames, marks are visibly painted on the exact ranges, the note renders as an agent-note card, and each landing sits near the top of the viewport.Notes
scripts/launch-video/never ships to npm).