fix(archive): stop "Archive running task?" dialog firing on idle tasks#3064
Merged
Conversation
…tasks
The archive confirmation was gated by:
task.taskRunStatus === "in_progress" || task.isGenerating
where taskRunStatus falls back to task.latest_run.status. That persisted
status is only kept current by the backend for cloud runs. Local runs never
get a terminal status written back when the agent goes idle or the app
closes, so latest_run.status stays "in_progress" forever — meaning the dialog
fired on archive for essentially every local task the user had ever run.
Move the predicate into core as a tested pure helper (isTaskActivelyRunning)
and only trust the persisted status for cloud runs. Local tasks now count as
running only while a prompt is actually in flight (isGenerating), matching the
existing session-based "running" logic in canvasGenerationStatus.ts and how
TaskIcon already gates run-status semantics to cloud tasks.
Adds a parameterised regression test covering the stale-local-in_progress case.
Generated-By: PostHog Code
Task-Id: 9f81df96-fa22-49c3-a559-7cb273296093
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "fix(archive): stop the "Archive running ..." | Re-trigger Greptile |
There was a problem hiding this comment.
Well-targeted bug fix: extracts a pure predicate into @posthog/core (correct layer), fixes the stale in_progress status problem for local runs, and ships 12 parameterised test cases that explicitly cover the regression. Architecture rules are satisfied — @posthog/ui importing from @posthog/core is explicitly permitted, and the function has no host dependencies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The "Archive running task?" confirmation was popping up on nearly every archive, even for tasks that weren't running.
The guard in
SidebarMenu.tsxwas:where
taskRunStatusfalls back totask.latest_run.status. That persisted status is only kept current by the backend for cloud runs (it flips tocompleted/failed/cancelledwhen the sandbox finishes or crashes).Local runs never get a terminal status written back — nothing PATCHes the run when the local agent goes idle or the app closes — so
latest_run.statusstays"in_progress"forever. Once there's no live session, the guard read that stale status and treated the task as running.Fix
Moved the predicate into core as a pure, tested helper (
packages/core/src/sidebar/taskRunning.ts, mirroringrunEnvironment.ts) and corrected the logic:isGenerating); the stale persisted status is ignored.in_progresssignal — behaviour unchanged.This matches the existing session-based "running" logic in
canvasGenerationStatus.tsand howTaskIconalready gates run-status semantics to cloud tasks.Testing
taskRunning.test.ts(12 cases), including the exact regression: stale localin_progresswith no live prompt → not running.pnpm --filter @posthog/core test→ 185 files / 1859 tests pass.typecheck(core + ui) andbiome lintclean.Note (out of scope)
The mobile guard (
apps/mobile/.../archiveGuard.ts) uses raw!isTerminalStatus(latest_run.status), which has the same latent flaw for local tasks — only sound today because mobile is cloud-only. Left untouched here.