Skip to content

fix: hook setup safety, background subagent lifecycle, review clock (v0.9.2) - #95

Merged
patoles merged 4 commits into
mainfrom
fix/v0.9.2
Oct 9, 2026
Merged

patoles merged 4 commits into
mainfrom
fix/v0.9.2

Conversation

@patoles

@patoles patoles commented Oct 9, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Bug fix release v0.9.2. Three separate commits, one per fix:

1. Hook setup only touches Agent Flow's own hooks (fixes #73)

Setup treated any hook URL starting with http://127.0.0.1: as ours. That deleted other tools' loopback HTTP hooks from ~/.claude/settings.json on install (npx agent-flow-app, pnpm run setup, the extension). It was worse in the extension: migrateHttpHooks() rewrote those hooks into Agent Flow command hooks on every activation, in both the global and workspace settings. A foreign loopback hook also made setup think it was already installed, so our own hooks were skipped.

  • Only our command hook and the legacy bare-origin HTTP hook (http://127.0.0.1:<port>, no path) are matched, in setup.js, the extension and uninstall.js
  • A settings file that fails to parse is left untouched with an error. Before, it was replaced by a file holding only our hooks, losing permissions, env, etc.
  • Settings are written via temp file + rename
  • Matching moved into a vscode-free extension/src/hook-entries.ts with unit tests

One assumption to confirm: the legacy HTTP hooks predate the public repo, so I couldn't find their exact URL in git history. The hook server accepts POSTs on any path, so I assumed the installer wrote the bare origin. If old versions used a path, the regex in hook-entries.ts, setup.js and uninstall.js needs to allow it.

2. Background subagents complete on their <task-notification> (fixes #92, parts 1 and 2 of #91)

Background Agent/Task launches (the Claude Code default) get a tool_result right away that only confirms the launch (toolUseResult.status: "async_launched"). We treated it as the finish. The node then either looked busy again on the next tool call, or faded out and the rest of its events were dropped.

  • Background launches stay pending until a <task-notification> with their tool_use_id arrives. Notifications for other background tasks (Bash, etc.) are ignored
  • Prescan rebuilds pending launches, so subagents started before attach still complete
  • The subagent's model comes from toolUseResult.resolvedModel unless its own transcript already reported one
  • <synthetic> placeholder model ids are ignored

Part 3 of #91 (keeping the model for finished subagents) is a separate feature and isn't included here.

3. Review clock keeps moving between events (fixes #90)

The animation loop only re-rendered React when an event was processed, so the elapsed time, knob and counters froze during quiet stretches. It now also re-renders when the clock crosses a whole second, still throttled to 250ms. That's at most 1 render per second at 1x when idle, instead of the 4 per second a plain isPlaying check would cost in live mode. The decision is a small pure helper with tests, and the root pnpm test now also runs web/hooks/**/*.test.ts.

Also: version bumped to 0.9.2 (extension and app), changelog updated.

How to test

Checklist

Setup matched any hook URL starting with http://127.0.0.1: as Agent Flow's,
so other tools' loopback HTTP hooks were deleted from settings.json on
install, and the VS Code extension rewrote them into Agent Flow command
hooks on every activation. A foreign loopback hook also made setup think
it was already installed, so Agent Flow's own hooks were skipped.

- Match only our command hook and the legacy bare-origin HTTP hook
  (http://127.0.0.1:<port>) in setup.js, the extension and uninstall.js
- Leave a settings.json that fails to parse untouched instead of
  replacing it with a hooks-only file
- Write settings via temp file + rename
- Move the hook matching into a vscode-free module with unit tests, and
  add tests for setup.js and the uninstall script

Fixes #73
Claude Code launches Agent/Task subagents in the background by default.
The tool_result written right after the tool_use only confirms the launch
(toolUseResult.status "async_launched"); the real finish arrives later as
a <task-notification> user entry. The parser emitted subagent_return and
agent_complete on the launch receipt and discarded the notification as
system content, so background subagents finished at launch.

- Keep background launches pending and complete them when a
  <task-notification> with their tool_use_id arrives; other background
  tasks (Bash, etc.) that send the same block are ignored
- Rebuild pending background launches during prescan so subagents
  started before attach still complete
- Emit the subagent's model from toolUseResult.resolvedModel unless its
  own transcript already reported one
- Ignore <synthetic> placeholder model ids

Fixes #92
Refs #91
The animation loop advanced currentTime every frame but only pushed state
to React when an event was processed, so the elapsed-time label, the
scrubber knob and the counters froze during quiet stretches of review
playback until the next event or a pause.

Also re-render when the clock crosses a whole second, still throttled to
250ms. The decision lives in a small pure helper with unit tests, and the
root test script now runs web/hooks tests.

Fixes #90
@patoles
patoles merged commit 504f063 into main Oct 9, 2026
2 checks passed
@patoles
patoles deleted the fix/v0.9.2 branch October 9, 2026 09:50
VladRd20 added a commit to VladRd20/agent-flow that referenced this pull request Nov 5, 2026
…es#96 patoles#97 patoles#98 patoles#99 patoles#56 patoles#103 patoles#104 patoles#106)

Conflict resolutions:
- hooks-config.ts / uninstall.js / .vscodeignore: take upstream's hook-entries
  refactor (supersedes our earlier partial port of the v0.9.2 hook fixes).
- app/src/server.ts: keep our read-only (GET/HEAD) + --host handling and add
  upstream's DNS-rebinding guard, adapted: loopback binds accept loopback Host
  only; LAN/WAN binds (--host 0.0.0.0) also accept IP-literal Hosts and names
  in AGENT_FLOW_ALLOWED_HOSTS (new isAllowedRemoteHost in request-guard.ts).
  Upstream's loopback-only check would have locked out remote/phone access.
- protocol.ts / event-source.ts: both sides added fileTail; keep our docs,
  add upstream's SubagentState.completed.
- timeline-panel.tsx: keep mobile maxHeight + upstream model hover handler.
- transcript-parser.test.ts add/add: ours kept, upstream's moved to
  transcript-parser-upstream.test.ts; upstream fixtures get pendingCatchUpSpawns.
- package.json test script: keep ours (cross-env, web/**) which is a superset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant