Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ bun run docs
- `~/.config/ccstatusline/settings.json` - ccstatusline UI/render settings
- `~/.claude/settings.json` - Claude Code settings (`statusLine` command object)
- `~/.cache/ccstatusline/block-cache-*.json` - block timer cache (keyed by Claude config directory hash)
- `~/.cache/ccstatusline/compaction/compaction-*.json` - per-session compaction counter state

If you use a custom Claude config location, set `CLAUDE_CONFIG_DIR` and ccstatusline will read/write that path instead of `~/.claude`.

Expand Down
2 changes: 1 addition & 1 deletion docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bun run example
- **Tokens Input** / **Tokens Output** / **Tokens Cached** / **Tokens Total** - Show current-session token counts.
- **Input Speed** / **Output Speed** / **Total Speed** - Show session-average token throughput with an optional per-widget rolling window (`0-120` seconds; `0` = full-session average).
- **Context Length** / **Context Window** / **Context %** / **Context % (usable)** / **Context Bar** - Show current context length, total context window size, used/remaining percentage, usable-window percentage, or a progress bar.
- **Compaction Counter** - Show how many context compactions have been detected in the current session. It can render as icon plus number, text plus number, or number-only, and can hide while the count is zero.
- **Compaction Counter** - Show how many context compactions have occurred in the current session. It can render as icon plus number, text plus number, or number-only, and can hide while the count is zero.
- **Session Usage** / **Weekly Usage** / **Weekly Sonnet Usage** / **Weekly Opus Usage** / **Extra Usage Utilization** / **Extra Usage Remaining** / **Block Timer** / **Block Reset Timer** / **Weekly Reset Timer** - Show usage percentages, monthly pay-as-you-go overage usage, and current block/reset timing. The all-models weekly bar covers `seven_day` from the usage API; the per-model variants surface the `seven_day_sonnet` and `seven_day_opus` buckets that Claude Code's own `/usage` panel shows. Session and weekly usage bars can show a time cursor; reset timers can show remaining time, progress, or exact reset date/time with timezone and locale controls.

### Environment, Layout & Custom
Expand Down
26 changes: 4 additions & 22 deletions src/ccstatusline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@ import type { StatusJSON } from './types/StatusJSON';
import { StatusJSONSchema } from './types/StatusJSON';
import { getVisibleText } from './utils/ansi';
import { updateColorMap } from './utils/colors';
import {
detectCompaction,
loadCompactionState,
saveCompactionState
} from './utils/compaction';
import { getCompactionCount } from './utils/compaction';
import {
initConfigPath,
loadSettings,
saveSettings
} from './utils/config';
import { calculateContextPercentageMetrics } from './utils/context-percentage';
import { handleHookInput } from './utils/hook-handler';
import {
getSessionDuration,
Expand Down Expand Up @@ -145,24 +140,11 @@ async function renderMultipleLines(data: StatusJSON) {
skillsMetrics = getSkillsMetrics(data.session_id);
}

// Compaction detectiontrack context percentage drops between renders
// Compaction countcount compact_boundary markers in this session's transcript
let compactionCount = 0;
const hasCompactionWidget = lines.some(line => line.some(item => item.type === 'compaction-counter'));
if (hasCompactionWidget && data.session_id) {
const prevState = loadCompactionState(data.session_id);
compactionCount = prevState.count;
const contextPercentageMetrics = calculateContextPercentageMetrics({ data, tokenMetrics });
if (contextPercentageMetrics !== null) {
const newState = detectCompaction(contextPercentageMetrics.usedPercentage, prevState, { windowSize: contextPercentageMetrics.windowSize });
if (
newState.count !== prevState.count
|| newState.prevCtxPct !== prevState.prevCtxPct
|| newState.prevWindowSize !== prevState.prevWindowSize
) {
saveCompactionState(data.session_id, newState);
}
compactionCount = newState.count;
}
if (hasCompactionWidget && data.transcript_path) {
compactionCount = await getCompactionCount(data.transcript_path);
}

// Create render context
Expand Down
Loading