Repository navigation
feat(daemon): send the git repository so projects group by repository - #356
Conversation
The server grouped coding agent sessions into projects by working directory, so renaming or moving a clone started a new project. The CLI now names the git repository a session ran in, as vcs.repository.url.full in the form Claude Code reports (https://<host>/<path>, credentials and .git dropped). - model.GitRepositoryResolver asks git for a directory's origin remote (else upstream, else the first) without optional locks, and caches answers, negative ones too. - The OTEL processor adds the repository to records whose resource has a pwd and that don't name one; Claude Code's own value wins. - session_project sends the statusline directory's repository. - Backfill adds it to uploaded events: the repository a Codex rollout recorded at the start, else the transcript directory's. - Migration: `shelltime cc projects` (also `codex projects`) lists this machine's folder projects from the server and moves the folders that are still clones into their repositories' projects. The daemon runs it once, two minutes after start, and leaves a marker in ~/.shelltime; an older server or a failure leaves none, so the next start tries again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRd5iov8tzMQ1SaQ2Fk
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f7fc0fbc9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
⏱️
|
| Scenario | base | head | Δ | p | |
|---|---|---|---|---|---|
Startup/floor |
510 µs ±2% | 511 µs ±1% | ~ | 0.631 | A/A |
Startup/version |
4.79 ms ±1% | 4.81 ms ±1% | +0.33% | 0.043 | ✅ |
Track/daemon/pre |
5.07 ms ±1% | 5.09 ms ±1% | ~ | 0.063 | ✅ |
Track/daemon/post |
5.11 ms ±1% | 5.13 ms ±0% | ~ | 0.247 | ✅ |
Track/direct/pre |
5.02 ms ±0% | 5.05 ms ±1% | ~ | 0.123 | ✅ |
Track/direct/post |
7.01 ms ±0% | 7.02 ms ±1% | ~ | 0.971 | ✅ |
Track/direct/post-sync |
9.67 ms ±1% | 9.64 ms ±1% | -0.36% | 0.023 | ✅ |
Binary size: 19.2 MiB → 19.3 MiB (+0.4%).
CPU, tail latency and memory
Per exec, base → head (Δ when significant).
| Scenario | p95 wall | user CPU | sys CPU | peak RSS |
|---|---|---|---|---|
Startup/floor |
567 µs → 567 µs | 276 µs → 279 µs | 188 µs → 182 µs | 9.2 MiB → 9.2 MiB |
Startup/version |
5.09 ms → 5.15 ms (+1.18%) | 1.87 ms → 2.00 ms | 3.55 ms → 3.46 ms | 15.7 MiB → 15.7 MiB |
Track/daemon/pre |
5.46 ms → 5.50 ms | 2.04 ms → 2.07 ms | 3.64 ms → 3.69 ms | 16.3 MiB → 16.5 MiB (+1.17%) |
Track/daemon/post |
5.47 ms → 5.44 ms | 2.11 ms → 2.06 ms | 3.71 ms → 3.73 ms | 16.3 MiB → 16.4 MiB (+0.78%) |
Track/direct/pre |
5.39 ms → 5.42 ms | 2.04 ms → 1.96 ms | 3.60 ms → 3.70 ms | 16.2 MiB → 16.4 MiB (+1.23%) |
Track/direct/post |
7.46 ms → 7.49 ms | 3.81 ms → 3.76 ms | 4.06 ms → 4.11 ms | 16.8 MiB → 17.0 MiB (+1.50%) |
Track/direct/post-sync |
10.43 ms → 10.40 ms | 5.98 ms → 5.74 ms | 6.25 ms → 6.43 ms | 19.4 MiB → 19.3 MiB (-0.26%) |
benchstat
goos: linux
goarch: amd64
pkg: github.com/malamtime/cli/perf
cpu: AMD EPYC 7763 64-Core Processor
│ base │ head │
│ sec/op │ sec/op vs base │
Startup/floor-4 509.6µ ± 2% 511.4µ ± 1% ~ (p=0.631 n=10)
Startup/version-4 4.793m ± 1% 4.809m ± 1% +0.33% (p=0.043 n=10)
Track/daemon/pre-4 5.068m ± 1% 5.095m ± 1% ~ (p=0.063 n=10)
Track/daemon/post-4 5.107m ± 1% 5.128m ± 0% ~ (p=0.247 n=10)
Track/direct/pre-4 5.023m ± 0% 5.048m ± 1% ~ (p=0.123 n=10)
Track/direct/post-4 7.008m ± 0% 7.024m ± 1% ~ (p=0.971 n=10)
Track/direct/post-sync-4 9.670m ± 1% 9.635m ± 1% -0.36% (p=0.023 n=10)
geomean 4.159m 4.171m +0.28%
│ base │ head │
│ p50-sec/op │ p50-sec/op vs base │
Startup/floor-4 499.9µ ± 1% 504.7µ ± 1% ~ (p=0.218 n=10)
Startup/version-4 4.804m ± 1% 4.811m ± 1% ~ (p=0.393 n=10)
Track/daemon/pre-4 5.038m ± 1% 5.064m ± 2% ~ (p=0.529 n=10)
Track/daemon/post-4 5.100m ± 1% 5.127m ± 1% ~ (p=0.247 n=10)
Track/direct/pre-4 4.985m ± 1% 5.021m ± 1% +0.72% (p=0.011 n=10)
Track/direct/post-4 7.062m ± 1% 7.094m ± 3% ~ (p=0.739 n=10)
Track/direct/post-sync-4 9.677m ± 0% 9.615m ± 1% -0.64% (p=0.007 n=10)
geomean 4.145m 4.161m +0.38%
│ base │ head │
│ p95-sec/op │ p95-sec/op vs base │
Startup/floor-4 566.9µ ± 3% 566.5µ ± 3% ~ (p=0.912 n=10)
Startup/version-4 5.094m ± 1% 5.154m ± 1% +1.18% (p=0.029 n=10)
Track/daemon/pre-4 5.461m ± 2% 5.497m ± 1% ~ (p=0.218 n=10)
Track/daemon/post-4 5.475m ± 2% 5.439m ± 1% ~ (p=0.684 n=10)
Track/direct/pre-4 5.387m ± 1% 5.417m ± 1% ~ (p=0.315 n=10)
Track/direct/post-4 7.457m ± 2% 7.485m ± 1% ~ (p=0.684 n=10)
Track/direct/post-sync-4 10.43m ± 2% 10.40m ± 1% ~ (p=0.315 n=10)
geomean 4.479m 4.490m +0.25%
│ base │ head │
│ peak-rss-B │ peak-rss-B vs base │
Startup/floor-4 9.179Mi ± 2% 9.197Mi ± 2% ~ (p=0.985 n=10)
Startup/version-4 15.72Mi ± 0% 15.71Mi ± 0% ~ (p=0.123 n=10)
Track/daemon/pre-4 16.30Mi ± 0% 16.49Mi ± 0% +1.17% (p=0.000 n=10)
Track/daemon/post-4 16.27Mi ± 0% 16.40Mi ± 0% +0.78% (p=0.000 n=10)
Track/direct/pre-4 16.17Mi ± 0% 16.37Mi ± 0% +1.23% (p=0.000 n=10)
Track/direct/post-4 16.77Mi ± 0% 17.02Mi ± 0% +1.50% (p=0.000 n=10)
Track/direct/post-sync-4 19.38Mi ± 0% 19.33Mi ± 0% -0.26% (p=0.000 n=10)
geomean 15.35Mi 15.45Mi +0.65%
│ base │ head │
│ sys-sec/op │ sys-sec/op vs base │
Startup/floor-4 187.6µ ± 11% 181.7µ ± 12% ~ (p=0.684 n=10)
Startup/version-4 3.547m ± 6% 3.455m ± 4% ~ (p=0.165 n=10)
Track/daemon/pre-4 3.644m ± 3% 3.691m ± 4% ~ (p=0.529 n=10)
Track/daemon/post-4 3.709m ± 3% 3.734m ± 2% ~ (p=0.684 n=10)
Track/direct/pre-4 3.600m ± 3% 3.701m ± 3% ~ (p=0.075 n=10)
Track/direct/post-4 4.057m ± 3% 4.107m ± 5% ~ (p=0.165 n=10)
Track/direct/post-sync-4 6.250m ± 4% 6.432m ± 5% ~ (p=0.063 n=10)
geomean 2.608m 2.619m +0.43%
│ base │ head │
│ user-sec/op │ user-sec/op vs base │
Startup/floor-4 275.9µ ± 7% 278.6µ ± 9% ~ (p=0.631 n=10)
Startup/version-4 1.870m ± 7% 1.996m ± 8% ~ (p=0.105 n=10)
Track/daemon/pre-4 2.044m ± 3% 2.068m ± 10% ~ (p=0.912 n=10)
Track/daemon/post-4 2.107m ± 8% 2.065m ± 7% ~ (p=0.971 n=10)
Track/direct/pre-4 2.043m ± 5% 1.964m ± 4% ~ (p=0.123 n=10)
Track/direct/post-4 3.811m ± 3% 3.760m ± 7% ~ (p=0.123 n=10)
Track/direct/post-sync-4 5.984m ± 5% 5.742m ± 6% ~ (p=0.089 n=10)
geomean 1.940m 1.933m -0.39%
Δ compares medians; ~ means no significant difference (Mann-Whitney U, p ≥ 0.05). A scenario is flagged when it is more than 10% and more than 250µs slower with p < 0.05. Startup/floor runs true, not shelltime: it is an A/A check of runner noise. Runner: linux/amd64, AMD EPYC 7763 64-Core Processor . go1.27.1, 10 rounds × 100 execs per scenario and binary.
☁️ Claude Code cloud · Add Git-Based Project Identity and Backfill MigrationImplemented Git remote–based project identification, migration/backfill support for existing path-based projects, and admin-compatible project repository migration handling.
258M tokens: 3.2K input · 442.2K output · 256.2M cache read · 1.4M cache write 📝 AI summaryUpdated the CLI to identify projects using the Git organization and repository name when remote metadata is available, while retaining the working-directory path as a fallback for non-Git projects. Added repository parsing and API models in On the server, added project-repository models, handlers, task logic, and schema support in View this session on ShellTime → Updated 2026-11-26 10:09 UTC by ShellTime · totals for the whole session so far · the session page is visible to its owner |
…hine Review follow-ups on the git repository resolver and project migration: - A lookup runs within one 2 s budget instead of 2 s per git call, and concurrent lookups of one directory share one run, since the daemon resolves on the OTLP export path. git is found through CommandService, so the daemon's limited PATH reaches Homebrew and /usr/local/bin. - Only definitive answers are cached. A timeout or git failing to start no longer hides a directory's repository for the whole TTL. - The migration skips host names many machines share (localhost, ubuntu, runner, ...), leaves no marker when the server cut its list short, logs a marker it couldn't write, and doesn't run in AI cloud only mode. - README documents `shelltime cc projects` / `shelltime codex projects`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRd5iov8tzMQ1SaQ2Fk
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 81850e6ca1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…checked Second review round: - The migration pages through the server's listing by its last project, since folders it can't move stay listed; a run covers 50 pages. - A folder git couldn't answer for (timeout, git missing) counts as unchecked, not "no repository", and keeps the migration from writing its done marker; so does a machine without a host name of its own. - Lookups that timed out are remembered for 30 s, so a hung mount doesn't cost every OTLP export the whole budget. - A repository the agent named on the resource keeps the folder's off metrics too, and git isn't asked then. - `shelltime cc projects` is skipped in AI cloud only mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRd5iov8tzMQ1SaQ2Fk
Fourth review round: - A lookup runs on its own goroutine and is given up on after its budget, since a stat or git blocked on a hung network mount ignores the context; the directory gets no second lookup until it returns, and waiters are always released. The migration's folder check is bounded the same way and counts a hung folder as unchecked. - git refusing an untrusted repository (safe.directory) or killed by a signal is no definitive answer, so the migration retries the folder. - A git binary not found when the daemon started is looked for again every 30 s instead of never. - aiCodeOtel.sendRepository: false stops every lookup, removes the repository Claude Code reports, and skips the migration. - The projects command test no longer depends on the host name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRd5iov8tzMQ1SaQ2Fk
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e29ee39ee5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e4e5d83c6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Fifth review round: - Each path segment of a remote is decoded and escaped again, like the server, so "My%20Project" stays one name, "repo%23one" doesn't lose its tail to a fragment, and every spelling of a name gives one URL. - git runs with LC_ALL=C, since gitExitIsAnswer reads its messages; a translated safe.directory refusal no longer counts as "no repository". - A caller whose context ends stops waiting for a lookup, whose answer is kept for the next caller. - A migration run stops asking after three folders went unanswered, so a hung mount costs a few blocked threads, not one per folder. - The docs say spans get no repository from the folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRd5iov8tzMQ1SaQ2Fk
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
The run stopped asking after three folders went unanswered, which also counted folders git refuses (safe.directory), so three such folders kept every later folder unchecked on every run. Only stats that time out count now. A folder that can't be stat'ed for another reason than not existing counts as unchecked, not missing; an abandoned lookup's answer is no longer overwritten by "unknown"; and `cc projects` names a generic host name before it starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRd5iov8tzMQ1SaQ2Fk
config.local.yaml replaced the whole aiCodeOtel block, so a local file that only set debug or the port turned the collector's base settings back to their defaults, sendRepository: false included, and the daemon started sending repository names again. The block now merges field by field, like codeTracking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRd5iov8tzMQ1SaQ2Fk
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c08b32a097
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ository A record that names a working directory of its own other than its resource's got the repository of the resource's folder, which may be another clone. The daemon now takes that repository back, as the server does for the statusline's directory; a repository the record names itself stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRd5iov8tzMQ1SaQ2Fk
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 118fc32fe8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The previous change took the resource folder's repository back from any record naming another working directory, a subfolder of the same work tree too, which split the project. Records whose directory is inside the resource's work tree keep it now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRd5iov8tzMQ1SaQ2Fk
A caller whose context ended abandoned the lookup it had started, and every caller sharing it got "unknown" although git answered moments later. The lookup now runs on its own and publishes its answer to everyone waiting; only the budget turns it into "unknown". A record that names the same repository as its resource's folder keeps it even from another folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014EpZRd5iov8tzMQ1SaQ2Fk
| } | ||
|
|
||
| // insideDir reports whether path is root or a directory below it. | ||
| func insideDir(path, root string) bool { |
There was a problem hiding this comment.
Important: insideDir compares a record's pwd with repositoryRoot, which is git's rev-parse --show-toplevel. Git prints the symlink-resolved path, but the agent reports the path as the user typed it. If the project is reached through a symlink (macOS /tmp -> /private/tmp, ~/work -> /Volumes/...), a record in a subfolder of the resource's folder has a pwd that is not under the resolved root. unfillRepository then takes the repository back. The resource's own pwd still matches the equality check, so only subfolder records lose it, and one session splits into repository-grouped and folder-grouped records.
Fix: compare against the real path too. Run filepath.EvalSymlinks on the record's pwd (or on both sides) before insideDir, or keep the resolved pwd that was used for the lookup next to Root.
| // working directory of its own outside the resource's work tree: the repository is the | ||
| // resource's folder's, not necessarily that one's. A subfolder of the same work tree keeps it, | ||
| // and so does a repository the record itself named. | ||
| func unfillRepository(attrs map[string]any, res *otelResource, filled bool, pwd string) { |
There was a problem hiding this comment.
Nit (optional): unfillRepository keeps the resource folder's repository for any record whose pwd is below repositoryRoot. That includes a nested repository or submodule inside the work tree, which has its own remote. A record in <root>/vendor/lib, where lib is its own clone, gets the parent's repository, and the server puts the session in the wrong project. Only a different top-level or a record outside the root is handled.
Fix: if this matters, resolve the record's own pwd when it differs from the resource's and it is not a plain subfolder (the resolver is cached). Otherwise document the limitation next to the "subfolder keeps it" rule.
| func AttachBackfillRepositories(ctx context.Context, sessions []*BackfillSession, repos *GitRepositoryResolver) { | ||
| for _, s := range sessions { | ||
| if s.Repository == "" && repos != nil && len(s.Events) > 0 { | ||
| s.Repository = repos.Resolve(ctx, s.Events[0].Pwd).URL |
There was a problem hiding this comment.
Nit (optional): AttachBackfillRepositories resolves the whole session from s.Events[0].Pwd. If the first event has no Pwd (a summary or meta line), Resolve returns the zero value and every event of the session gets no repository, even though later events have a folder. A session that moved between folders or clones is also stamped with the first one's repository.
Fix: use the first non-empty Pwd, or resolve per event Pwd (the resolver caches) and set the attribute per event.
Also, this loop runs sequentially in the CLI. Each distinct folder on a hung mount costs up to about 2.25 s before it is marked stuck, so a large backfill can stall.
| unanswered++ | ||
| result.Unchecked++ | ||
| continue | ||
| case dirUnknown: |
There was a problem hiding this comment.
Nit (optional): any stat error other than "not exist" (EACCES on a parent, ENOTDIR because a path component is now a file) is counted as Unchecked, and Complete() is then false. That condition is permanent, so the daemon never writes the marker. It re-pages the whole list on every start and shelltime cc projects always prints "git didn't answer ... run it again". The resolver's own lookup treats the same stat error as a definitive "not a repository", so the two are inconsistent.
Fix: map ENOTDIR (and probably EACCES/EPERM) to dirMissing. Or keep dirUnknown only for errors that can clear up, such as EIO or a timeout.
Why
The server grouped coding agent sessions into projects by working directory. That breaks when a folder is renamed or moved, or when the agent starts in a worktree or a subfolder. The CLI now names the git repository a session ran in, and the server groups by it (shelltime/server#610).
What changes
model.GitRepositoryResolver(model/git_repository.go):CommandService) for a directory's top level and itsoriginremote (elseupstream, else the first by name), withremote get-urlsoinsteadOfappliesLC_ALL=C), within one 2 s budget per lookup, on its own goroutine, so a hung mount can't block the export path; concurrent lookups of a directory share one run, and a caller that gives up leaves it running for the othersmodel.CanonicalRepositoryURLturns any remote intohttps://<host>/<path>, the form Claude Code reports, without credentials, port or.git, each path segment escaped the same way as the server. A local path is no repository.vcs.repository.url.fullto metrics and log events whose resource has apwdand that name none, except records in a folder outside that work tree. A value the agent sent wins.session_project(statusline) sends the repository of the directory along with the path.shelltime cc projects/shelltime codex projects(--dry-run) lists this machine's folder projects from the server, page by page, checks the folders that still exist, and moves the clones into their repository's project. The daemon runs it once, 2 minutes after start (not in AI cloud only mode), and writes~/.shelltime/project-repositories.v1only when every folder got an answer. Generic host names (localhost,runner, …) are skipped.aiCodeOtel.sendRepository: falsestops every lookup, removes the repository from records and spans, attaches none in backfill and skips the migration. A localaiCodeOtelblock now merges field by field.Tests
go vet ./...andgo test ./...pass,-raceon the resolver.git initrepo, stuck and abandoned lookups, git's exit codes), OTEL attribute filling and the opt-out, the session_project body, backfill attachment, the migration (paging, unanswered folders, hung stats) and the config merge.