Skip to content
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

feat: added terminal title status output #438

Merged
merged 1 commit into from
Feb 6, 2025
Merged

Conversation

ErikBjare
Copy link
Owner

@ErikBjare ErikBjare commented Feb 6, 2025

Important

Adds terminal title updates to reflect current status during message generation, tool execution, and user input in gptme application.

  • Behavior:
    • Adds terminal title updates to reflect current status using terminal_state_title() in chat.py, tools/__init__.py, and ask_execute.py.
    • Sets initial terminal title with conversation name in chat() in chat.py.
  • Utilities:
    • Adds terminal_state_title(), set_terminal_state(), and reset_terminal_title() in util/terminal.py for managing terminal titles.
  • Integration:
    • Wraps message generation in step() in chat.py with terminal_state_title("🤔 generating").
    • Wraps user input prompt in prompt_user() in chat.py with terminal_state_title("⌨️ waiting for input").
    • Wraps tool execution in execute_msg() in tools/__init__.py with terminal_state_title("🛠️ running {tooluse.tool}").
    • Wraps user confirmation prompt in ask_execute() in ask_execute.py with terminal_state_title("❓ waiting for confirmation").

This description was created by Ellipsis for a02bee9. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Reviewed everything up to e95270a in 1 minute and 36 seconds

More details
  • Looked at 286 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 8 drafted comments based on config settings.
1. gptme/chat.py:46
  • Draft comment:
    The terminal_title_state context manager resets the title to the default (using _make_title) on exit. If nested title changes are expected, consider preserving and restoring the previous state.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
  1. The comment points out a potential issue with nested context manager usage
  2. However, I cannot see the implementation of set_terminal_state and reset_terminal_title
  3. Without seeing those implementations, I cannot verify if this is actually an issue
  4. The comment is speculative ("if nested title changes are expected...")
  5. The current code looks reasonable for the simple use cases shown in the diff
    I may be too quick to dismiss this - nested context managers are a real pattern and this could be a legitimate architectural concern.
    While nested context managers are important, this comment is speculative and we don't have enough context to verify if it's a real issue. The code works for its current usage patterns.
    Delete the comment because it is speculative ("if nested title changes are expected") and we cannot verify if it's a real issue without seeing the terminal utility implementations.
2. gptme/tools/__init__.py:15
  • Draft comment:
    The tool_execution_state context manager is clean. Ensure that the tool_name passed is concise, as it directly appears in the terminal title.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 50%
    None
3. gptme/util/ask_execute.py:27
  • Draft comment:
    The confirmation_title_state context manager is used to set a specific title during prompts. Its usage improves UX, and the implementation looks sound.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
4. gptme/util/terminal.py:34
  • Draft comment:
    In _set_raw_title, using print() for emitting ANSI sequences works in most cases, but consider sys.stdout.write for finer control in non-interactive scenarios.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 50%
    None
5. gptme/util/ask_execute.py:180
  • Draft comment:
    The return expression does not handle the default=False case. When default is false, it evaluates to an empty list, so even a 'y' input will return false. Consider using something like: return answer in (['y', 'yes'] if not default else ['y', 'yes', '']).
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
6. gptme/util/ask_execute.py:177
  • Draft comment:
    The help option uses a recursive call to ask_execute, which may lead to deep recursion if help is requested multiple times. Consider refactoring to an iterative loop.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
7. gptme/chat.py:92
  • Draft comment:
    The use of the terminal_title_state context manager for initialization sets a temporary title that resets right after init. Confirm this is intended; if a persistent title is desired, the context scope might need to be adjusted.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
8. gptme/tools/__init__.py:131
  • Draft comment:
    Ensure that 'tooluse.tool' is a string as expected by the tool_execution_state context manager. If it's an object, consider using its name or another identifier.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.

Workflow ID: wflow_63BjSTZ6Xw3g7TqG


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 84.90566% with 8 lines in your changes missing coverage. Please review.

Project coverage is 67.15%. Comparing base (486d985) to head (a02bee9).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
gptme/util/terminal.py 87.50% 4 Missing ⚠️
gptme/util/ask_execute.py 25.00% 3 Missing ⚠️
gptme/chat.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #438      +/-   ##
==========================================
+ Coverage   65.46%   67.15%   +1.68%     
==========================================
  Files          70       71       +1     
  Lines        6226     6266      +40     
==========================================
+ Hits         4076     4208     +132     
+ Misses       2150     2058      -92     
Flag Coverage Δ
anthropic/claude-3-haiku-20240307 65.92% <84.90%> (?)
openai/gpt-4o-mini 65.59% <84.90%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ErikBjare ErikBjare force-pushed the dev/terminal-status branch from e95270a to d37e8e7 Compare February 6, 2025 11:37
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on d37e8e7 in 30 seconds

More details
  • Looked at 290 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 9 drafted comments based on config settings.
1. gptme/chat.py:70
  • Draft comment:
    Using 'set_current_conv_name(logdir.name)' immediately sets the conversation name; ensure that logdir.name is sanitized if it might contain unexpected characters.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
2. gptme/chat.py:268
  • Draft comment:
    Good use of the terminal_state_title context manager around the reply generation. Verify that exceptions inside yield still result in a proper terminal title reset.
  • Reason this comment was not posted:
    Confidence changes required: 20% <= threshold 50%
    None
3. gptme/util/terminal.py:57
  • Draft comment:
    The reset_terminal_title() uses _make_title() without a state, which reuses _current_conv_name. Ensure this is the intended behavior for title reset after temporary state changes.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 50%
    None
4. gptme/chat.py:70
  • Draft comment:
    Good addition: setting the terminal title with the conversation name improves context. Consider validating logdir.name to avoid unwanted characters in terminal titles.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
5. gptme/chat.py:276
  • Draft comment:
    Wrapping the call to reply() in terminal_state_title provides clear status feedback. Ensure that any exceptions within reply() are handled properly within this context.
  • Reason this comment was not posted:
    Confidence changes required: 20% <= threshold 50%
    None
6. gptme/chat.py:298
  • Draft comment:
    Using terminal_state_title in prompt_user to indicate input waiting state is a nice UX improvement. The placement of clear_interruptible() outside the context seems appropriate.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
7. gptme/tools/__init__.py:116
  • Draft comment:
    Wrapping tool execution in terminal_state_tool contextualizes tool runs. Verify that tooluse.tool is reliably a valid string and consider sanitizing if necessary.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
8. gptme/util/ask_execute.py:126
  • Draft comment:
    Using the confirmation_title_state context manager to update the terminal title during confirmation prompt enhances clarity. This is a clean implementation.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
9. gptme/util/terminal.py:67
  • Draft comment:
    The new terminal manipulation utilities are clear. Consider using sys.stdout.write instead of print when setting the terminal title to avoid any unexpected formatting, though the current approach is acceptable.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None

Workflow ID: wflow_FeJ4UpwsokFsU1ve


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@ErikBjare ErikBjare force-pushed the dev/terminal-status branch from d37e8e7 to 63f3e6b Compare February 6, 2025 11:38
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on 63f3e6b in 27 seconds

More details
  • Looked at 282 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 11 drafted comments based on config settings.
1. gptme/chat.py:276
  • Draft comment:
    Using the terminal_state_title context manager to wrap the reply generation is clear and neat. Confirm that the title reset is acceptable in non-interactive environments.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
2. gptme/chat.py:298
  • Draft comment:
    The prompt_user function wraps the waiting-for-input phase with terminal_state_title appropriately. This is a clean integration; ensure that title resets are handled correctly.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
3. gptme/tools/__init__.py:116
  • Draft comment:
    Wrapping tool execution within terminal_state_tool provides clear context in the terminal title. This looks well integrated.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
4. gptme/util/ask_execute.py:115
  • Draft comment:
    The terminal_state_confirm context manager is correctly applied to the user prompt session. This helps indicate waiting state; ensure consistency with other terminal contexts.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
5. gptme/util/terminal.py:11
  • Draft comment:
    The new terminal manipulation utilities are straightforward. Verify that using ANSI escape sequences via print is consistent across your supported terminal emulators.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
6. gptme/chat.py:70
  • Draft comment:
    Nice addition: setting the terminal title with the conversation name (using logdir.name) enhances UX. Ensure the conversation name is always a valid string for the title.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
7. gptme/chat.py:268
  • Draft comment:
    Good use of the terminal_state_title context manager during response generation to update terminal title. This temporary UI feedback is a useful addition.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
8. gptme/chat.py:298
  • Draft comment:
    Wrapping the prompt input loop with terminal_state_title helps indicate waiting state. This improves user experience during user input.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
9. gptme/tools/__init__.py:118
  • Draft comment:
    Using terminal_state_tool around tool execution is effective. Just confirm that 'tooluse.tool' reliably yields a string identifier for proper terminal title display.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
10. gptme/util/ask_execute.py:115
  • Draft comment:
    Good integration: the terminal_state_confirm context manager clearly indicates when the system is waiting for user confirmation.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
11. gptme/util/terminal.py:10
  • Draft comment:
    The new terminal utility module with context managers for updating terminal titles is well implemented. Consider adding comments about potential fallback options for non-ANSI terminals if needed in the future.
  • Reason this comment was not posted:
    Confidence changes required: 20% <= threshold 50%
    None

Workflow ID: wflow_MX7Mz5gNIAOcLTZb


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@ErikBjare ErikBjare force-pushed the dev/terminal-status branch from 63f3e6b to a02bee9 Compare February 6, 2025 11:44
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on a02bee9 in 40 seconds

More details
  • Looked at 262 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. gptme/tools/__init__.py:118
  • Draft comment:
    Use an f-string for dynamic interpolation. Change "🛠️ running {tooluse.tool}" to f"🛠️ running {tooluse.tool}".
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. gptme/chat.py:268
  • Draft comment:
    Good use of context manager for terminal state during response generation.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
3. gptme/chat.py:298
  • Draft comment:
    Nice addition of terminal state when waiting for user input.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
4. gptme/util/ask_execute.py:115
  • Draft comment:
    Appropriate wrapping of the session prompt with terminal_state_title for confirmation.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
5. gptme/util/terminal.py:10
  • Draft comment:
    New terminal utility file looks good; consider adding tests for escape sequences if possible.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
6. gptme/tools/__init__.py:118
  • Draft comment:
    Use an f-string here to interpolate the tool name. Change "🛠️ running {tooluse.tool}" to f"🛠️ running {tooluse.tool}".
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_rhr1eDh5qeWPrPKi


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@ErikBjare ErikBjare merged commit 37c877f into master Feb 6, 2025
7 checks 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.

2 participants