Fix session time remaining display after Claude Code update - #23
Merged
Conversation
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>
There was a problem hiding this comment.
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
looksLikeResetLinehelper 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 |
- 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>
- 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>
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
marked this pull request as ready for review
January 24, 2026 15:30
Owner
Author
✅ Ready for MergeThis PR has been through 3 rounds of Copilot code review and all feedback has been addressed: Implemented fixes:
Dismissed suggestions (with justification):
Build verified with Since even Copilot is satisfied with Claude's work now, we proceed by merging this. 🤖🤝🤖 |
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
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 currentstripANSIfunction removes these sequences entirely, causing text concatenation issues where "Resets" becomes "Reses" or "Rese s", breaking reset time detection.Problem
Raw output:
After current ANSI stripping:
The
parseResetTimefunction looks for "reset" or "renew" keywords, but the garbled text doesn't match, so session reset times are not parsed.Solution
\x1B[nCand\x1B[Csequences (with or without digit)stripANSI- Replace cursor movements with spaces before stripping other ANSI codes, preserving word boundarieslooksLikeResetLinehelper - Detect both standard "reset"/"renew" keywords and garbled patterns (e.g., "rese s" followed by time indicators)Changes
main.go: AddedcursorForwardPatternregex andlooksLikeResetLinehelper functionVERSION: Bumped to 2.1.17-1flake.nix: Updated claude-code input to v2.1.17README.md: Updated compatibility table for 2.1.17-XTest plan
nix buildclaude-o-meter queryshows session quota withresets_at,time_remaining_seconds, andtime_remaining_human🤖 Generated with Claude Code