#16831: feat(status): group cron sessions for readability
commands
size: M
Cluster:
Cron Job Enhancements
## Summary
Implements #16799 — Improve `openclaw status` UX for cron-heavy setups.
## Changes
- Adds `sessionType` classification (`main`/`cronJob`/`cronRun`/`other`) to session entries
- Adds grouped session buckets to `StatusSummary.sessions.grouped`:
- **Active**: Primary interactive sessions
- **Cron Jobs**: Cron job definitions
- **Recent Runs**: Individual cron execution history (collapsed when > 20)
- **Other**: Everything else
- Basic unit tests for session type classification
## Future Work (out of scope for this PR)
- Wire grouped output into the human-readable `openclaw status` printer
- Add snapshot/regression tests for status output
- Align token % with model contextWindow (tracked in #15726)
## Related
- Issue: #16799
- Related: #12899, #13900, #15726, #10936, #12578, #9455, #13601
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds session type classification and grouping infrastructure to improve `openclaw status` UX for cron-heavy setups. Sessions are now categorized as `main` (interactive), `cronJob` (definitions), `cronRun` (execution history), or `other`, with grouped output buckets that collapse when cron runs exceed 20 entries. The implementation correctly uses canonical session-key utilities (`isCronJobSessionKey`, `isCronRunSessionKey`) for cron detection, addressing previous review feedback about regex consistency. Tests properly import the actual classification functions rather than duplicating logic.
- Added `sessionType` field to `SessionStatus` with four classification types
- Added `SessionGroups` structure with Active/Cron Jobs/Recent Runs/Other buckets
- Implemented `classifySessionType()` that delegates to canonical helpers for cron detection
- Implemented `groupSessions()` with automatic collapsing when cron runs > 20
- Added `isCronJobSessionKey()` helper alongside existing `isCronRunSessionKey()` in session-key-utils
- Enhanced `isCronRunSessionKey()` implementation from regex to explicit part validation
- Comprehensive unit tests for classification and grouping logic
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The implementation is well-structured with proper separation of concerns, comprehensive test coverage, and addresses previous review feedback. The code uses canonical session-key utilities correctly, includes clear documentation, and follows TypeScript best practices. All changes are additive (new fields are optional), ensuring backward compatibility. The test suite validates both classification logic and grouping behavior including edge cases.
- No files require special attention
<sub>Last reviewed commit: 0d47412</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#16511: feat(cron): support custom session IDs and auto-bind to current ses...
by kkhomej33-netizen · 2026-02-14
77.5%
#23562: feat: add sessionFreshness config for isolated cron jobs (#23539)
by MunemHashmi · 2026-02-22
76.6%
#18179: CLI: add sessions --json-debug diagnostics
by p6l-richard · 2026-02-16
75.9%
#22764: docs: comprehensive cron system study for portability reference
by Ahsd-digital · 2026-02-21
75.5%
#17530: refactor(sessions): centralize session status field extraction
by Facens · 2026-02-15
75.1%
#20188: fix: Update sessionFile path when rolling to new session in cron jobs
by jriff · 2026-02-18
74.5%
#15294: fix(cron): reset token counters when creating new isolated session
by Elarwei001 · 2026-02-13
74.3%
#6315: fix(cron): persist isolated sessions (fixes #6217) - attempt 2
by ChaitanyaSai-Meka · 2026-02-01
74.1%
#23501: fix(cron): force new session ID for isolated cron jobs (#23470)
by stakeswky · 2026-02-22
72.8%
#18743: Cron Tool Hardening: Normalize Gateway Params and Enforce Valid Sch...
by cccat6 · 2026-02-17
72.6%