Skip to content

feat(mobile): warn before archiving a running task (port #2530)#2544

Open
Gilbert09 wants to merge 2 commits into
mainfrom
posthog-code/mobile-archive-running-task-warning
Open

feat(mobile): warn before archiving a running task (port #2530)#2544
Gilbert09 wants to merge 2 commits into
mainfrom
posthog-code/mobile-archive-running-task-warning

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

What

Ports desktop PR #2530 (add warning dialog for archiving running tasks) to the mobile app.

On desktop, choosing Archive on a still-running task shows a confirmation dialog before stopping the agent. Mobile archives tasks via swipe, so this adds the equivalent guard to the swipe-to-archive flow.

  • Swiping to archive a task whose latest run is non-terminal (still running) now shows a native Alert.alert confirm — title Archive running task?, message "<task title>" is still running. Archiving it now will stop the agent. You can unarchive it later., with Cancel / Archive buttons. The row springs back so a cancel leaves it visibly un-archived; it only archives on confirm.
  • Archiving a terminal task (completed / failed / cancelled) or one with no run proceeds immediately with no prompt — unchanged behaviour.

How

  • New renderer-layer util features/tasks/utils/archiveGuard.ts:
    • isTaskRunning(task) — true when latest_run.status is non-terminal (reuses the existing isTerminalStatus).
    • confirmArchiveRunningTask(taskTitle, onConfirm) — thin Alert.alert wrapper.
  • SwipeableTaskItem calls the guard in its swipe-release handler before sliding the row off.

Matches the mobile convention of native Alert.alert confirms (as used for delete-automation, attachment permissions, etc.). The running-vs-terminal decision uses the existing task status field — no new business logic in stores.

Scope

Like the desktop original (which only guarded its single-task menu archive, not bulk operations), this guards the single-task swipe path. The bulk selection-mode archive is intentionally left unchanged.

Tests

Added archiveGuard.test.ts covering isTaskRunning (running for non-terminal statuses, not running for terminal / no run) and confirmArchiveRunningTask (confirm archives, cancel does not). Full mobile tasks suite passes (74 tests); lint clean; typecheck introduces no new errors.

Swiping to archive a task whose run is still active now shows a confirmation
first, mirroring the desktop ArchiveRunningTaskDialog. Archiving a terminal
task (completed/failed/cancelled) or one with no run still archives
immediately with no prompt.

The guard lives in a small renderer-layer util (isTaskRunning +
confirmArchiveRunningTask) and is wired into the swipe-release handler, which
springs the row back on cancel so it stays visibly un-archived.

Generated-By: PostHog Code
Task-Id: a27b225b-f759-4150-a1f3-5b9a98af64d1
@Gilbert09 Gilbert09 requested a review from a team June 9, 2026 10:42
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 8cd13d7.

@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/mobile/src/features/tasks/utils/archiveGuard.test.ts:42-57
The two `isTaskRunning` tests iterate over status arrays with a `for` loop inside a single `it` block. The team's convention is to prefer parameterised tests (`it.each`), which surfaces each status as its own labelled test case so a single failure is immediately identifiable without re-running with extra logging.

```suggestion
  it.each(["not_started", "queued", "started", "in_progress"] as const)(
    "treats %s as running",
    (status) => {
      expect(isTaskRunning(makeTask(status))).toBe(true);
    },
  );

  it.each(["completed", "failed", "cancelled"] as const)(
    "treats %s as not running",
    (status) => {
      expect(isTaskRunning(makeTask(status))).toBe(false);
    },
  );
```

### Issue 2 of 2
apps/mobile/src/features/tasks/components/SwipeableTaskItem.tsx:123-129
**Missing slide-out animation on confirmed archive**

When the user confirms archiving a running task, `p.onArchive` is called directly — skipping both the `translateX → -400` slide animation and the `LayoutAnimation.configureNext` call that smooths out the list-height change. The row springs back to rest, then the item vanishes abruptly when the list re-renders, whereas every other archive action slides the row off first. The `onConfirm` callback should trigger the same `Animated.timing``LayoutAnimation``onArchive` sequence used by the normal path.

Reviews (1): Last reviewed commit: "feat(mobile): warn before archiving a ru..." | Re-trigger Greptile

Comment thread apps/mobile/src/features/tasks/utils/archiveGuard.test.ts Outdated
Comment thread apps/mobile/src/features/tasks/components/SwipeableTaskItem.tsx
Use it.each for isTaskRunning status tests and slide the row out before
archiving a confirmed running task, matching the normal archive animation.

Generated-By: PostHog Code
Task-Id: ab621d50-4d9c-412a-95ad-99ec33a16c2c
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.

1 participant