Repository navigation
feat: Show import progress, skip live sessions before the read, mark imports with (*) - #1893
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 10 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
Summary
Reviewed the import progress bar, the skip-before-the-read change in the Claude Code source, and the (*) marker. The wire compatibility story checks out on both sides (old proxy → report only; old agentop → no progress field), the NDJSON reader is bounded like every other body this client reads, and the skip-before-the-read change preserves the documented Sessions contract (a file's mtime is not older than its newest line, so skip still receives a time not before the parsed Updated). The rate limit (250 ms) matches the documented "at most 4 a second", and the progress tests are deterministic on that boundary (first line passes on the zero last, last line passes on done == total). No findings — the diff, the tests, and both docs pages agree with each other.
Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go (agentop client/cmd, TUI, importer, sessionapi), Docs
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing
All checks pass. Ready for human review.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
clawgenti
left a comment
There was a problem hiding this comment.
Summary
The changes look correct. Calling skip with the newest file mtime before the read keeps the Sessions contract: an mtime is never older than the lines in its file, so a Rule 1 or expired skip on the mtime is sound. A Rule 2 "current" skip on the mtime only fires when the archive copy is at least that new, and the existing newestAt re-check still catches a file that was only touched. The counters cannot double-count, because the first skip either drops the session or returns false. The NDJSON progress stream works with older peers in both directions: an old proxy sends one report line, which the scanner reads as the report, and an old client never sets progress. Two small, non-blocking comments are inline.
What I checked locally on bcd14d5 (merge base ef574d4):
go vetis clean oncore/session/...,core/sessionapi/...andcmd/agentop/....go test -racepasses oncore/session/importer/...,core/sessionapi/...,cmd/agentop/apiclientand thetuiimported-marker and title tests.- I ran
TestImport_ProgressLinesBeforeTheReport200 times under-race, and it passed every time. cmd/agentop: onlyTestReportSessionInterruption/names_the_cost_when_connections_are_attachedfails, and it fails the same way on the base. It is environmental and not related to this PR.- I sent
progresswith the wrong JSON type to head and base.{"progress":"yes"}and{"progress":1}get 400bad JSON bodyon head, and base ignored them. This field is new and only agentop sends it, so I don't consider it a regression.
Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go (importer, session API, agentop client/CLI/TUI), Docs
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing (CodeRabbit and Spellcheck skipped)
| } | ||
| got = append(got, p.Progress) | ||
| } | ||
| want := []importer.Progress{{Agent: "claude-code", Done: 0, Total: 2}, {Agent: "claude-code", Done: 2, Total: 2}} |
There was a problem hiding this comment.
suggestion: This exact want depends on timing. The {done:1,total:2} line is dropped only while the archive write of s1 takes less than importProgressEvery (250 ms). On a slow, -race CI runner a stalled fsync can take longer than that. The handler then sends a third line, and slices.Equal fails. It passed 200 times for me under -race, so the risk is low. You could make it deterministic in either of two ways: make importProgressEvery a package var and set it very high in the test, or assert only the first line (done == 0) and the last line (done == total).
| if last == nil { | ||
| fmt.Fprintf(w, "\rimporting %c", frames[i%len(frames)]) | ||
| } else { | ||
| fmt.Fprintf(w, "\r\033[K%s", progressBar(*last)) |
There was a problem hiding this comment.
nit: The bar line has about 70 columns at four-digit counts, and its width does not change. On a terminal narrower than the line, it wraps. \r\033[K then clears only the last physical row, so each 150 ms tick leaves another wrapped row behind. The spinner was too short to have this problem. You could cut the line to the terminal width, which term.GetSize gives for the *os.File, or drop the bar cells below a minimum width.
…orts with (*) - agentop import shows a progress bar on a terminal, not only a spinner. POST /v1/import with "progress": true sends NDJSON progress lines before the report. An older proxy ignores the field and sends only the report. The Claude Code and Bob sources report progress. - The Claude Code source calls skip with the file mtime before it reads the files. A live or expired session is not read now. A dry run on 2.8 GB of transcripts took 28.4 s before and 13.1 s after. - An imported session shows "(*)" before its title, not "imp". Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
1905569 to
a5eb2fd
Compare
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Since the approval of bcd14d5, the PR was rebased onto 31413332 (the #1892 Bob merge). The Bob source now takes the new progress parameter, TestSource_Progress covers it, and the docs say that the before-the-read skip belongs to the Claude Code source. The code changes are fine. The Bob source calls progress(i, len(all)) before each tree and progress(len(all), len(all)) after the loop, which meets the Source contract. Bob already calls skip before s.read, so the doc wording holds. The only Source implementers are bob and claude, so no other implementation breaks.
There is one blocking problem. Resolving the rebase conflict in docs/laptop-service.md deleted the text that #1892 and the forget-record PRs added on main: the 90% max_bytes stop, the forget-record and re-import counting rules, and the Flags and output: lead-in. It also leaves the paragraph ending in the fragment The import followed by a link. If this merges, those docs on main are reverted. See the inline comment.
The two earlier inline comments on bcd14d5 still apply to this head: the timing-dependent exact want in TestImport_ProgressLinesBeforeTheReport, and bar wrap on narrow terminals. Neither one blocks the merge.
What I checked locally on a5eb2fd (merge base 31413332):
- The range-diff against
bcd14d5shows changes only inbob.go,bob_test.go, the docs and the commit message. go buildandgo vetare clean oncore/...,cmd/agentop/...andcmd/cortex/....go test -racepasses oncore/session/importer/...(bob, claude, sqlitecli),core/sessionapi/...,cmd/agentop/apiclient,cmd/agentop/tui, andcmd/agentop -run 'Import|Progress'.
Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go (importer incl. Bob source, sessionapi, agentop client/CLI/TUI), Docs
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: pending (DCO and CodeQL pass so far; the rest is still running)
| project near it that the proxy wrote live or that an earlier import wrote. Flags | ||
| and output: | ||
| Each imported session is marked `(*)` in agentop. A Claude Code turn is priced | ||
| at today's rates. A Bob turn keeps Bob's own cost. LAST 1H shows imported turns only after the next restart. The import |
There was a problem hiding this comment.
must-fix: The rebase conflict resolution here dropped the main text that follows the marker sentence. On 31413332, the paragraph continues: "The import stops at 90% of max_bytes. A session that you erased, or that a limit removed, comes back in full on the next import. Its forget record tells the import which turns the cost ledger already holds. The turns inside that span are not counted again, and the turns after it are. A turn before the span is counted only when the cost ledger has no row of the same project near it that the proxy wrote live or that an earlier import wrote. Flags and output:". At this head the paragraph ends in ...only after the next restart. The import and goes straight into the link. Merging this would revert the forget-record docs from #1892 and the earlier forget-record PRs, and would leave a broken sentence. The intended change is only imp → (*). Please restore the rest of the paragraph:
| at today's rates. A Bob turn keeps Bob's own cost. LAST 1H shows imported turns only after the next restart. The import | |
| at today's rates. A Bob turn keeps Bob's own cost. LAST 1H shows imported turns | |
| only after the next restart. The import stops at 90% of `max_bytes`. A session | |
| that you erased, or that a limit removed, comes back in full on the next import. | |
| Its forget record tells the import which turns the cost ledger already holds. | |
| The turns inside that span are not counted again, and the turns after it are. A | |
| turn before the span is counted only when the cost ledger has no row of the same | |
| project near it that the proxy wrote live or that an earlier import wrote. Flags | |
| and output: |
…timing-safe Fixes review: docs/laptop-service.md lost the rossoctl#1892 import text in the merge and cut a sentence in two Fixes review: TestImport_ProgressLinesBeforeTheReport expected an exact line list that depends on the 250 ms limit Files: - core/sessionapi/import_test.go - docs/laptop-service.md Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
Fixes review: the timing-safe progress test no longer checked that the limit drops a middle line Files: - core/sessionapi/import.go - core/sessionapi/import_test.go Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
clawgenti
left a comment
There was a problem hiding this comment.
PR Review — feat: Show import progress, skip live sessions before the read, mark imports with (*)
All checks pass. Ready for human review.
Summary: Clean PR. The progress protocol (NDJSON with a progress field, report as last line) is backward-compatible in both directions, and the pre-read skip in the Claude Code source preserves the Sessions contract (file mtime ≥ newest line, so the skip time is not before the parsed Updated). The changed accounting for unreadable/expired transcripts is documented in both the PR body and docs/session-api.md.
Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go (importer, sessionapi, apiclient, TUI), docs, tests
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, signed-off: yes
CI status: passing (some jobs still pending at review time; Pre-commit, DCO, CodeQL, YAML lint, build-and-push all green)
Verified on head a5eb2fd:
go test -race -count=1on./core/session/importer/...,./core/sessionapi/...,./cmd/agentop/apiclient/...— all pass (new testsTestSessions_SkipBeforeTheRead,TestImport_ProgressLinesBeforeTheReport,TestClientImport_ProgressLines,TestSource_Progressincluded)go vetclean on./cmd/agentop/... ./core/session/... ./core/sessionapi/...gofmt -lclean on all touched Go dirsTestProgressBartable cases (including the 0/0 and 9/4 clamp cases) pass- Note:
TestReportSessionInterruptionincmd/agentopfails in this sandbox, but it fails identically onmain, so it is pre-existing and environment-specific, not introduced by this PR - The local clone was checked out on the PR head for the probes and returned to
mainafterwards; no files were modified
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
clawgenti
left a comment
There was a problem hiding this comment.
PR Review — follow-up on new commits c124454 and 8924af2
Two commits were pushed after my review of a5eb2fd. Reviewed the delta: no issues.
c124454restores the import paragraph indocs/laptop-service.mdthat the first revision had dropped, with the line wrapping fixed — good catch, that was a gap in the original diff.8924af2makesimportProgressEverya settable var and pins the rate-limit test to it. The timing-safety concern was real (the originalTestImport_ProgressLinesBeforeTheReportrelied on the two progress lines passing the rate limit by ordering alone).
Verified on head 8924af2: go test -race -count=1 ./core/sessionapi/ passes, go vet and gofmt -l clean on core/sessionapi.
Ready for human review.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
clawgenti
left a comment
There was a problem hiding this comment.
Review marker for the cycle's queued head a5eb2fd; the full reviews (including the follow-up covering c124454 and 8924af2) are posted above.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Clean, well-tested change. The NDJSON progress protocol is backward-compatible in both directions (older proxy → spinner fallback; older agentop → plain report), the skip-before-the-read optimization is measured (28.4 s → 13.1 s) and its mtime assumption ("no line is newer than its file") is sound and documented. Tests cover the new rate limit, the client stream parsing, the bar rendering, and the pre-read skip (with a root-safety guard). No must-fix findings; the two deferred nits in the PR body (mtime-on-restore, narrow-terminal bar wrap) are reasonable to leave to their open threads.
Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go (importer, sessionapi, agentop client/TUI), docs, tests
Agent/IDE config (.claude/.vscode): none
Commits: 3 commits, all signed-off: yes
CI status: passing (several Go CI jobs still pending at review time)
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| mod = f.mod | ||
| } | ||
| } | ||
| if skip(id, mod) { |
There was a problem hiding this comment.
nit: each imported session now calls skip twice — once pre-read with the file mtime (here) and again post-parse with newest. Both are needed for correctness (the mtime is only an upper bound on Updated, so the post-parse check can still drop a session the pre-read passed), but it doubles the store/ledger lookups for every session that is actually imported. With ~400 imported sessions that's negligible next to the ~1,400 reads you saved, so fine to leave — just noting it in case a future profile shows the skip closure getting expensive.
clawgenti
left a comment
There was a problem hiding this comment.
Review tracking marker for the automation state machine (full review posted above):
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Re-review at 8924af2. The must-fix from the a5eb2fd review is resolved, and the progress test is now deterministic. I found no new issues. Approving.
Resolved since the last review
- docs/laptop-service.md (was must-fix): The import paragraph now matches main's text exactly, from "only after the next restart." to "Flags and output:". The dangling "The import" fragment is gone.
git diff origin/main pr -- docs/laptop-service.mdshows one changed line, the intendedimp→(*). I diffed the PR's other.mdfiles against main too, and every removed line is an intendedimp→(*)edit. No other main text is reverted. Main has moved by 7 commits since this PR's merge base (dependency bumps only). None of them touch the PR's files, and the PR still merges into current main without conflicts. - TestImport_ProgressLinesBeforeTheReport (was a timing nit at bcd14d5):
importProgressEveryis now a package var. The test sets it per subtest and restores it with adefer. The case withevery=1handgap=0always drops the middle line. The case withevery=50msandgap=100msalways sends it, because the sleep happens before eachprogress(i, …)call. Each case asserts the line count, the first and last lines, and thatDonegrows. There is no data race: the write happens beforehttptestserves the request, the handler goroutine reads the var after that, and the package has not.Paralleltests.go test -race -count=20 -run TestImport_ProgressLinesBeforeTheReportpassed.
Still open (non-blocking, not reposted): The progress bar at cmd/agentop/cmd_import.go can still wrap on terminals narrower than the line, about 70 columns.
Checks run
go buildandgo vetpassed on./core/...,./cmd/agentop/...and./cmd/cortex/.... Only bob and claude implement the changedSourceinterface, and both are updated.go test -racepassed oncore/session/importer/...,core/sessionapi/...and everycmd/agentopsubpackage. Incmd/agentop,TestServiceInstall_RefusesABrokenConfigandTestReportSessionInterruptionfail in my sandbox, which has no systemd user bus. They fail the same way on main, so this PR does not cause them.- Version skew: a new client against an old proxy gets only the report line, which still decodes.
progressisomitemptyand the server's decoder doesn't reject unknown fields, so an old proxy ignores the field.
Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go (importer, sessionapi, agentop client/CLI/TUI), Docs
Agent/IDE config (.claude/.vscode): none
Commits: 3 commits, all signed-off: yes (DCO check passes)
CI status: 22 passed, 0 failed so far. Go CI and some other jobs were still running or queued when I posted.
Problem
agentop importshowed only a spinner. A large history takes 30 s or more, and the user cannot see how far the import is.impprefix on imported sessions was not clear.Changes
Progress bar
POST /v1/importaccepts"progress": true. The body is then NDJSON: progress lines{"progress":{"agent","done","total"}}, at most 4 a second, and then the report line.Source.Sessionsgets aprogress(done, total)function.importer.Options.Progresspasses it through.importing claude-code [█████████░░░░░░░░░░░] 45% 837/1851 sessions. Not on a terminal, it asks for no progress.Skip before the read
skipwith the newest file mtime before it reads the files. No line is newer than its file, so theSessionscontract ("a time not before Updated") still holds.skippedExpired. Before, the importer read it and dropped it without a count.Marker
(*)before its title, or before its id when TITLE does not fit. The search finds it with(*).Measurements
Dry run with
importer.Runon a copy of the archive and real~/.claude(2.8 GB, about 1,800 sessions). The versions ran one after the other:The remaining 13 s is the full parse of the sessions to import.
Tests
TestSessions_SkipBeforeTheRead(it fails on main),TestImport_ProgressLinesBeforeTheReport,TestClientImport_ProgressLines,TestProgressBar.go test -raceoncore/session/...,core/sessionapi/..., allcmd/agentopsubpackages, andscripts/dev/go-test-shards.sh -race cmd/agentop(1,098 tests) pass.go vetis clean on both modules.Bob source
progressparameter: once per task tree, and once at the end.TestSource_Progresscovers it.Assisted-By: Claude (Anthropic AI) noreply@anthropic.com
Deferred from review
core/session/importer/claude/claude.go:80: the early skip uses the file mtime. A transcript that is copied or restored with an mtime older than its newest line is skipped as current, and its new turns are not imported.cmd/agentop/cmd_import.go:170: the progress bar wraps on a narrow terminal (open review thread).