Repository navigation
fix(cli): align sessions cleanup label summary by visible width - #117459
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 3:17 PM ET / 19:17 UTC. ClawSweeper reviewWhat this changesThis PR updates the Merge readinessNo blocking findings. Current Priority: P3 Review scores
Verification
How this fits togetherThe sessions cleanup CLI reads session-store preview rows, groups them by session label, and prints a dry-run summary for operators. This change affects only the text-table padding used before the kept/pruned counts are logged. flowchart LR
A[Session store preview] --> B[Cleanup action rows]
B --> C[Label summaries]
C --> D[Terminal width measurement]
D --> E[Aligned count padding]
E --> F[CLI dry-run output]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1, Tests +71. Total +72 across 2 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land this focused migration to the existing Do we have a high-confidence way to reproduce the issue? Yes, at source level: current Is this the best way to solve the issue? Yes. Reusing terminal-core’s existing ANSI-aware AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bf99e43ee7d3. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
e60c58a to
8cb02e5
Compare
|
Maintainer independently ran the same real SQLite session store -> production For precision, Focused owner regression: ClawSweeper rank-up addressed: native review refreshed current-main comparison and confirmed the existing shared terminal-width helper; the original contributor head is mergeable, so preserve the already-green original head without an unnecessary rebase. |
|
Merged via squash.
|
* commit '81e392b7ff43bcdb7a3be50a99adf65c3b0141b5': fix(channels): preserve filters in offline status diagnostics (#117570) perf(gateway): separate startup maintenance timing (#117577) refactor(tests): deduplicate database-first guard fixtures (#117594) fix(cli): align sessions cleanup label summary by visible width (#117459) perf(gateway): skip empty session reconciliation (#117589)
* commit '81e392b7ff43bcdb7a3be50a99adf65c3b0141b5': fix(channels): preserve filters in offline status diagnostics (#117570) perf(gateway): separate startup maintenance timing (#117577) refactor(tests): deduplicate database-first guard fixtures (#117594) fix(cli): align sessions cleanup label summary by visible width (#117459) perf(gateway): skip empty session reconciliation (#117589) refactor(ui): consolidate cron form control rendering (#117576) fix(memory): recover restored session freshness (#117548) fix(ui): preserve Talk transcript surrogate bounds fix(ui): harden Talk transcript marker bounds test(ui): cover bounded realtime Talk entries fix(ui): bound realtime Talk conversation text
* commit '81e392b7ff43bcdb7a3be50a99adf65c3b0141b5': fix(channels): preserve filters in offline status diagnostics (#117570) perf(gateway): separate startup maintenance timing (#117577) refactor(tests): deduplicate database-first guard fixtures (#117594) fix(cli): align sessions cleanup label summary by visible width (#117459) perf(gateway): skip empty session reconciliation (#117589)
* commit '58213dd5389737ff100c6286d110921defeb76e8': fix(channels): preserve filters in offline status diagnostics (openclaw#117570) perf(gateway): separate startup maintenance timing (openclaw#117577) refactor(tests): deduplicate database-first guard fixtures (openclaw#117594) fix(cli): align sessions cleanup label summary by visible width (openclaw#117459) perf(gateway): skip empty session reconciliation (openclaw#117589)
* origin/main: perf(gateway): separate startup maintenance timing (openclaw#117577) refactor(tests): deduplicate database-first guard fixtures (openclaw#117594) fix(cli): align sessions cleanup label summary by visible width (openclaw#117459) perf(gateway): skip empty session reconciliation (openclaw#117589)
* commit '58213dd5389737ff100c6286d110921defeb76e8': fix(channels): preserve filters in offline status diagnostics (openclaw#117570) perf(gateway): separate startup maintenance timing (openclaw#117577) refactor(tests): deduplicate database-first guard fixtures (openclaw#117594) fix(cli): align sessions cleanup label summary by visible width (openclaw#117459) perf(gateway): skip empty session reconciliation (openclaw#117589)
* commit '58213dd5389737ff100c6286d110921defeb76e8': fix(channels): preserve filters in offline status diagnostics (openclaw#117570) perf(gateway): separate startup maintenance timing (openclaw#117577) refactor(tests): deduplicate database-first guard fixtures (openclaw#117594) fix(cli): align sessions cleanup label summary by visible width (openclaw#117459) perf(gateway): skip empty session reconciliation (openclaw#117589) refactor(ui): consolidate cron form control rendering (openclaw#117576) fix(memory): recover restored session freshness (openclaw#117548) fix(ui): preserve Talk transcript surrogate bounds fix(ui): harden Talk transcript marker bounds test(ui): cover bounded realtime Talk entries fix(ui): bound realtime Talk conversation text
Summary
Fix the
sessions cleanupdry-run "Summary by Label" table so labels containing emoji or CJK characters no longer shift the kept/pruned counts column out of alignment.What Problem This Solves
Session labels are user-controlled via
/name, and users routinely put emoji or CJK text in them. The dry-run summary groups sessions by label and aligns the counts column by padding each label to the widest label:src/commands/sessions-cleanup.ts:132, the column width was computed withsummary.label.length— the UTF-16 code-unit count, not the terminal cell width.src/commands/sessions-cleanup.ts:139,label.padEnd(labelPad)padded by code units for the same reason.A label like
🔥修复occupies 6 terminal cells (wide emoji + 2 wide CJK) but only 5 UTF-16 code units, so the padding math disagrees with what the terminal renders and thekept, prunedcounts no longer line up across rows. Any user runningopenclaw sessions cleanup --dry-runwith emoji/CJK session names sees a crooked summary table.Code evidence: in
src/commands/sessions-cleanup.ts:132,139, the width and padding were based on.length/padEnd, which count UTF-16 code units instead of visible terminal columns.Root Cause
a89e6e05efa("fix(cli): summarize cleanup dry-run by label", fix(cli): summarize cleanup dry-run by label #93565, 2026-06-16), which added the label summary table.string.lengthequals the number of terminal cells a string occupies. That holds only for narrow ASCII; wide emoji, CJK, and combining characters break it./name 🔥修复next to/name plain).Why This Fix
visibleWidth(packages/terminal-core/src/ansi.ts), which measures terminal cell width (ANSI-aware, wide-grapheme-aware).visibleWidthand pad with" ".repeat(labelPad - visibleWidth(label))— the same idiom already used bysrc/cli/cron-cli/shared.tsandsrc/commands/models/list.format.ts.padEndand special-case wide characters — duplicatesvisibleWidthlogic inline and drifts from the shared implementation.User Impact
openclaw sessions cleanup(dry-run and applied runs that print the "Summary by Label" table) when session labels contain emoji or CJK text.Evidence
main, seeding a real session store with/name 🔥修复and/name plainand running the dry-run cleanup prints the counts at visible columns 9 and 7 — misaligned (FAIL).Real Behavior Proof
Before (on main)
After (with fix)
$ node --import tsx proof.mjs === sessions cleanup --dry-run label summary === 🔥修复 1 kept, 0 pruned plain 1 kept, 0 pruned counts column visible offsets: 8, 8 PASS: counts column is aligned for emoji/CJK and ASCII labelsProof setup: a real sqlite session store was seeded through the repository's own
upsertSessionEntryAPI with two sessions labeled🔥修复andplain, then the realsessionsCleanupCommand({ dryRun: true, store })code path printed the summary above.Tests and Validation
src/commands/sessions-cleanup.test.ts("aligns the label summary columns for emoji and CJK labels") that asserts the counts column starts at the same visible offset for🔥修复andplainlabels.pnpm vitest run src/commands/sessions-cleanup.test.ts— 9/9 tests passed.pnpm checkpassed.padEndsites in this file (Action/Key/Age/Modelcolumns) pad fixed ASCII enums, literals, or truncated ASCII-safe cells, so they are not affected.