Skip to content

feat(daemon): send the git repository so projects group by repository - #356

Merged
AnnatarHe merged 11 commits into
mainfrom
claude/bold-mayer-a98vnb
Nov 26, 2026
Merged

AnnatarHe merged 11 commits into
mainfrom
claude/bold-mayer-a98vnb

Conversation

@AnnatarHe

@AnnatarHe AnnatarHe commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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):
    • asks git (found through CommandService) for a directory's top level and its origin remote (else upstream, else the first by name), with remote get-url so insteadOf applies
    • runs git without optional locks, prompts or translations (LC_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 others
    • caches definitive answers (10 min in the daemon) and unknown ones (a timeout, git refusing an untrusted repository, a signal) for 30 s
  • model.CanonicalRepositoryURL turns any remote into https://<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.
  • OTEL processor adds vcs.repository.url.full to metrics and log events whose resource has a pwd and 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.
  • Backfill adds the repository to uploaded events: the one a Codex rollout recorded at session start, else the transcript directory's.
  • Migration of existing projects: 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.v1 only when every folder got an answer. Generic host names (localhost, runner, …) are skipped.
  • Opt-out: aiCodeOtel.sendRepository: false stops every lookup, removes the repository from records and spans, attaches none in backfill and skips the migration. A local aiCodeOtel block now merges field by field.

Tests

  • go vet ./... and go test ./... pass, -race on the resolver.
  • New tests cover URL normalization and escaping, the resolver (fake git, a real git init repo, 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.

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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T09:58:02.359191Z 9c8e29e New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread daemon/project_migration.go Resolved
Comment thread cmd/daemon/main.go Resolved
Comment thread model/git_repository.go Resolved
Comment thread daemon/aicode_otel_processor.go Resolved
Comment thread model/project_migration.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread commands/aicode_projects.go Resolved
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.24726% with 40 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
model/git_repository.go 91.47% 15 Missing ⚠️
commands/aicode_projects.go 78.26% 10 Missing ⚠️
model/project_migration.go 90.00% 6 Missing ⚠️
daemon/project_migration.go 90.47% 4 Missing ⚠️
daemon/aicode_otel_processor.go 93.87% 3 Missing ⚠️
model/config.go 83.33% 2 Missing ⚠️
Flag Coverage Δ
unittests 87.37% <91.24%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
commands/aicode_backfill.go 91.07% <100.00%> (+0.08%) ⬆️
commands/cc.go 81.08% <ø> (ø)
commands/codex.go 100.00% <ø> (ø)
daemon/socket.go 87.43% <100.00%> (+0.69%) ⬆️
model/aicode_backfill_codex.go 85.92% <100.00%> (+0.15%) ⬆️
model/aicode_backfill_common.go 92.61% <100.00%> (+0.64%) ⬆️
model/aicode_otel_claude_settings.go 88.11% <100.00%> (+0.81%) ⬆️
model/api_project_repositories.go 100.00% <100.00%> (ø)
model/api_session_project.go 100.00% <100.00%> (ø)
model/types.go 100.00% <100.00%> (ø)
... and 6 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

⏱️ shelltime track performance

✅ No significant change in shelltime track latency

Comparing main @ 1ac8def → #356 @ 9c8e29e. Each scenario execs the binary the way the shell hooks do; values are the median of 10 interleaved rounds. Lower is better.

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.

@shelltime

shelltime Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

☁️ Claude Code cloud · Add Git-Based Project Identity and Backfill Migration

Implemented Git remote–based project identification, migration/backfill support for existing path-based projects, and admin-compatible project repository migration handling.

💰 Cost 🔢 Tokens ⏱️ Duration 🧠 Model 💬 Prompts ✏️ Lines
$71.45 258M 3h 4m (2h 9m active) claude-opus-5-5 4 +1206 / −0

258M tokens: 3.2K input · 442.2K output · 256.2M cache read · 1.4M cache write

📝 AI summary

Updated 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 cli/model/git_repository.go and api_project_repositories.go, integrated the behavior into project migration logic, and expanded coverage in git_repository_test.go.

On the server, added project-repository models, handlers, task logic, and schema support in server/model/project_repo.go, server/handler/cc_projects.go, server/tasks/ccsession.project_repo.go, and server/schema/user.aicodeotel.project_scope.go. This provides backfill/migration of existing path-based project records to repository-based identities and exposes the migration through the existing admin workflow. The completed changes were reviewed and merged as requested.

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread daemon/aicode_otel_processor.go Resolved
Comment thread model/project_migration.go Resolved
Comment thread daemon/project_migration.go Resolved
Comment thread model/project_migration.go Resolved
Comment thread commands/aicode_projects.go Resolved
Comment thread daemon/aicode_otel_processor.go Resolved
Comment thread daemon/aicode_otel_processor.go Resolved
…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
Comment thread model/git_repository.go Resolved
Comment thread daemon/aicode_otel_processor.go Resolved
Comment thread model/git_repository.go Resolved
Comment thread model/git_repository.go Resolved
Comment thread commands/aicode_projects_test.go Resolved
Comment thread model/project_migration.go Resolved
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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread daemon/aicode_otel_processor.go Resolved
Comment thread daemon/socket.go Resolved
Comment thread daemon/aicode_otel_processor.go Resolved
Comment thread commands/aicode_projects_test.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread model/git_repository.go Resolved
Comment thread model/project_migration.go Resolved
Comment thread model/git_repository.go Resolved
Comment thread daemon/aicode_otel_processor.go Resolved
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
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

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
Comment thread model/types.go Resolved
Comment thread daemon/project_migration.go Resolved
Comment thread daemon/project_migration.go Resolved
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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread daemon/aicode_otel_processor.go Resolved
…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
Comment thread daemon/project_migration.go Resolved
Comment thread model/project_migration.go Resolved
Comment thread daemon/aicode_otel_processor.go Resolved
Comment thread cmd/daemon/main.go Resolved
Comment thread model/git_repository.go Resolved
Comment thread daemon/aicode_otel_processor.go Resolved
Comment thread model/aicode_backfill_common.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread daemon/aicode_otel_processor.go Resolved
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
@AnnatarHe
AnnatarHe merged commit 396e602 into main Nov 26, 2026
11 checks passed
@AnnatarHe
AnnatarHe deleted the claude/bold-mayer-a98vnb branch November 26, 2026 09:57
}

// insideDir reports whether path is root or a directory below it.
func insideDir(path, root string) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

2 participants