Skip to content

feat: persist pending task prompts and recover it on failure#3053

Merged
jonathanlab merged 3 commits into
mainfrom
posthog-code/prevent-task-prompts-from-being-lost
Jul 1, 2026
Merged

feat: persist pending task prompts and recover it on failure#3053
jonathanlab merged 3 commits into
mainfrom
posthog-code/prevent-task-prompts-from-being-lost

Conversation

@jonathanlab

@jonathanlab jonathanlab commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Persist our prompt during task creation, so a hang/app crash/task creation failure won't lose it


Created with PostHog Code

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 24fb91f.

@jonathanlab jonathanlab changed the title feat: persist pending task prompts and enable recovery on failure feat: persist pending task prompts and recover it on failure Jul 1, 2026
@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat: persist pending task prompts and e..." | Re-trigger Greptile

Comment thread packages/ui/src/features/task-detail/hooks/useTaskCreation.ts Outdated
Comment thread packages/ui/src/shell/pendingTaskPromptStore.ts Outdated
Address PR review:
- The success-path clear used `"provisioningError" in result`, but the
  field lives at `result.data.provisioningError`, so the guard was always
  false and cleared the durable prompt even when provisioning failed.
  Use the real path so a kept-but-unprovisioned task keeps its prompt for
  recovery.
- Bound `pending-task-prompts` storage with a fixed cap (20), evicting the
  oldest beyond it and logging the drop, so orphaned prompts can't grow
  unbounded in electronStorage.

Generated-By: PostHog Code
Task-Id: bb024b86-4ac5-4ec6-87af-3d8809d28466
persist calls onRehydrateStorage with state=undefined on a hydration
error, so setHasHydrated was never called and whenHydrated() (and the
recovery flow that awaits it) would hang forever. Flip the hydrated flag
via getState() on error too, so recovery proceeds even if the persisted
prompts can't be read.

Generated-By: PostHog Code
Task-Id: bb024b86-4ac5-4ec6-87af-3d8809d28466
@jonathanlab jonathanlab merged commit 9c9dc51 into main Jul 1, 2026
23 checks passed
@jonathanlab jonathanlab deleted the posthog-code/prevent-task-prompts-from-being-lost branch July 1, 2026 13:06
frankh added a commit that referenced this pull request Jul 1, 2026
#3054 added kill-timeouts to `git worktree add` and the post-checkout hook,
and #3053 restructured the saga to clear the provisioning spinner and keep the
task for retry when provisioning fails. Both landed on main and supersede the
worktree-add/hook-timeout and spinner-clearing parts of this PR, so those are
dropped here.

The one hang path neither covered is the `git fetch` that precedes worktree
creation — the trigger both fixes cited. It still runs unbounded inside the
per-repo write lock, so a blocked fetch (network stall, unreachable remote)
never settles, the lock is never released, and every later worktree creation
for that repo queues behind it forever.

Bound the two fetch call sites (resolveFreshBaseRef and
createWorktreeForRemoteBranch) with a timeout. The fetch runs through
simple-git rather than a raw spawn, so it can't use armProcessTimeout; instead
it aborts via the AbortSignal executeWrite already forwards to its scoped git
client, which kills the fetch subprocess and releases the write lock. On
timeout the trunk path degrades to the local ref and the remote-branch path
fails with a retryable error, rather than hanging.
Gilbert09 added a commit that referenced this pull request Jul 2, 2026
#3053)

Ports desktop #3053 to the mobile app so a user's typed new-task prompt is
never silently lost when task creation fails or the app is killed mid-flight.

- Add a separate AsyncStorage-backed `pendingPromptRecoveryStore` (distinct
  from the transient in-memory echo store, whose entries must vanish when the
  live SSE copy lands). Records a prompt when creation begins, clears it once
  the task exists or on failure, and caps to the newest 20 entries.
- Add a mount-once `PendingPromptRecovery` component that, after the store
  hydrates, recovers the newest orphaned prompt exactly once per launch and
  routes to the new-task composer pre-filled with it.
- Wire clear-on-success / clear-on-failure into the create flow.

Generated-By: PostHog Code
Task-Id: 398f655d-ec85-4295-99cd-585d3debfd17
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.

3 participants