Skip to content

Track desktop conversations vibetime never saw start, including every Cursor Agent conversation - #146

Merged
iamnotstatic merged 4 commits into
mainfrom
iamnotstatic/adopt-open-sessions
Oct 29, 2026
Merged

iamnotstatic merged 4 commits into
mainfrom
iamnotstatic/adopt-open-sessions

Conversation

@iamnotstatic

@iamnotstatic iamnotstatic commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Desktop hooks only opened a session on SessionStart, and every later event for an unknown session id was dropped. Two kinds of conversation never get a SessionStart that vibetime sees:

  1. A conversation that was already open when vibetime was installed. A user reported their Claude Desktop session wasn't counted. People keep these open for days.
  2. Every Cursor Agent conversation. Cursor 3.20.17 sends no sessionStart for an Agent conversation. Its own hooks log from 2026-10-29 shows workspaceOpen, then beforeSubmitPrompt, postToolUse, subagentStart/Stop and stop, with the hooks loaded and no sessionStart step. Across every Cursor log on the maintainer's machine, sessionStart fired once, on Sep 14. Production shows the result: Cursor sessions went 36, 14, 7, 14, 6, 1 over the last six weeks.

Change

An activity event (prompt, tool call, stop) for a session id we have never seen now opens the session, as SessionStart would:

  • Only work from that point counts. The baseline is taken then, so commits from before vibetime could see the conversation aren't claimed. That's consistent with the ledger rule that a session can't own work that landed before it was running.
  • The opening event also runs the start housekeeping. That's the install repair, the tunables refresh, and reaping stale sessions, which until now only ran on SessionStart. Without it, Cursor-only users would never get any of them. It runs once per opened session, never per event, and never in a folder with no repo.
  • Unchanged: sessions we've already seen (a clean end past the inactivity window still can't be revived), a SessionEnd for an unseen id (opens nothing), and tool tagging (imported Claude hooks inside Cursor are still tagged cursor).

Subagents

A subagent must not open a session of its own. The newest open session in a checkout gets its commits, so it would take them from the parent.

  • Claude Code: checked with a real claude -p run. Every event inside an Agent subagent carried the parent's session_id, and the subagent was identified only by agent_id.
  • Codex: its hooks docs say "Subagent hooks use the parent session id".
  • Cursor: logged in the app. subagentStart/subagentStop carry the parent's conversation_id, and the subagent is identified by subagent_id, which looks like call-<uuid>-2\nfc_<uuid>_0. That isn't a uuid, so it fails the session-id check even if it ever arrived as the id. The subagent itself didn't run a tool, because its model was unavailable on a Free plan, so a tool call from inside a Cursor subagent wasn't observed directly.
  • ZCode: sub-agent ids are already rejected by their prefix.

Verified

  • test/hook-adopt.test.mjs replays the payload Cursor actually sent (prompt and email removed), firing it twice at once, as Cursor runs both its own and the imported Claude hooks:
    • the conversation opens one session tagged cursor and later counts a commit;
    • a Cursor subagent id opens nothing;
    • the housekeeping runs when a session opens and not for events in a folder with no repo.
  • Against the earlier Cursor-gated version all three tests fail, and against the version without housekeeping the housekeeping test fails.
  • The built CLI, fed the logged payload on stdin exactly as Cursor runs it, answers {}, exits 0 and records one Cursor session.
  • Earlier on this PR: the adoption test fails on main; eight concurrent cold hook processes on one unseen id produce one row (6/6 rounds); in a folder with no repo each event costs one repo lookup (~14 ms) and creates nothing.
  • Full suite: 202/202 under a scratch HOME (Write hook configs atomically, keep tests out of the real home, refresh stale Claude hooks #147 makes that the default).

Changes from release QA

  • The housekeeping runs once. Cursor runs two copies of every hook as separate processes, and both used to run the housekeeping on the first prompt. addSession now returns whether it inserted the row, and only that process does the housekeeping. The test runs two real processes released at one instant: it fails 3/3 without the change (two settings fetches) and passes 3/3 with it. An in-process version passed either way, so it was replaced.
  • The adoption tests use a local stub API. They had set VIBE_API_URL, which the CLI doesn't read; the variable is VIBE_API. Their settings fetch went to the real API, a read-only GET.
  • Known cost: the first prompt of a conversation opened this way waits for the housekeeping, as a SessionStart already does. That's the settings fetch, capped at 1.2 s and skipped while the cached settings are fresh, plus reaping. It happens once per session.

…e installed

Its first prompt or tool call after install opens the session, with the
baseline taken then, so only work from that point counts.
Claude Code and Codex send a subagent's events under the parent's session
id. Cursor's docs don't say, and a subagent opened as its own session would
take the parent's commits, so Cursor waits until that is checked.
Cursor 3.20 sends no sessionStart for an Agent conversation, so every event
after it was dropped: production shows Cursor sessions falling to one a week.
Opening a session from the first event it sees now covers Cursor too, and a
session opened that way runs the start housekeeping (install repair,
tunables, reap) that only sessionStart used to run, once rather than per
event. A subagent's start and stop arrive under the parent's conversation id,
and a subagent id is not a uuid, so it never opens a session of its own.
@iamnotstatic iamnotstatic changed the title Track a desktop conversation that was already open at install Track desktop conversations vibetime never saw start, including every Cursor Agent conversation Oct 29, 2026
Cursor runs two copies of every hook at once. Both opened the session in
their own eyes, so both ran the repair and the tunables fetch on the first
prompt. addSession now says whether it inserted. The adoption tests also
point VIBE_API at a local stub instead of the real API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant