Skip to content

Conversation

@daaain
Copy link
Owner

@daaain daaain commented Jan 4, 2026

@cboos I went down a rabbit hole adding functionality around handling deleted sessions and projects (where the JSONL files are gone, but the SQLite cache still has the info) and it's working all right now, but I'm not sure if the added complexity is worth it, so instead of committing into #59 I thought I'd open a PR to separately look at and discuss.

Features:

  • Show fully archived projects (cached but no JSONL files) in TUI and HTML index
  • Projects with [ARCHIVED] badge in project selector and greyed-out styling in index
  • Archived projects automatically open in archived view mode
  • Delete sessions from cache via 'd' key with confirmation dialog
  • Restore JSONL now produces compact JSON format matching original files
  • Project list refreshes after restore to update archived status

Implementation:

  • Add get_all_cached_projects() to discover archived projects from cache.db
  • Add delete_session() and delete_project() methods to CacheManager
  • Update CLI to discover and track archived projects, refresh on return
  • Update SessionBrowser to handle is_archived_project flag
  • Add DeleteConfirmScreen modal for delete confirmation

Tests:

  • Add tests for compact JSON export, session/project deletion
  • Add tests for get_all_cached_projects with active/archived detection
  • Add TUI test for archived project loading in archived mode

This is how the CLI output looks like if you have deleted / archived sessions and projects (with a few work projects removed so the numbers don't add up):

(claude-code-log) ➜  claude-code-log git:(feat/sqlite-cache) ✗ j cli
uv run claude-code-log 
Processing all projects in /Users/dain/.claude/projects...
  -Users-dain: cached, 3 archived (0.0s)
  -Users-dain--claude: cached (0.0s)
  -Users-dain-Obsidian: cached, 1 archived (0.0s)
  -Users-dain-workspace-ai-sdk-provider-claude-code: cached (0.0s)
  -Users-dain-workspace-bigquery-emulator: cached (0.0s)
  -Users-dain-workspace-claude-code-log: 2 files updated (1.8s)
  -Users-dain-workspace-cook-anything: 4 files updated (0.7s)
  -Users-dain-Desktop: [ARCHIVED] (0 sessions)
  -Users-dain-truenas-backup: [ARCHIVED] (2 sessions)
  -Users-dain-workspace-JSSoundRecorder: [ARCHIVED] (3 sessions)
  -Users-dain-workspace-browser-llm-script-interaction-extension: [ARCHIVED] (87 sessions)
  -Users-dain-workspace-coderabbit-review-helper: [ARCHIVED] (2 sessions)
  -Users-dain-workspace-danieldemmel-me-next: [ARCHIVED] (6 sessions)
  -Users-dain-workspace-duolingo-profile-progress: [ARCHIVED] (10 sessions)
  -Users-dain-workspace-go-zetasql: [ARCHIVED] (1 sessions)
Processed 30 projects in 4.4s
  2 projects updated
  Index regenerated

Note: 93 archived session(s) found (cleanupPeriodDays: 99999).
  These sessions were cached before their JSONL files were deleted.
  To restore them or adjust cleanup settings, see:
  https://github.com/daaain/claude-code-log/blob/main/dev-docs/restoring-archived-sessions.md
Successfully processed 16 projects and created index at /Users/dain/.claude/projects/index.html

Features:
- Show fully archived projects (cached but no JSONL files) in TUI and HTML index
- Projects with [ARCHIVED] badge in project selector and greyed-out styling in index
- Archived projects automatically open in archived view mode
- Delete sessions from cache via 'd' key with confirmation dialog
- Restore JSONL now produces compact JSON format matching original files
- Project list refreshes after restore to update archived status

Implementation:
- Add get_all_cached_projects() to discover archived projects from cache.db
- Add delete_session() and delete_project() methods to CacheManager
- Update CLI to discover and track archived projects, refresh on return
- Update SessionBrowser to handle is_archived_project flag
- Add DeleteConfirmScreen modal for delete confirmation

Tests:
- Add tests for compact JSON export, session/project deletion
- Add tests for get_all_cached_projects with active/archived detection
- Add TUI test for archived project loading in archived mode
@coderabbitai
Copy link

coderabbitai bot commented Jan 4, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cboos
Copy link
Collaborator

cboos commented Jan 5, 2026

I like the idea of the TUI enabling you to manage your sessions. I tested it and here's my feedback.

Well, some of the feedback, as what I started to write was general feedback about the TUI.. So the unrelated part of the feedback is in #73, and here I focus on the archive/restore functionality.

So, I didn't immediately "get" it...

  • First, as you mentioned archived projects and sessions, I expected to see the 'a' also in the project list.
  • Then, after selecting a project and seeing the sessions, I could see the 'a' but that action didn't "do" anything, except to show "No archived sessions found", which puzzled me even more: "Of course, there's none yet; I'm about to archive the first one!"
  • Then, it clicked: the 'a' is about viewing the archived sessions (toggling pane), it's not for archiving a session!

I somehow expected to have 'a' to be the symmetrical to 'r'. The 'd' action can't be used for that either, as it will propose to delete the archive and keep the file.

Likewise, I expected the ability to archive ('a') a whole project, but I'm OK to let that happen by itself once all sessions are archived (as it is now).

So, what do you think about having 'A' (upper case, "dangerous", "think twice" connotation) do the archiving (i.e., deleting the session file)?

Also:

  • We show "No archived sessions found" when there's no archived session, but the reverse, when there are only archived session, then we toggle to the empty pane; I find the latter behavior clearer;
  • Restoring a session when the whole project was deleted fails (we don't mkdir);
  • Not sure 'd' works as intended: Screenshot from 2026-01-05 16-16-36 There's not confirmation key hinted at ('[Enter]' doesn't work, '[ESC]' does, to dismiss). Well, 'y' worked, but you have to guess ;-) Either aliasing '[ENTER]' to 'y', or adding a 'y'es / 'n'o would help!

In summary, and to answer your question: "I'm not sure if the added complexity is worth it". Definitely yes, if you can use claude-code-log --tui to manage your sessions (archive and delete).

@cboos cboos mentioned this pull request Jan 5, 2026
@daaain
Copy link
Owner Author

daaain commented Jan 9, 2026

Thanks a lot, this is great feedback! I'll improve the usability of the TUI. Will need to think how to incorporate these new functions into the TUI without crowding the bottom bar too much 🤔 but accepting Enter for actions and always showing what keys do what action makes perfect sense (might even add it to CLAUDE.md).

I guess then managing session logs should be the remit of this library, so maybe we can even expand this functionality to delete JSONL logs too!

@daaain
Copy link
Owner Author

daaain commented Jan 9, 2026

In the end I realised we could remove a lot of confusion by having a unified list, having a do the archiving, added d for deleting, and wired up Enter.

Here's Claude's summary:

Summary of Changes

  1. Unified Session List
  • Removed view_mode reactive property and action_toggle_view_mode() method
  • Both current and archived sessions now appear in a single list, sorted by timestamp (newest first)
  • Sessions are visually distinguished by [ARCHIVED] text prefix in the title column
  1. New Key Mappings
    Key: a
    Action: Archive Session
    Description: Deletes JSONL file, keeps session in cache (only for current
    sessions)
    ────────────────────────────────────────
    Key: d
    Action: Delete Session
    Description: Smart options: cache-only OR both cache+JSONL
    ────────────────────────────────────────
    Key: r
    Action: Restore JSONL
    Description: Restores archived session to JSONL file
    ────────────────────────────────────────
    Key: Enter
    Action: Confirm
    Description: Now works as alias for y in all confirmation dialogs
  2. Improved Confirmation Dialogs

Archive dialog (ArchiveConfirmScreen):

  • [Enter/y] Yes [Esc/n] No

Delete dialog (DeleteConfirmScreen):

  • For current sessions: [c] Cache only [b] Both (permanent) [Esc/n] Cancel
  • For archived sessions: [Enter/y/c] Delete from cache [Esc/n] Cancel
  1. Bug Fixes
  • Auto-create project directory on restore (fixes restore failure when directory was deleted)
  • Updated check_action() to enable/disable actions based on selected session type

Files Modified

  • claude_code_log/tui.py - Main TUI implementation
  • test/test_tui.py - Updated test for archived sessions

@daaain
Copy link
Owner Author

daaain commented Jan 10, 2026

Added all these actions (archive / restore / delete) to projects as well and wired up Enter and Esc more to do main action / back. I'm quite happy with this PR now so will merge it back into the main SQLite PR!

@daaain daaain merged commit 4a7ce7a into feat/sqlite-cache Jan 10, 2026
1 check passed
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.

3 participants