-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(config): add refresh interval for periodic prompt updates #6938
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
base: main
Are you sure you want to change the base?
feat(config): add refresh interval for periodic prompt updates #6938
Conversation
There was a problem hiding this 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 adds a refresh interval feature that allows prompts to be automatically refreshed at a configurable time interval. This enables time-based segments (like clocks) to update automatically without requiring user interaction.
Key Changes:
- Added
RefreshIntervalfeature flag to the shell features system - Implemented refresh interval functionality for PowerShell, Zsh, Bash, and Fish shells
- Updated initialization code to pass refresh interval configuration to shell scripts
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/shell/features.go | Added RefreshInterval constant to feature flags |
| src/config/config.go | Added RefreshInterval field and logic to enable feature for supported shells |
| src/shell/init.go | Updated Init and PrintInit functions to accept and pass refreshInterval parameter |
| src/cli/init.go | Modified to pass RefreshInterval from config to shell initialization |
| src/shell/pwsh.go | Added PowerShell feature mapping for RefreshInterval |
| src/shell/zsh.go | Added Zsh feature mapping for RefreshInterval |
| src/shell/bash.go | Added Bash feature mapping for RefreshInterval |
| src/shell/fish.go | Added Fish feature mapping for RefreshInterval |
| src/shell/scripts/omp.ps1 | Implemented timer-based prompt refresh using System.Timers.Timer |
| src/shell/scripts/omp.zsh | Implemented prompt refresh using TMOUT and TRAPALRM |
| src/shell/scripts/omp.bash | Implemented prompt refresh using background process with SIGWINCH |
| src/shell/scripts/omp.fish | Implemented prompt refresh using background process with SIGUSR1 |
| src/shell/pwsh_test.go | Updated tests to include RefreshInterval in feature tests |
| src/shell/zsh_test.go | Updated tests to include RefreshInterval in feature tests |
| src/shell/bash_test.go | Updated tests to include RefreshInterval in feature tests |
| src/shell/fish_test.go | Updated tests to include RefreshInterval in feature tests |
| src/config/config_test.go | Added comprehensive tests for RefreshInterval feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/shell/features.go:33
- The stop condition
Async*2is now incorrect sinceRefreshIntervalwas added afterAsync. This will causeRefreshIntervalto be excluded from the feature iteration. Update toRefreshInterval*2or use a more maintainable approach that doesn't hardcode the last feature.
if feature > Async*2 {
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
src/shell/features.go:33
- The hardcoded check
Async*2prevents thegetAllFeatures()function from including the newly addedRefreshIntervalfeature. SinceRefreshIntervalis now the last feature in the enum (afterAsync), the loop terminates before reaching it. This should be updated toRefreshInterval*2to ensure all features are included.
if feature > Async*2 {
|
|
||
| # Convert milliseconds to seconds for bash (preserve sub-second precision) | ||
| local timeout_seconds=$(awk "BEGIN {print $interval/1000}") | ||
|
|
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected on line 178. This should be removed for consistency with coding standards.
|
|
||
| # Convert milliseconds to seconds for fish | ||
| set --local timeout_seconds (math "$interval / 1000.0") | ||
|
|
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected on line 246. This should be removed for consistency with coding standards.
| kill -WINCH $parent_pid 2>/dev/null | ||
| done | ||
| ) & | ||
|
|
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected on line 192. This should be removed for consistency with coding standards.
|
|
||
| function _omp_refresh_timer --on-signal SIGUSR1 | ||
| omp_repaint_prompt | ||
| end | ||
|
|
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected on line 250. This should be removed for consistency with coding standards.
| function _omp_refresh_timer --on-signal SIGUSR1 | |
| omp_repaint_prompt | |
| end | |
| function _omp_refresh_timer --on-signal SIGUSR1 | |
| omp_repaint_prompt | |
| end |
0f43b02 to
fa38ae3
Compare
Prerequisites
Description
Issue
Fixes #5036
Problem
Prompt only refreshes when executing commands. Users had to press Enter repeatedly to see updated git status, time, battery, and other dynamic segments.
Solution
Added
refresh_intervalconfig option (in milliseconds) to automatically refresh the prompt on a timer. Implemented using native shell mechanisms for PowerShell, Zsh, Bash, and Fish.Changes Made
RefreshIntervalfield toConfigstruct and feature detection logicSystem.Timers.Timer)TMOUTandTRAPALRM)SIGWINCH)SIGUSR1)TestRefreshIntervalFeatureand updated all shell feature testsTesting
Usage Example
{ "refresh_interval": 5000, "blocks": [...] }Prompt now refreshes every 5 seconds, automatically updating git status, time, and all dynamic segments without pressing Enter.
Supported shells: PowerShell, Zsh, Bash, Fish
Implementation: Non-blocking, uses native shell timers, opt-in only, proper resource cleanup