Skip to content

Conversation

@sanki92
Copy link
Contributor

@sanki92 sanki92 commented Nov 2, 2025

Prerequisites

  • I have read and understood the contributing guide.
  • The commit message follows the conventional commits guidelines.
  • Tests for the changes have been added (for bug fixes / features).
  • Docs have been added/updated (for bug fixes / features).

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_interval config option (in milliseconds) to automatically refresh the prompt on a timer. Implemented using native shell mechanisms for PowerShell, Zsh, Bash, and Fish.

Changes Made

  • Added RefreshInterval field to Config struct and feature detection logic
  • Implemented timer-based refresh for PowerShell (using System.Timers.Timer)
  • Implemented timer-based refresh for Zsh (using TMOUT and TRAPALRM)
  • Implemented timer-based refresh for Bash (using background process with SIGWINCH)
  • Implemented timer-based refresh for Fish (using background process with SIGUSR1)
  • Added TestRefreshIntervalFeature and updated all shell feature tests

Testing

  • ✅ All existing tests pass - no breaking changes
  • ✅ New unit test validates feature detection for all shells
  • ✅ Shell feature tests updated to include RefreshInterval

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

Copilot AI review requested due to automatic review settings November 2, 2025 10:09
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 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 RefreshInterval feature 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.

@sanki92 sanki92 mentioned this pull request Nov 2, 2025
1 task
Copilot AI review requested due to automatic review settings November 2, 2025 10:19
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

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.

Copilot AI review requested due to automatic review settings November 2, 2025 10:33
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

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.

Copilot AI review requested due to automatic review settings November 2, 2025 13:41
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

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.

Copilot AI review requested due to automatic review settings November 4, 2025 11:27
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

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings November 4, 2025 12:59
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

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*2 is now incorrect since RefreshInterval was added after Async. This will cause RefreshInterval to be excluded from the feature iteration. Update to RefreshInterval*2 or use a more maintainable approach that doesn't hardcode the last feature.
		if feature > Async*2 {

Copilot AI review requested due to automatic review settings November 4, 2025 13:05
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

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*2 prevents the getAllFeatures() function from including the newly added RefreshInterval feature. Since RefreshInterval is now the last feature in the enum (after Async), the loop terminates before reaching it. This should be updated to RefreshInterval*2 to 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}")

Copy link

Copilot AI Nov 4, 2025

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.

Suggested change

Copilot uses AI. Check for mistakes.

# Convert milliseconds to seconds for fish
set --local timeout_seconds (math "$interval / 1000.0")

Copy link

Copilot AI Nov 4, 2025

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.

Suggested change

Copilot uses AI. Check for mistakes.
kill -WINCH $parent_pid 2>/dev/null
done
) &

Copy link

Copilot AI Nov 4, 2025

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.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +246 to +250

function _omp_refresh_timer --on-signal SIGUSR1
omp_repaint_prompt
end

Copy link

Copilot AI Nov 4, 2025

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.

Suggested change
function _omp_refresh_timer --on-signal SIGUSR1
omp_repaint_prompt
end
function _omp_refresh_timer --on-signal SIGUSR1
omp_repaint_prompt
end

Copilot uses AI. Check for mistakes.
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.

Refresh Git widgets periodically

1 participant