Repository navigation
feat: add shelltime cc backfill and shelltime codex backfill - #312
Merged
Merged
Conversation
- SendHTTPRequestJSON now returns a typed HTTPStatusError for non-2xx responses so callers can tell retryable errors from client errors. The error text is unchanged. - Wire types and senders for the server's /api/v1/cc/backfill endpoints. Backfill events use pointer fields so a failed tool call is sent as "success": false instead of being dropped by omitempty. - Shared helpers for the transcript parsers: stable "bf1:" event ids from natural keys, a JSONL reader without a line length cap, file discovery, session selection, and request packing that keeps whole sessions together and marks a session completed on its last batch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LMCwtubXzBYhQTnX44vhzF
Rebuild historical sessions from local transcripts as backfill events matching what the live OTEL pipeline records. Claude Code (~/.claude/projects, ~/.config/claude/projects or CLAUDE_CONFIG_DIR): one api_request per message id + request id, keeping the most complete usage of a streamed response; human prompts only (no meta, subagent, compaction, local-command or notification lines); tool results paired with their tool calls, keeping only file paths of the parameters. Items copied into resumed sessions are credited once, to the session that started first. Codex (~/.codex/sessions, archived_sessions or CODEX_HOME): conversation_starts, user prompts, response.completed token counts from last_token_usage or the cumulative delta (skipping null and repeated counts), and tool results with exit code and duration. Items copied into forked rollouts are dropped. Batches are also bounded by encoded size, and long prompts and tool arguments are capped, so a batch stays under the server's body limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LMCwtubXzBYhQTnX44vhzF
…fill` Upload past Claude Code and Codex usage from local transcripts that live OTEL tracking missed (before `cc install` or while the daemon was down). The command asks the server which sessions it already has, skips those tracked live, archived or already uploaded, and uploads the rest in batches with retries on server errors. Sessions still running are held back. When it finishes it asks the server to refresh activity data and caches for the uploaded range. Flags: --since/--until, --dry-run (per-day preview), --no-prompts and --ai-summary (opt-in, uses AI credits). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LMCwtubXzBYhQTnX44vhzF
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 108 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two commands that upload past Claude Code and Codex usage from the transcripts both tools keep on disk. They fill gaps live OTEL tracking missed: usage from before
cc install/codex install, or from while the daemon was down. Events are uploaded as the same kinds the live pipeline sends (user_prompt,api_request,tool_result, Codexsse_event/response.completed,conversation_starts), so dashboards, session summaries and MCP tools pick them up.Requires shelltime/server#494. Against an older server the command stops with "server does not support backfill yet".
How it works
~/.claude/projects,~/.config/claude/projects, or theCLAUDE_CONFIG_DIRlist.api_requestis deduplicated globally bymessage.id:requestId, keeping the most complete usage.file_path/pathfrom the parameters is kept; commands and file contents are never uploaded.~/.codex/sessions,archived_sessions, orCODEX_HOME.last_token_usage, or from the change in the cumulative total. Null and repeated counts are skipped.user_messageevents fall back to the conversation's own user messages./completeso the server refreshes the activity heatmap and caches for the uploaded range.Event ids are
bf1:plus a sha256 of a natural key (message/request id, prompt uuid, tool call id, and so on). They don't depend on the session, so re-runs and copied history are idempotent.Other changes
SendHTTPRequestJSONreturns a typedHTTPStatusError, so callers can tell retryable errors from fatal ones. The error text is unchanged.AICodeOtelEventhassuccess,omitemptyon abool, which drops failed tool calls; backfill sends"success": false.aiCodeResourceIdentity()is extracted, so backfilled events carry the sameuser.name/machine.name/team.idas live ones.Test plan
is_errorsent asfalse--no-prompts, prompt cap,CLAUDE_CONFIG_DIRlist, stable idshttptestserver:--ai-summaryis passed through;--dry-runonly checks statusgo vet ./...andgo test ./...pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01LMCwtubXzBYhQTnX44vhzF
Generated by Claude Code