feat(mobile): warn before archiving a running task (port #2530)#2544
Open
Gilbert09 wants to merge 2 commits into
Open
feat(mobile): warn before archiving a running task (port #2530)#2544Gilbert09 wants to merge 2 commits into
Gilbert09 wants to merge 2 commits into
Conversation
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
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
Prompt To Fix All With AIFix 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 |
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
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.
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.
Alert.alertconfirm — titleArchive 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.How
features/tasks/utils/archiveGuard.ts:isTaskRunning(task)— true whenlatest_run.statusis non-terminal (reuses the existingisTerminalStatus).confirmArchiveRunningTask(taskTitle, onConfirm)— thinAlert.alertwrapper.SwipeableTaskItemcalls the guard in its swipe-release handler before sliding the row off.Matches the mobile convention of native
Alert.alertconfirms (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.tscoveringisTaskRunning(running for non-terminal statuses, not running for terminal / no run) andconfirmArchiveRunningTask(confirm archives, cancel does not). Full mobile tasks suite passes (74 tests); lint clean; typecheck introduces no new errors.