-
Notifications
You must be signed in to change notification settings - Fork 1
Add CLI + Web GUI for browsing Claude Code sessions #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e7ecff0
Add CLI + Web GUI for browsing Claude Code sessions
timon0305 59485d1
updated feedback from coderabbitai
timon0305 9b44027
updated another feedback from coderabbittai
timon0305 47e3ca6
UI/UX overhaul, tool result classification, and bug fixes
timon0305 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,57 @@ | ||
| """API endpoints for viewing individual sessions.""" | ||
| """Session detail and stats endpoints.""" | ||
|
|
||
| import os | ||
| import traceback | ||
|
|
||
| from flask import Blueprint, current_app, jsonify, abort | ||
|
|
||
| from utils.session_path import get_claude_projects_dir | ||
| from utils.session_path import get_claude_projects_dir, safe_join | ||
| from utils.jsonl_parser import parse_session | ||
| from utils.session_stats import compute_stats | ||
|
|
||
| sessions_bp = Blueprint("sessions", __name__) | ||
|
|
||
|
|
||
| @sessions_bp.route("/api/sessions/<path:project_name>/<session_id>") | ||
| def get_session(project_name, session_id): | ||
| base = current_app.config.get("CLAUDE_PROJECTS_DIR") or get_claude_projects_dir() | ||
| filepath = os.path.join(base, project_name, f"{session_id}.jsonl") | ||
| try: | ||
| filepath = safe_join(base, project_name, f"{session_id}.jsonl") | ||
| except ValueError: | ||
| return jsonify({"error": "Invalid path"}), 400 | ||
|
|
||
| if not os.path.isfile(filepath): | ||
| abort(404, description=f"Session {session_id} not found") | ||
| return jsonify({"error": f"Session {session_id} not found"}), 404 | ||
|
|
||
| session = parse_session(filepath) | ||
| return jsonify(session) | ||
| try: | ||
| session = parse_session(filepath) | ||
| return jsonify(session) | ||
| except Exception as e: | ||
| tb = traceback.format_exc() | ||
| print(f"[ERROR] Failed to parse session {session_id}: {e}\n{tb}") | ||
| return jsonify({ | ||
| "error": f"Failed to parse session: {type(e).__name__}: {e}", | ||
| }), 500 | ||
|
|
||
|
|
||
| @sessions_bp.route("/api/sessions/<path:project_name>/<session_id>/stats") | ||
| def get_session_stats(project_name, session_id): | ||
| base = current_app.config.get("CLAUDE_PROJECTS_DIR") or get_claude_projects_dir() | ||
| try: | ||
| filepath = safe_join(base, project_name, f"{session_id}.jsonl") | ||
| except ValueError: | ||
| return jsonify({"error": "Invalid path"}), 400 | ||
|
|
||
| if not os.path.isfile(filepath): | ||
| return jsonify({"error": f"Session {session_id} not found"}), 404 | ||
|
|
||
| try: | ||
| session = parse_session(filepath) | ||
| stats = compute_stats(session) | ||
| return jsonify(stats) | ||
| except Exception as e: | ||
| tb = traceback.format_exc() | ||
| print(f"[ERROR] Failed to compute stats for {session_id}: {e}\n{tb}") | ||
| return jsonify({ | ||
| "error": f"Failed to compute stats: {type(e).__name__}: {e}", | ||
| }), 500 |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.