Skip to content

feat: add auto-refresh interval option#1149

Closed
chindris-mihai-alexandru wants to merge 1 commit intotw93:mainfrom
chindris-mihai-alexandru:feat/auto-refresh-interval
Closed

feat: add auto-refresh interval option#1149
chindris-mihai-alexandru wants to merge 1 commit intotw93:mainfrom
chindris-mihai-alexandru:feat/auto-refresh-interval

Conversation

@chindris-mihai-alexandru
Copy link
Copy Markdown

Summary

  • add a new --refresh-interval CLI option to reload the packaged page on a fixed interval
  • defer refresh while the page is hidden or while the user is actively focused in editable fields
  • document the option in CLI usage docs

Closes #1146

Why

Some packaged sites such as news pages or dashboards do not refresh themselves automatically, and manually pressing reload is inconvenient. This adds an opt-in refresh interval directly in Pake instead of requiring external automation.

Behavior

pake https://news.ycombinator.com --name HackerNews --refresh-interval 300
  • value is in seconds
  • default is 0 (disabled)
  • when enabled, Pake schedules a timed reload in the injected runtime
  • if the page is hidden, refresh is deferred
  • if the user is focused in an input, textarea, select, or contenteditable field, refresh is deferred

Files changed

  • bin/types.ts - add refreshInterval and refresh_interval config fields
  • bin/defaults.ts - default interval of 0
  • bin/helpers/cli-program.ts - register --refresh-interval <number>
  • bin/helpers/merge.ts - write interval into generated pake.json
  • src-tauri/src/app/config.rs - deserialize refresh_interval
  • src-tauri/src/inject/event.js - implement deferred timed reload behavior
  • src-tauri/pake.json - template default
  • tests/unit/cli-options.test.ts - CLI option test
  • docs/cli-usage.md - usage docs

Validation

  • pnpm run cli:build
  • npx vitest run tests/unit/cli-options.test.ts
  • cargo check
  • built a real app with PAKE_CREATE_APP=1 and verified generated .pake/pake.json contains "refresh_interval": 120

Add a new --refresh-interval CLI option that reloads the packaged page on a
fixed interval. The injected runtime defers refreshes while the page is hidden
or while the user is focused in editable fields so dashboards and news pages
can stay fresh without disrupting active input.
@tw93
Copy link
Copy Markdown
Owner

tw93 commented Mar 14, 2026

@chindris-mihai-alexandru Thanks for the PR. I do not think this should be a built-in Pake option.

Pake already supports --inject, and auto-refresh fits better as a small custom script than as a new core CLI/config feature.

setInterval(() => {
  const el = document.activeElement;
  const editing =
    el &&
    (el.isContentEditable ||
      ["INPUT", "TEXTAREA", "SELECT"].includes(el.tagName));

  if (!document.hidden && !editing) {
    window.location.reload();
  }
}, 300000);
pake https://news.ycombinator.com --name HackerNews --inject ./refresh.js

I think this is better as documentation, not core behavior.

@tw93 tw93 closed this Mar 14, 2026
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.

Auto refresh page at interval

2 participants