Skip to content

improve traversal in the tui#89

Merged
dhth merged 3 commits intomainfrom
improve-traversal
Aug 17, 2025
Merged

improve traversal in the tui#89
dhth merged 3 commits intomainfrom
improve-traversal

Conversation

@dhth
Copy link
Owner

@dhth dhth commented Aug 16, 2025

Summary by CodeRabbit

  • New Features

    • Consistent Esc handling to go back or exit forms; also quits in records.
    • Refined navigation: from inactive task list goes to task log; Help returns to your last view.
    • Improved window resizing; can quit from insufficient screen view via Ctrl+C, q, or Esc.
    • Enter no longer submits when the comment field is focused.
    • Streamlined date/time display formats.
  • Documentation

    • Help updated: back is q/Esc; Ctrl+C quits immediately.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @dhth, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the navigation and keybinding behavior within the TUI, primarily focusing on the escape and q keys. It introduces more context-aware handling for these keys, ensuring that users can intuitively navigate back to previous views or quit the application, depending on the current interface state. Additionally, it includes minor code cleanup by removing unused constants.

Highlights

  • Improved Escape Key Handling: The escape key's behavior is now context-dependent, specifically calling handleEscapeInForms() only when in form-related views, preventing unintended exits from other views.
  • Refined 'Go Back' Logic: The helpView now returns to the lastView instead of always taskListView, enhancing user flow. The taskLogView now correctly returns to itself when 'q' or 'escape' is pressed.
  • Clearer Quit vs. Go Back: The ctrl+c key is now explicitly designated for immediate quitting, while q and escape are used for navigating back or gracefully exiting, aligning with updated help text.
  • Code Cleanup: Unused time format constants (dayFormat, friendlyTimeFormat) have been removed from internal/ui/model.go, contributing to cleaner code.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly improves the user experience of the TUI by refining traversal and key handling. The changes make navigation more intuitive and consistent, particularly with the escape and q keys. Separating the immediate quit action to ctrl+c is a good clarification of user intent. The refactoring also fixes a potential bug where the escape key could be handled twice. I have one high-severity suggestion to improve maintainability by consolidating key-press handling logic.

@dhth dhth requested a review from Copilot August 16, 2025 23:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the keyboard navigation and user experience in the TUI by adding proper escape key handling and refining the quit behavior. The changes separate immediate quit (Ctrl+C) from navigational back actions (q/escape), and improve view traversal logic.

Key changes:

  • Added escape key constant and handling to provide consistent navigation between views
  • Separated immediate quit (Ctrl+C) from back navigation (q/escape) for better UX
  • Improved view traversal by remembering the last view when returning from help

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
internal/ui/update.go Added escape key handling, restructured quit logic, and improved view navigation flow
internal/ui/model.go Removed unused time format constants
internal/ui/help.go Updated help text to reflect new keyboard shortcuts (escape for back, Ctrl+C for quit)
internal/ui/handle.go Renamed escape handler function and improved back navigation to return to last view from help

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@dhth
Copy link
Owner Author

dhth commented Aug 17, 2025

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Aug 17, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Aug 17, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Important

Review skipped

Auto reviews are disabled on this repository.

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.

Walkthrough

Refactors Escape-key handling and back/quit routing across UI update logic; adds a constant for Escape; introduces early window-resize handling; adjusts view transitions for back action; updates help text to reflect new shortcuts; and removes two time-format constants.

Changes

Cohort / File(s) Summary
Escape handling refactor and back/quit flow
internal/ui/update.go, internal/ui/handle.go
Added escape constant; centralized Escape handling including forms via handleEscapeInForms; modified back/quit routing through handleRequestToGoBackOrQuit; added early window-resize path; updated records model to accept Escape as quit; adjusted Enter behavior for entryComment focus. Renamed handleEscape to handleEscapeInForms.
Help text shortcut updates
internal/ui/help.go
Documented back as q/; added Ctrl+C as “Quit immediately.”
Time format constants cleanup
internal/ui/model.go
Removed dayFormat and friendlyTimeFormat; retained other time/date formats; no control-flow changes.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant UI Model
  participant View Router
  participant Form Handler
  participant Window Resizer

  User->>UI Model: Key/Window events
  alt WindowSizeMsg
    UI Model->>Window Resizer: handleWindowResizing
    Window Resizer-->>UI Model: updated dims/commands
  else Escape key
    alt In form views
      UI Model->>Form Handler: handleEscapeInForms
      Form Handler-->>UI Model: commands
    else Other views
      UI Model->>View Router: handleRequestToGoBackOrQuit (via q/esc)
      View Router-->>UI Model: GoBack/Quit decision
    end
  else q key
    UI Model->>View Router: handleRequestToGoBackOrQuit
    View Router-->>UI Model: GoBack/Quit decision
  else Ctrl+C
    UI Model-->>User: Quit
  else Enter
    alt entryComment focused
      UI Model-->>User: No-op
    else Create/Update action
      UI Model-->>User: Execute command
    end
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

I tap ESC—a burrowed breeze—
The views hop back with practiced ease.
Q or carrot, quit we may,
While windows resize, come what may.
Time sheds formats, light and spry—
A rabbit ships, then bounds on by. 🥕🐇

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-traversal

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (2)
internal/ui/handle.go (1)

199-201: Bug: clearing the wrong input slice in editActiveTLView.

You’re clearing taskInputs instead of TL inputs when handling Escape for editActiveTLView. This wipes the task summary field instead of the begin timestamp.

Apply:

-    m.taskInputs[entryBeginTS].SetValue("")
+    m.tLInputs[entryBeginTS].SetValue("")
internal/ui/update.go (1)

167-173: ‘q’ does not go back in forms (help says q/ go back).

Currently, Escape in forms routes to handleEscapeInForms(), but ‘q’ falls through to handleRequestToGoBackOrQuit(), which doesn’t handle form views—so ‘q’ is a no-op in forms. This contradicts the help text and will confuse users.

Apply this to align ‘q’ with Escape in forms:

-        case "q", escape:
-            shouldQuit := m.handleRequestToGoBackOrQuit()
+        case "q", escape:
+            // Treat 'q' like Escape in form views
+            switch m.activeView {
+            case taskInputView, editActiveTLView, finishActiveTLView, manualTasklogEntryView, editSavedTLView:
+                m.handleEscapeInForms()
+                return m, tea.Batch(cmds...)
+            }
+            shouldQuit := m.handleRequestToGoBackOrQuit()
             if shouldQuit {
                 return m, tea.Quit
             }
♻️ Duplicate comments (2)
internal/ui/update.go (2)

80-85: Escape focuses only forms here; consider a safety net.

This block handles Escape in form views only. If new form views are added, they’ll need to be added here as well.

Document this requirement or add a default branch to handle future form views defensively.


49-144: Two separate key-handling switch blocks reduce maintainability.

Key handling happens in two disjoint switches (Lines 49–144 and again at 164–279). Centralizing into one would reduce drift and double-handling risk.

Also applies to: 164-279

🧹 Nitpick comments (1)
internal/ui/handle.go (1)

205-211: Move comment clearing out of the loop.

m.tLCommentInput.SetValue("") is called on each iteration unnecessarily.

Apply:

-    for i := range m.tLInputs {
-        m.tLInputs[i].SetValue("")
-        m.tLCommentInput.SetValue("")
-    }
+    for i := range m.tLInputs {
+        m.tLInputs[i].SetValue("")
+    }
+    m.tLCommentInput.SetValue("")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e01b36a and 787a2ba.

📒 Files selected for processing (4)
  • internal/ui/handle.go (2 hunks)
  • internal/ui/help.go (1 hunks)
  • internal/ui/model.go (1 hunks)
  • internal/ui/update.go (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/ui/handle.go (1)
internal/ui/model.go (1)
  • Model (81-115)
🔇 Additional comments (6)
internal/ui/help.go (1)

43-45: Help shortcuts update looks correct.

Documenting q/ for “Go back” and adding “<ctrl+c> Quit immediately” aligns with the updated input handling and improves clarity for users.

internal/ui/handle.go (1)

331-335: Back navigation target changed; confirm intent.

inactiveTaskListView now goes back to taskLogView (was taskListView), and helpView goes back to lastView. If this is meant to create a consistent traversal cycle, all good—just confirm it matches expected UX flows.

internal/ui/update.go (4)

15-18: Introducing an escape key constant is a good cleanup.

Centralizing "esc" as a constant reduces stringly-typed errors and improves readability.


26-37: Early window-resize handling is solid.

Handling tea.WindowSizeMsg upfront and normalizing insufficientDimensionsView behavior improves clarity and consistency of returns.


50-59: Enter bail-out for comment textarea is a nice UX fix.

Avoiding accidental submit while entryComment is focused mirrors typical form behavior.


375-378: recordsModel: Escape included for quitting — good.

Adding Escape alongside ctrl+C and q for quit in records view keeps behavior consistent across UI.

@dhth dhth merged commit d0643a9 into main Aug 17, 2025
14 checks passed
@dhth dhth deleted the improve-traversal branch August 17, 2025 01:44
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