Skip to content

Fix session time remaining display after Claude Code update - #23

Merged
MartinLoeper merged 5 commits into
mainfrom
fix-session-time-remaining
Jan 24, 2026
Merged

Fix session time remaining display after Claude Code update#23
MartinLoeper merged 5 commits into
mainfrom
fix-session-time-remaining

Conversation

@MartinLoeper

@MartinLoeper MartinLoeper commented Jan 24, 2026

Copy link
Copy Markdown
Owner

Summary

Fix session reset time parsing for Claude CLI v2.1.17+

Claude CLI v2.1.17 uses cursor movement ANSI escape sequences (\x1B[nC) to render text with visual spacing. The current stripANSI function removes these sequences entirely, causing text concatenation issues where "Resets" becomes "Reses" or "Rese s", breaking reset time detection.

Problem

Raw output:

Rese[1Cs[1C3:59pm (Europe/Berlin)

After current ANSI stripping:

Reses3:59pm (Europe/Berlin)

The parseResetTime function looks for "reset" or "renew" keywords, but the garbled text doesn't match, so session reset times are not parsed.

Solution

  1. Add cursor forward pattern - New regex to match \x1B[nC and \x1B[C sequences (with or without digit)
  2. Modify stripANSI - Replace cursor movements with spaces before stripping other ANSI codes, preserving word boundaries
  3. Add looksLikeResetLine helper - Detect both standard "reset"/"renew" keywords and garbled patterns (e.g., "rese s" followed by time indicators)

Changes

  • main.go: Added cursorForwardPattern regex and looksLikeResetLine helper function
  • VERSION: Bumped to 2.1.17-1
  • flake.nix: Updated claude-code input to v2.1.17
  • README.md: Updated compatibility table for 2.1.17-X

Test plan

  • Build succeeds with nix build
  • claude-o-meter query shows session quota with resets_at, time_remaining_seconds, and time_remaining_human
  • Weekly quota reset times still parse correctly
  • HyprPanel output shows session time remaining (e.g., "17m left")

🤖 Generated with Claude Code

MartinLoeper and others added 2 commits January 24, 2026 15:13
Claude CLI v2.1.17 uses cursor movement ANSI sequences (\x1B[nC] to render
text with visual spacing. This causes "Resets" to appear as "Rese s" after
ANSI stripping, breaking reset time detection.

Changes:
- Add cursorForwardPattern regex to match cursor forward sequences
- Modify stripANSI to replace cursor movements with spaces before stripping
- Add looksLikeResetLine helper to detect garbled reset patterns
- Bump VERSION to 2.1.11-4
- Update flake.nix claude-code input to v2.1.17
- Update README compatibility table for 2.1.11-2.1.17

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

This PR fixes session time remaining display after updating to Claude CLI v2.1.17, which introduced cursor movement ANSI sequences that broke the existing parser. The fix adds special handling for cursor forward sequences to preserve word boundaries before stripping ANSI codes, and adds a heuristic to detect garbled reset time text.

Changes:

  • Added cursor forward ANSI sequence handling to preserve spacing in Claude CLI v2.1.17+ output
  • Introduced looksLikeResetLine helper function to detect garbled reset time patterns
  • Updated Claude Code dependency to v2.1.17 and expanded compatibility range

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
main.go Adds cursor forward pattern handling in stripANSI, introduces looksLikeResetLine function for garbled text detection, updates parseResetTime to use new helper
flake.nix Updates claude-code dependency reference from v2.1.11 to v2.1.17
VERSION Bumps revision from 2.1.11-3 to 2.1.11-4
README.md Expands compatibility table to show 2.1.11-X supports Claude Code 2.1.11-2.1.17

Comment thread main.go Outdated
Comment thread VERSION Outdated
Comment thread main.go
Comment thread flake.nix
- Fix cursor forward handling: n=0 returns empty string, increase limit to 100
- Bump VERSION to 2.1.17-1 to match flake.nix claude-code version
- Add lowercase documentation comment to looksLikeResetLine function
- Update README compatibility table for 2.1.17-X

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

Comment thread VERSION
Comment thread main.go Outdated
Comment thread main.go Outdated
Comment thread main.go Outdated
Comment thread main.go Outdated
- Handle \x1B[C (no digit) as cursor forward 1 per ANSI standard
- Remove redundant 'if n > 0' check after n == 0 early return
- Clarify comment about cursor movements affecting any character position

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Comment thread main.go
Keep separate rows for 2.1.11-X and 2.1.17-X versions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MartinLoeper
MartinLoeper marked this pull request as ready for review January 24, 2026 15:30
@MartinLoeper

Copy link
Copy Markdown
Owner Author

✅ Ready for Merge

This PR has been through 3 rounds of Copilot code review and all feedback has been addressed:

Implemented fixes:

  • Handle \x1B[C (no digit) as cursor forward 1 per ANSI standard (9ba9d4c)
  • Remove redundant if n > 0 check after early return (9ba9d4c)
  • Fix n=0 returning empty string, increase limit to 100 (ddbc62e)
  • Bump VERSION to 2.1.17-1 to match flake.nix (ddbc62e)
  • Add lowercase documentation comment to looksLikeResetLine (ddbc62e)
  • Clarify comment about cursor movements affecting any char position (9ba9d4c)

Dismissed suggestions (with justification):

  • Flake pinning to commit hash - flake.lock already pins exact commit, tag improves readability
  • Stricter regex for "rese" pattern - false positives unlikely within quota section context

Build verified with nix build

Since even Copilot is satisfied with Claude's work now, we proceed by merging this. 🤖🤝🤖

@MartinLoeper
MartinLoeper merged commit 7580a5d into main Jan 24, 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.

2 participants