Skip to content

feat(tab): agent usage SFTP fallback for hosts without wsh - #39

Closed
Atreus-X wants to merge 5 commits into
feat/agent-usage-widgetfrom
feat/agent-usage-sftp
Closed

Atreus-X wants to merge 5 commits into
feat/agent-usage-widgetfrom
feat/agent-usage-sftp

Conversation

@Atreus-X

Copy link
Copy Markdown
Owner

Summary

Agent usage meter now works on remote hosts without wsh. AgentUsageCommand tries wsh first; if the connection has no wsh (or the wsh call fails) it reads the agent logs over the existing SFTP session and parses them locally. A per-file cache keyed by size and mtime means each poll only re-reads changed files.

Stacked on #38 (feat/agent-usage-widget). Merge #38 first, then this; retarget to main after #38 merges.

Routes

  • wsh: unchanged, RemoteAgentUsageCommand on the connection route.
  • plain SSH (SFTP): new sftpfs.AgentUsageSource; no wsh needed on the host.

Testing

  • go test ./pkg/agentusage/ (both routes' shared code via an in-memory FileSource: cache hit, changed file, deleted file, old/non-jsonl skipped; Codex parser)
  • go vet on agentusage, sftpfs, wshserver; npx vitest run; tsc with no new errors
  • Not exercised against a live SFTP host yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_01W6QMXXvRReaKxWk1JL5Et6

Atreus-X and others added 4 commits September 29, 2026 12:57
Remote agent-usage scanning tries wsh first and reads the logs over the
existing SFTP session otherwise, with a per-file cache keyed by size and mtime.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6QMXXvRReaKxWk1JL5Et6
The wsh attempt now times out after 8s and the meter's request after 90s, so a
dead wsh route no longer eats the whole budget (EC-TIME) before SFTP is tried.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6QMXXvRReaKxWk1JL5Et6
An empty agentusage:agent is dropped by omitempty on its way to the frontend,
so Off silently reverted to the Claude default.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6QMXXvRReaKxWk1JL5Et6
…atusline

Claude Code hands rate_limits (5h and 7d percent plus reset time) to the
statusline command, and nothing else records them. A statusline line saves
them to ~/.claude/rate-limits.json; the meter reads that file on the local
machine or over wsh/SFTP and prefers it to the log-based estimate. A window
past its reset falls back to the estimate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6QMXXvRReaKxWk1JL5Et6
@Atreus-X

Copy link
Copy Markdown
Owner Author

Also on this branch: exact Claude plan percentages and reset times.

  • Claude Code passes rate_limits (5h and 7d percent plus reset) to the statusline command. A one-line statusline addition saves it to ~/.claude/rate-limits.json.
  • The meter reads that file on the local machine, over wsh, or over SFTP, and shows the plan's numbers. A missing file or a window past its reset falls back to the log-based estimate.
  • The file only updates while a Claude Code session is running on that machine.
  • Both routes go through the same FileSource, so there is no wsh dependency. Covered by TestCollectFromPlanLimits.
  • Also fixes "Off" not sticking (explicit "off" value).

…sage

Claude plans only have a 5h and a 7d limit, so the daily token budget
setting and the "until reset" countdown to local midnight were misleading.
The Today row now shows plain token totals.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6QMXXvRReaKxWk1JL5Et6
@Atreus-X Atreus-X mentioned this pull request Sep 30, 2026
@Atreus-X

Copy link
Copy Markdown
Owner Author

Closing: every commit on this branch is already in main via the v0.17.0 release (#53).

@Atreus-X Atreus-X closed this Sep 30, 2026
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.

1 participant