Skip to content

emrg: show running task elapsed duration + 5s status polling in GUI task panel - #931

Merged
argszero merged 2 commits into
masterfrom
feature/gui-task-running-duration
Aug 22, 2026
Merged

emrg: show running task elapsed duration + 5s status polling in GUI task panel#931
argszero merged 2 commits into
masterfrom
feature/gui-task-running-duration

Conversation

@argszero

Copy link
Copy Markdown
Owner

Implements the GUI task-panel improvements from rant 2026-08-22T07:18:35: show the running task's elapsed duration, and auto-refresh the running→queued state transition via 5s polling (host-confirmed polling approach — a few seconds of lag is acceptable, no event push).

Changes

emrg/server/scheduler.pyTaskHandler.status() now exposes "started_at": the current cycle's start epoch (self._start_time), valid only while running is true, None when idle/completed.

emrg/gui/renderer/js/dialogs.js

  • Running task rows now render an elapsed-duration span "已运行 XXs" (app.taskRunningDuration i18n) that ticks up every second — reuses the existing taskCountdowns array mechanism, mirrored: startedAt fixed, now increases so the duration grows (vs. the pending countdown which shrinks toward its deadline).
  • New startTaskPoll() / stopTaskPoll(): a 5s interval re-fetches loadTaskMeta() + renderTaskList() while the panel is active, so a task that finishes its cycle flips to "待运行" with its next-run countdown within ≤5s. Idempotent start; separate timer from the 1s countdown (the poll never restarts itself).

emrg/gui/renderer/js/app.js

  • openTasksPanel() starts the poll after the initial render.
  • Both view-leave paths (switchView to a non-tasks view, and toggle-close of the tasks panel) call stopTaskPoll() alongside the existing stopTaskCountdown() — same lifecycle, no leaks.

emrg/gui/renderer/js/i18n.js — new app.taskRunningDuration key in zh (已运行 {n}) and en (running for {n}).

Verification

  • uv run pytest tests/: 1002 passed, 1 skipped (new assertions in test_evolution_handler_status_last_run_fields cover started_at = epoch while running, None while idle)
  • python -c "from emrg.client.app import run_client": OK
  • python -m emrg --help: OK
  • GUI renderer smoke tests extended (elapsed tick + poll lifecycle) — executed by CI (test-windows job; no local node binary on this host)

CSS/JS + one additive daemon field; no protocol breaking changes.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle 1245. Verified the scheduler status() started_at semantics (epoch while running / None when idle, both asserted in tests), the dialogs.js elapsed-tick + 5s poll lifecycle (start on panel open, stop on both view-leave paths — no leak), and i18n keys in zh/en. CI test+test-windows green (run 32537257426).

@argszero

Copy link
Copy Markdown
OwnerAuthor

Found a semantic bug during review: _start_time is set ONCE at handler start (scheduler.py run()), so the originally-shipped started_at reported cumulative handler uptime instead of THIS cycle's elapsed time — the second cycle onward would show a wrong (growing) duration. The rant explicitly asks for 本次运行时长 (this run's duration).

Fix (commit 207dcc6): added a dedicated per-cycle timestamp _cycle_start_time — set at tick begin (where _cycle_running = True), cleared in the finally block. status()['started_at'] now reads _cycle_start_time while running. _start_time is untouched, so template uptime semantics are preserved.

Tests updated to exercise _cycle_start_time (epoch while running / None when idle); full suite re-verified: 1002 passed, 1 skipped, import + CLI OK.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle 1245 (re-verified on head 207dcc6 after the per-cycle started_at fix). The scheduler change now reports THIS cycle's elapsed time via _cycle_start_time (set at tick begin, cleared at cycle end) — matching the rant's 本次运行时长 requirement; _start_time (handler uptime) semantics preserved for templates. Full suite 1002 passed + 1 skipped, import + CLI OK; CI test + test-windows green (run 32537919701).

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle 1246. Fresh re-verify on head 207dcc6: per-cycle started_at semantics correct, elapsed tick + 5s poll lifecycle sound, i18n zh/en present, tests cover both states; CI test+test-windows green (run 32537919701).

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle 1247. Fresh diff review vs master e6aa4d4: scheduler exposes per-cycle _cycle_start_time (set at tick begin, cleared at end) as started_at; dialogs.js elapsed tick + 5s poll lifecycle (start on open, stop on both leave paths); i18n zh/en present; tests cover running/idle states. CI test+test-windows green (run 32537919701).

@argszero
argszero merged commit 4f3dda5 into masterAug 22, 2026
2 checks passed
argszero added a commit that referenced this pull request Aug 22, 2026
Co-authored-by: EMRG Evolution <emrg@argszero.dev>
@argszero
argszero deleted the feature/gui-task-running-duration branch August 23, 2026 02:26
Sign up for freeto 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.

1 participant

@argszero