feat: Add rage-quit CLI command to display terminal inactivity signatures#355
Hidden character warning
feat: Add rage-quit CLI command to display terminal inactivity signatures#355PrathamReddy888 wants to merge 6 commits into
Conversation
Added a new command 'rage-quit' to analyze terminal session endings.
Adds a function to format rage-quit signatures for CLI display, including emojis based on command types.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Tip 👋 Hey @PrathamReddy888 — Miku's on it. Here are the most useful commands for this PR:
Note 🎓 This repo is part of ECSOC26. Run Note ⭐ Star this repo to unlock all commands. Say 📖 All commands🤖 AI-powered — 14 commands
🔧 Issue & PR management — 18 commands
🎉 Community & utility — 9 commands
|
📝 WalkthroughWalkthroughAdds rage-quit signature formatting and Typer command handlers that analyze non-legacy sessions, calculate signatures, and print formatted results. The CLI module also contains duplicate ChangesRage-quit signatures
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant Database
participant SignatureCalculator
participant Formatter
participant Console
CLI->>Database: Retrieve sessions
CLI->>CLI: Filter legacy sessions
CLI->>SignatureCalculator: Calculate signatures and total events
CLI->>Formatter: Format signature results
CLI->>Console: Print formatted output
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
:miku /ecsoc |
|
miku 🏷️ Added |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@termstory/formatter.py`:
- Around line 211-213: Remove the duplicate format_rage_quit_signatures
definition so the canonical two-argument API remains available to
termstory/insights.py. Update or rename the legacy implementation and all of its
callers consistently, preserving the expected formatting behavior without
allowing the later definition to shadow the two-argument function.
- Around line 264-266: Update the rage-quit report formatting around the command
output so command text cannot be interpreted as Rich markup. Escape command
before interpolating it into the output line, or ensure the corresponding print
operation disables markup while preserving the existing report formatting.
In `@termstory/insights.py`:
- Around line 671-675: Update the flow around calculate_rage_quit_signatures so
it also evaluates the final session’s end time against the current time, adding
the ongoing 12+ hour inactivity gap to the result before
format_rage_quit_signatures runs. Preserve the existing adjacent-session
calculations and output structure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8cb43ba5-0f3b-4aa3-84fd-99ceb377029b
📒 Files selected for processing (3)
termstory/cli.pytermstory/formatter.pytermstory/insights.py
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Greptile Review
⚠️ CI failures not shown inline (10)
GitHub Actions: CI / Test (Python 3.10): feat: Add rage-quit CLI command to display terminal inactivity signatures
Conclusion: failure
##[group]Run python -m pytest tests/ \
�[36;1mpython -m pytest tests/ \�[0m
�[36;1m --tb=short \�[0m
�[36;1m -q \�[0m
�[36;1m --ignore=tests/stress \�[0m
�[36;1m --ignore=tests/poc_debounced.py \�[0m
�[36;1m -x \�[0m
�[36;1m --timeout=60�[0m
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.10.20/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.10.20/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.20/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.20/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.20/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.20/x64/lib
##[endgroup]
==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_expert_resize.py _________________
tests/test_expert_resize.py:3: in <module>
from termstory.tui import TermStoryWorkspace
termstory/tui.py:54: in <module>
from termstory.insights import calculate_focus_score, calculate_time_of_day_distribution, assign_daily_rpg_class
termstory/insights.py:650: in <module>
`@app.command`("rage-quit")
E NameError: name 'app' is not defined
=========================== short test summary info ============================
ERROR tests/test_expert_resize.py - NameError: name 'app' is not defined
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 error in 0.76s
##[error]Process completed with exit code 1.
GitHub Actions: CI / 0_Test (Python 3.10).txt: feat: Add rage-quit CLI command to display terminal inactivity signatures
Conclusion: failure
##[group]Run python -m pytest tests/ \
�[36;1mpython -m pytest tests/ \�[0m
�[36;1m --tb=short \�[0m
�[36;1m -q \�[0m
�[36;1m --ignore=tests/stress \�[0m
�[36;1m --ignore=tests/poc_debounced.py \�[0m
�[36;1m -x \�[0m
�[36;1m --timeout=60�[0m
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.10.20/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.10.20/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.20/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.20/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.20/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.20/x64/lib
##[endgroup]
==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_expert_resize.py _________________
tests/test_expert_resize.py:3: in <module>
from termstory.tui import TermStoryWorkspace
termstory/tui.py:54: in <module>
from termstory.insights import calculate_focus_score, calculate_time_of_day_distribution, assign_daily_rpg_class
termstory/insights.py:650: in <module>
`@app.command`("rage-quit")
E NameError: name 'app' is not defined
=========================== short test summary info ============================
ERROR tests/test_expert_resize.py - NameError: name 'app' is not defined
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 error in 0.76s
##[error]Process completed with exit code 1.
GitHub Actions: CI / Test (Python 3.11): feat: Add rage-quit CLI command to display terminal inactivity signatures
Conclusion: failure
##[group]Run python -m pytest tests/ \
�[36;1mpython -m pytest tests/ \�[0m
�[36;1m --tb=short \�[0m
�[36;1m -q \�[0m
�[36;1m --ignore=tests/stress \�[0m
�[36;1m --ignore=tests/poc_debounced.py \�[0m
�[36;1m -x \�[0m
�[36;1m --timeout=60�[0m
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.11.15/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib
##[endgroup]
==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_expert_resize.py _________________
tests/test_expert_resize.py:3: in <module>
from termstory.tui import TermStoryWorkspace
termstory/tui.py:54: in <module>
from termstory.insights import calculate_focus_score, calculate_time_of_day_distribution, assign_daily_rpg_class
termstory/insights.py:650: in <module>
`@app.command`("rage-quit")
^^^
E NameError: name 'app' is not defined
=========================== short test summary info ============================
ERROR tests/test_expert_resize.py - NameError: name 'app' is not defined
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 error in 0.74s
##[error]Process completed with exit code 1.
GitHub Actions: CI / Test (Python 3.9): feat: Add rage-quit CLI command to display terminal inactivity signatures
Conclusion: failure
##[group]Run python -m pytest tests/ \
�[36;1mpython -m pytest tests/ \�[0m
�[36;1m --tb=short \�[0m
�[36;1m -q \�[0m
�[36;1m --ignore=tests/stress \�[0m
�[36;1m --ignore=tests/poc_debounced.py \�[0m
�[36;1m -x \�[0m
�[36;1m --timeout=60�[0m
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.9.25/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.25/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.25/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.25/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.25/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.25/x64/lib
##[endgroup]
==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_expert_resize.py _________________
tests/test_expert_resize.py:3: in <module>
from termstory.tui import TermStoryWorkspace
termstory/tui.py:54: in <module>
from termstory.insights import calculate_focus_score, calculate_time_of_day_distribution, assign_daily_rpg_class
termstory/insights.py:650: in <module>
`@app.command`("rage-quit")
E NameError: name 'app' is not defined
=========================== short test summary info ============================
ERROR tests/test_expert_resize.py - NameError: name 'app' is not defined
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 error in 0.72s
##[error]Process completed with exit code 1.
GitHub Actions: CI / 1_Test (Python 3.11).txt: feat: Add rage-quit CLI command to display terminal inactivity signatures
Conclusion: failure
##[group]Run python -m pytest tests/ \
�[36;1mpython -m pytest tests/ \�[0m
�[36;1m --tb=short \�[0m
�[36;1m -q \�[0m
�[36;1m --ignore=tests/stress \�[0m
�[36;1m --ignore=tests/poc_debounced.py \�[0m
�[36;1m -x \�[0m
�[36;1m --timeout=60�[0m
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.11.15/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib
##[endgroup]
==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_expert_resize.py _________________
tests/test_expert_resize.py:3: in <module>
from termstory.tui import TermStoryWorkspace
termstory/tui.py:54: in <module>
from termstory.insights import calculate_focus_score, calculate_time_of_day_distribution, assign_daily_rpg_class
termstory/insights.py:650: in <module>
`@app.command`("rage-quit")
^^^
E NameError: name 'app' is not defined
=========================== short test summary info ============================
ERROR tests/test_expert_resize.py - NameError: name 'app' is not defined
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 error in 0.74s
##[error]Process completed with exit code 1.
GitHub Actions: CI / Test (Python 3.12): feat: Add rage-quit CLI command to display terminal inactivity signatures
Conclusion: failure
##[group]Run python -m pytest tests/ \
�[36;1mpython -m pytest tests/ \�[0m
�[36;1m --tb=short \�[0m
�[36;1m -q \�[0m
�[36;1m --ignore=tests/stress \�[0m
�[36;1m --ignore=tests/poc_debounced.py \�[0m
�[36;1m -x \�[0m
�[36;1m --timeout=60�[0m
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.12.13/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.13/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.13/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.13/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.13/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.13/x64/lib
##[endgroup]
==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_expert_resize.py _________________
tests/test_expert_resize.py:3: in <module>
from termstory.tui import TermStoryWorkspace
termstory/tui.py:54: in <module>
from termstory.insights import calculate_focus_score, calculate_time_of_day_distribution, assign_daily_rpg_class
termstory/insights.py:650: in <module>
`@app.command`("rage-quit")
^^^
E NameError: name 'app' is not defined
=========================== short test summary info ============================
ERROR tests/test_expert_resize.py - NameError: name 'app' is not defined
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 error in 0.78s
##[error]Process completed with exit code 1.
GitHub Actions: CI / 2_Test (Python 3.12).txt: feat: Add rage-quit CLI command to display terminal inactivity signatures
Conclusion: failure
##[group]Run python -m pytest tests/ \
�[36;1mpython -m pytest tests/ \�[0m
�[36;1m --tb=short \�[0m
�[36;1m -q \�[0m
�[36;1m --ignore=tests/stress \�[0m
�[36;1m --ignore=tests/poc_debounced.py \�[0m
�[36;1m -x \�[0m
�[36;1m --timeout=60�[0m
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.12.13/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.13/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.13/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.13/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.13/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.13/x64/lib
##[endgroup]
==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_expert_resize.py _________________
tests/test_expert_resize.py:3: in <module>
from termstory.tui import TermStoryWorkspace
termstory/tui.py:54: in <module>
from termstory.insights import calculate_focus_score, calculate_time_of_day_distribution, assign_daily_rpg_class
termstory/insights.py:650: in <module>
`@app.command`("rage-quit")
^^^
E NameError: name 'app' is not defined
=========================== short test summary info ============================
ERROR tests/test_expert_resize.py - NameError: name 'app' is not defined
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 error in 0.78s
##[error]Process completed with exit code 1.
GitHub Actions: CI / 3_Test (Python 3.9).txt: feat: Add rage-quit CLI command to display terminal inactivity signatures
Conclusion: failure
##[group]Run python -m pytest tests/ \
�[36;1mpython -m pytest tests/ \�[0m
�[36;1m --tb=short \�[0m
�[36;1m -q \�[0m
�[36;1m --ignore=tests/stress \�[0m
�[36;1m --ignore=tests/poc_debounced.py \�[0m
�[36;1m -x \�[0m
�[36;1m --timeout=60�[0m
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.9.25/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.25/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.25/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.25/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.25/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.25/x64/lib
##[endgroup]
==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_expert_resize.py _________________
tests/test_expert_resize.py:3: in <module>
from termstory.tui import TermStoryWorkspace
termstory/tui.py:54: in <module>
from termstory.insights import calculate_focus_score, calculate_time_of_day_distribution, assign_daily_rpg_class
termstory/insights.py:650: in <module>
`@app.command`("rage-quit")
E NameError: name 'app' is not defined
=========================== short test summary info ============================
ERROR tests/test_expert_resize.py - NameError: name 'app' is not defined
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 error in 0.72s
##[error]Process completed with exit code 1.
GitHub Actions: CI / Lint: feat: Add rage-quit CLI command to display terminal inactivity signatures
Conclusion: failure
##[group]Run ruff check termstory/ --output-format=github || true
�[36;1mruff check termstory/ --output-format=github || true�[0m
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.11.15/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib
##[endgroup]
##[error]termstory/ai.py:1:1: I001 Import block is un-sorted or un-formatted
GitHub Actions: CI / 4_Lint.txt: feat: Add rage-quit CLI command to display terminal inactivity signatures
Conclusion: failure
##[group]Run ruff check termstory/ --output-format=github || true
�[36;1mruff check termstory/ --output-format=github || true�[0m
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.11.15/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib
##[endgroup]
##[error]termstory/ai.py:1:1: I001 Import block is un-sorted or un-formatted
🧰 Additional context used
📓 Path-based instructions (1)
termstory/*.py
📄 CodeRabbit inference engine (termstory/AGENTS.md)
Follow the existing project structure and naming conventions when adding features.
Files:
termstory/cli.pytermstory/insights.pytermstory/formatter.py
🪛 GitHub Actions: CI / 0_Test (Python 3.10).txt
termstory/insights.py
[error] 650-650: Pytest import failed with NameError: name 'app' is not defined at decorator @app.command("rage-quit").
🪛 GitHub Actions: CI / 1_Test (Python 3.11).txt
termstory/insights.py
[error] 650-650: Pytest collection failed with NameError: name 'app' is not defined. Error occurs at decorator '@app.command("rage-quit")'.
🪛 GitHub Actions: CI / 2_Test (Python 3.12).txt
termstory/insights.py
[error] 650-650: Pytest failed due to import-time exception. NameError: name 'app' is not defined at decorator '@app.command("rage-quit")'.
🪛 GitHub Actions: CI / 3_Test (Python 3.9).txt
termstory/insights.py
[error] 650-650: Test collection failed: NameError in decorator @app.command("rage-quit"). 'app' is not defined.
🪛 GitHub Actions: CI / Test (Python 3.10)
termstory/insights.py
[error] 650-650: Pytest collection failed with NameError: name 'app' is not defined at decorator @app.command("rage-quit").
🪛 GitHub Actions: CI / Test (Python 3.11)
termstory/insights.py
[error] 650-650: Pytest collection failed with NameError: name 'app' is not defined. Error occurs at decorator @app.command("rage-quit").
🪛 GitHub Actions: CI / Test (Python 3.12)
termstory/insights.py
[error] 650-650: Pytest collection failed with NameError: name 'app' is not defined at decorator @app.command("rage-quit").
🪛 GitHub Actions: CI / Test (Python 3.9)
termstory/insights.py
[error] 650-650: pytest collection failed with NameError: name 'app' is not defined. Error occurred at decorator @app.command("rage-quit") in termstory/insights.py.
🔇 Additional comments (2)
termstory/cli.py (1)
384-384: LGTM!termstory/insights.py (1)
657-664: 🩺 Stability & AvailabilityVerify that the shared database bootstrap runs for this command.
Unlike the existing
termstory/cli.pyflow, this handler does not callsafe_init_db(db)orrun_ingestion(db)before querying sessions. If no app-level callback supplies those steps, first-run execution can fail on an uninitialized schema and normal runs can omit newly ingested data. Confirm the shared bootstrap or add it here.
|
| Filename | Overview |
|---|---|
| termstory/cli.py | Adds a duplicate @app.command('rage-quit') handler (rage_quit) that conflicts with the existing show_rage_quit registered at line 1627; the new handler also skips safe_init_db/run_ingestion, uses an unused ctx parameter, and redundantly re-imports symbols already available at module level. |
| termstory/formatter.py | Inserts a second definition of format_rage_quit_signatures with a different signature (signatures, total_events) 1761 lines before the original (rage_quit_info) definition; Python's last-definition-wins rule means the new function is entirely dead code, and any call with the new two-argument signature will raise TypeError against the winning definition. |
| termstory/insights.py | Only removes a blank line between two functions — no functional change in this commit. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[termstory rage-quit] --> B{Typer command lookup}
B --> C[rage_quit at cli.py:1564 - registered first]
B --> D[show_rage_quit at cli.py:1627 - registered last wins]
D --> E[safe_init_db + run_ingestion]
E --> F[analyze_all db]
F --> G[format_rage_quit_signatures with rage_quit_info dict]
G --> H[formatter.py:1972 - original definition wins via last-def rule]
H --> I[Output rendered correctly]
C -.->|Dead code - overwritten by D| X[format_rage_quit_signatures with signatures + total_events]
X -.-> Y[formatter.py:211 - new definition shadowed by :1972]
style C fill:#FFB6C6
style X fill:#FFB6C6
style Y fill:#FFB6C6
style D fill:#90EE90
style H fill:#90EE90
style I fill:#90EE90
Reviews (4): Last reviewed commit: "Update termstory/cli.py" | Re-trigger Greptile
Removed the 'rage-quit' command and its associated logic from insights.py.
Adds a new command 'rage-quit' to analyze terminal session patterns.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
termstory/cli.py (1)
1564-1565: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueConsolidate the duplicate
rage-quitcommand handlers. The latershow_rage_quitregistration is the active command; the earlierrage_quithandler is shadowed and should be removed or folded into a helper. Keep thesafe_init_db/run_ingestionflow in the command path.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@termstory/cli.py` around lines 1564 - 1565, Remove or fold the shadowed earlier rage_quit handler into a helper, leaving the later show_rage_quit registration as the sole active rage-quit command. Preserve the safe_init_db and run_ingestion flow in the retained command path.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@termstory/cli.py`:
- Around line 1584-1590: Update the rage-quit handler to pass the full result
object to format_rage_quit_signatures and print the returned ANSI string via
Text.from_ansi(...). Remove the duplicate app.command("rage-quit") handler so
only one registration remains.
---
Nitpick comments:
In `@termstory/cli.py`:
- Around line 1564-1565: Remove or fold the shadowed earlier rage_quit handler
into a helper, leaving the later show_rage_quit registration as the sole active
rage-quit command. Preserve the safe_init_db and run_ingestion flow in the
retained command path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f2a9ae23-9445-49a8-a445-23f12817ed92
📒 Files selected for processing (1)
termstory/cli.py
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
- GitHub Check: Greptile Review
- GitHub Check: Test (Python 3.9)
- GitHub Check: Test (Python 3.12)
- GitHub Check: Test (Python 3.11)
- GitHub Check: Test (Python 3.10)
🧰 Additional context used
📓 Path-based instructions (1)
termstory/*.py
📄 CodeRabbit inference engine (termstory/AGENTS.md)
Follow the existing project structure and naming conventions when adding features.
Files:
termstory/cli.py
|
@bitflicker64 Please review and merge |
|
@bitflicker64 Please review and merge soon. |
|
@greptile review |
|
✅ Action performedReview finished.
|
|
/rewrite |
|
miku ✅ PR description rewritten! Check the PR body above. PreviewSummaryThis PR attempts to add a new Changes
Architecture / Flowflowchart LR
A[CLI: rage-quit command] --> B{Which handler?}
B --> C[Existing: show_rage_quit at cli.py:1600]
B --> D[New: rage_quit at cli.py:1564]
C --> E[analyze_all db]
D --> F[calculate_rage_quit_signatures sessions]
E --> G[format_rage_quit_signatures rage_quit_info]
F --> H[format_rage_quit_signatures signatures total_events]
G --> I[Output]
H --> J[Output]
style C fill:#90EE90
style D fill:#FFB6C6
style G fill:#90EE90
style H fill:#FFB6C6
Fixes
Breaking Changes
Testing# This will fail due to duplicate command registration
termstory rage-quitNotesThe |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
termstory/cli.py (1)
1576-1584: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winInitialize and ingest before loading sessions.
This handler reads the database directly without the
safe_init_db(db)andrun_ingestion(db)steps used by the existingshow_rage_quit()flow at Lines 1630-1634. As a result,rage-quitcan report stale results or fail when the database schema has not been initialized.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@termstory/cli.py` around lines 1576 - 1584, Update the handler around calculate_rage_quit_signatures to call safe_init_db(db) and run_ingestion(db) immediately after creating the Database, before get_all_sessions(). Match the initialization and ingestion order used by show_rage_quit(), while preserving the existing legacy-session filtering and signature calculation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@termstory/cli.py`:
- Around line 1576-1584: Update the handler around
calculate_rage_quit_signatures to call safe_init_db(db) and run_ingestion(db)
immediately after creating the Database, before get_all_sessions(). Match the
initialization and ingestion order used by show_rage_quit(), while preserving
the existing legacy-session filtering and signature calculation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6601da8d-4ff3-49f4-a09f-b0fb90cca18f
📒 Files selected for processing (1)
termstory/cli.py
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Greptile Review
🧰 Additional context used
📓 Path-based instructions (1)
termstory/*.py
📄 CodeRabbit inference engine (termstory/AGENTS.md)
Follow the existing project structure and naming conventions when adding features.
Files:
termstory/cli.py
🔇 Additional comments (1)
termstory/cli.py (1)
1565-1590: Remove the duplicaterage-quithandler registration.The new handler is registered alongside the existing
show_rage_quit()command, leaving two handlers for the same CLI command. Remove one registration and retain a single implementation.
bitflicker64
left a comment
There was a problem hiding this comment.
complete the review suggestion and it looks mergable to me
| def format_rage_quit_signatures( | ||
| signatures: List[Dict[str, Any]], total_events: int | ||
| ) -> str: | ||
| """Format rage-quit signatures for display in the CLI. | ||
|
|
||
| Args: | ||
| signatures: List of rage-quit signature dictionaries | ||
| total_events: Total number of rage-quit events analyzed | ||
|
|
||
| Returns: | ||
| Formatted string for terminal output | ||
| """ | ||
| if not signatures: | ||
| return ( | ||
| "😤 No rage-quit signatures found! You're either very" |
There was a problem hiding this comment.
🚨 Bug: Duplicate format_rage_quit_signatures shadows new 2-arg version
formatter.py now defines format_rage_quit_signatures twice: the new (signatures, total_events) version at line 211 and the pre-existing (rage_quit_info) version at line 1972. Because Python binds the later definition, the module-level name always resolves to the 1-arg version at 1972, so the new function at 211 is dead code. The new command's call format_rage_quit_signatures(signatures, total_events) (cli.py:1589) then passes two positional args to a 1-arg function, raising TypeError at runtime. Remove the duplicate new function and reuse the existing formatter, or rename one of them.
Delete the duplicate function; the feature already exists.:
# Drop the new format_rage_quit_signatures (formatter.py:211-276) entirely.
# The existing formatter at formatter.py:1972 already renders rage-quit
# signatures from the analyze_all() 'rage_quit_info' dict.
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
| @app.command("rage-quit") | ||
| def rage_quit(ctx: typer.Context) -> None: | ||
| """Find the most frequent commands before 12+ hour periods of inactivity. | ||
|
|
||
| Your "rage-quit" is the command you run before long breaks — | ||
| it reveals how you typically end your terminal sessions. | ||
| """ | ||
| from termstory.config import get_config | ||
| from termstory.database import Database | ||
| from termstory.formatter import format_rage_quit_signatures | ||
| from termstory.insights import calculate_rage_quit_signatures | ||
|
|
||
| config = get_config() | ||
| db = Database(config.get_db_path()) | ||
| sessions = db.get_all_sessions() |
There was a problem hiding this comment.
🚨 Bug: Duplicate @app.command("rage-quit") registration collides
cli.py registers @app.command("rage-quit") twice — the new rage_quit() handler at line 1564 and the pre-existing show_rage_quit() at line 1627. Two commands with the same name collide; Click/Typer keeps only one (the later show_rage_quit), so the new handler is silently shadowed and unreachable, making the whole PR a no-op that risks masking regressions. Remove the new duplicate rage_quit() command since show_rage_quit() already implements the feature via analyze_all().
Delete the duplicate command registration.:
# Remove the new command block at cli.py:1564-1590.
# show_rage_quit() at cli.py:1627 already registers 'rage-quit'.
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
Code Review 🚫 Blocked 0 resolved / 2 findingsAdds a new rage-quit CLI command and formatter, but fails due to duplicate 🚨 Bug: Duplicate format_rage_quit_signatures shadows new 2-arg version📄 termstory/formatter.py:211-225 📄 termstory/formatter.py:1972-1986 📄 termstory/cli.py:1573 📄 termstory/cli.py:1589 formatter.py now defines format_rage_quit_signatures twice: the new (signatures, total_events) version at line 211 and the pre-existing (rage_quit_info) version at line 1972. Because Python binds the later definition, the module-level name always resolves to the 1-arg version at 1972, so the new function at 211 is dead code. The new command's call Delete the duplicate function; the feature already exists.🚨 Bug: Duplicate
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
|
@greptile review |
Summary
This PR attempts to add a new
termstory rage-quitCLI command and formatter, but the feature already exists in v0.6.0 viashow_rage_quit()atcli.py:1600-1614. The diff introduces a duplicate command registration and a conflicting formatter signature that would break the existing implementation.Changes
@app.command("rage-quit")registration atcli.py:1564, conflicting with the existingshow_rage_quit()handler atcli.py:1600-1614format_rage_quit_signatures()function atformatter.py:211-278with signature(signatures, total_events), conflicting with the existing implementation atformatter.py:1833-1874which expects a singlerage_quit_infodictinsights.py:649Architecture / Flow
flowchart LR A[CLI: rage-quit command] --> B{Which handler?} B --> C[Existing: show_rage_quit at cli.py:1600] B --> D[New: rage_quit at cli.py:1564] C --> E[analyze_all db] D --> F[calculate_rage_quit_signatures sessions] E --> G[format_rage_quit_signatures rage_quit_info] F --> H[format_rage_quit_signatures signatures total_events] G --> I[Output] H --> J[Output] style C fill:#90EE90 style D fill:#FFB6C6 style G fill:#90EE90 style H fill:#FFB6C6Fixes
Breaking Changes
@app.command("rage-quit")handlersformat_rage_quit_signatures()has a different signature than the existing one, breaking the call fromshow_rage_quit()Testing
# This will fail due to duplicate command registration termstory rage-quitNotes
The
rage-quitfeature is already fully implemented in v0.6.0 withcalculate_rage_quit_signatures()ininsights.py:685-720, the CLI commandshow_rage_quit()incli.py:1600-1614, and the formatterformat_rage_quit_signatures()informatter.py:1833-1874. This PR should be rejected as it introduces conflicts without adding new functionality.