feat(minder): upload only agent activity from after setup

Description

By default, glab minder now uploads only agent activity from after the user set up each agent with glab minder setup. Before this change, resuming a Claude Code, OpenCode or Cursor conversation from before setup uploaded its earlier turns, and the fallback sync uploaded Codex and Cursor sessions from the last 89 days.

Setup records when it first set up each agent in a new file next to the existing agent lists, once the user confirms. Running setup again keeps the first time. The new --include-history flag also uploads the last 89 days for the agents a setup sets up for the first time. An agent set up earlier keeps what it uploads, because a later setup cannot bring back what was skipped. Setup refuses the flag when every agent is set up already, and says how to start again. The setup prompt says exactly which activity is uploaded for each agent: from now on, from when it was first set up, or from the last 89 days.

For Claude Code, OpenCode and Codex, sync leaves out transcript entries timestamped before setup, in both the hooks and the fallback sync. For a session that started before setup it also leaves out the goal taken from an earlier prompt and the start time. A tool call made before setup is left out together with its result, even when the result arrives after setup. A session whose syncing starts partway through its transcript takes its goal from its first prompt after setup. Claude Code compaction summaries are no longer uploaded as prompts, because they can describe the conversation from before setup. A transcript that was last active before setup is skipped to its end the first time glab sees it, so later turns of a resumed session are still uploaded without reading old transcripts on every run.

Cursor transcripts have no timestamps. When setup first sets up Cursor, it records where each existing Cursor transcript ends, as the point its syncing starts. A resumed conversation from before setup then uploads exactly the turns added after setup, and a transcript created after setup uploads from its beginning. Setup fails and records nothing for Cursor if it cannot read a workspace or transcript, so no transcript is left out. With --include-history, setup records this only for transcripts unchanged for longer than 89 days. A chat that Cursor copies under a new ID counts as new. The help text says so. Setup and sync share the code that lists Cursor transcripts and the code that keeps each session's sync position.

A hook sync that cannot read a session's sync position now fails instead of uploading the transcript from its beginning. A session that glab has uploaded nothing for is no longer created on GitLab only to be marked completed. The agent files are now replaced atomically.

Agents set up by an earlier glab version have no recorded time. They keep the 89-day behaviour until the user runs setup again, and the help text says so. glab minder setup --uninstall removes the setup times and the Cursor snapshot along with the rest of the local state.

Closes https://gitlab.com/gitlab-org/cli/-/work_items/8776

How has this been tested?

New unit tests cover:

  • Claude Code through the hook and through the fallback sync, including a compaction summary.
  • A Codex session that runs across setup, and a Codex session from before setup that is resumed.
  • An OpenCode session from before setup.
  • Cursor transcripts from before and after setup, through the fallback sync and through the hook.
  • A sync position that cannot be read.
  • A tool call that spans setup, with its result in the same sync or a later one, and the goal of a resumed Claude Code, Codex and Cursor session.
  • Completing a session with and without earlier uploads.
  • The setup snapshot: taken on first setup and not on re-runs, limited to old transcripts with --include-history, following symlinked workspaces, and failing on an unreadable workspace.
  • --include-history on a re-run, agents set up by an earlier glab version, an unreadable setup file, the setup prompt for each case, and uninstall removing the new state.

go test ./internal/commands/govern/... passes, and so does go test -race on the sync, setup and shared packages. golangci-lint run ./internal/commands/govern/... passes for macOS, Linux and Windows.

Edited by Jean van der Walt

Merge request reports

Loading
Loading