Roll surfaced task out of the UI when creation fails after onTaskReady - #4018
Closed
adboio wants to merge 2 commits into
Closed
Roll surfaced task out of the UI when creation fails after onTaskReady#4018adboio wants to merge 2 commits into
adboio wants to merge 2 commits into
Conversation
The creation saga fires onTaskReady before its final steps (agent session connect, cloud run), so a late failure rolls back a task the UI already spliced into the channel feed, task lists, and the detail cache. The prompt returned to the composer, but the feed kept a card pointing at a deleted task whose detail page fell through to the "Select a repository folder" prompt. TaskService now tracks the surfaced task and fires a new TaskCreationEffects.onCreateRolledBack on failure; the shared impl cancels in-flight refetches, removes the task from list/feed caches, and drops the detail entry so the route's 404 handling redirects instead of rendering the dead task. useTaskCreation exposes onTaskCreationFailed so WebsiteNewTask can return a user parked on the dead task's page to the composer with their prompt. Generated-By: PostHog Code Task-Id: d7169be9-8012-4434-a325-c578adac0458
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found 1 issue in 1 file · 1 warning. 1 warning
Reviewed by React Doctor for commit |
A failed creation can leave the task row behind: the saga's rollback delete is swallowed on failure, and a create-request timeout commits server-side with nothing to roll back. Such a task legitimately reappears in the feed (it exists), and opening it dead-ended on "Select a repository folder" — a repo-less task has no repo to map, so hasDirectoryMapping is永false and the picker never made sense. Provision the scratch dir on open instead, the same way creation does: TaskLogsPanel ensures it when a local repo-less task resolves no cwd (the folder picker remains only as the fallback if provisioning errors), and navigationTaskBinder does the same on the imperative openTask path. The workspace server already synthesizes scratch dirs into getAll, so the session resolves the new dir as its cwd. Generated-By: PostHog Code Task-Id: d7169be9-8012-4434-a325-c578adac0458
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
When task creation fails partway through, the prompt correctly returns to the channel composer — but the message can stay in the feed looking like a normal kickoff, and clicking its card lands on a task page that just says "Select a repository folder".
The creation saga fires
onTaskReadybefore its final steps (agent session connect), so the UI splices the real task card into the channel feed, seeds the task lists, and caches the task detail before creation has actually settled. A late failure then produces one of two states:Why
Raised by Adam in the code channel: a failed create left a normal-looking message in the feed whose card led to a confusing "select a repo folder" page, even though the prompt had correctly bounced back to the input box — and the card survived an app restart.
Changes
TaskService.createTasktracks the task surfaced viaonTaskReadyand fires a newTaskCreationEffects.onCreateRolledBack(task)when the saga then fails. The shared effects impl cancels in-flight list/feed refetches, removes the task from task-list and channel-feed caches, drops the detail cache entry (so the route's existing 404 handling redirects), and invalidates both roots — so server truth settles either way: a deleted task disappears, a surviving one comes back as a real row.TaskLogsPanel(feed-card navigation) andnavigationTaskBinder(imperativeopenTask). The folder picker remains only as the fallback if scratch provisioning errors, and is untouched for repo-linked tasks. A surviving orphan now opens into a working session instead of the picker.useTaskCreationgains anonTaskCreationFailed(task, promptText)callback (forwarded throughTaskInput);WebsiteNewTaskuses it to return a user parked on the dead task's page to the composer with their prompt.How did you test this?
TaskServicefires/skipsonCreateRolledBack(fails-after-surface, success, fails-before-surface); effects impl removes the task from list/feed/detail caches and marks them stale;WebsiteNewTaskreturns the user to the composer only when still parked on the dead task;useEnsureScratchWorkspaceprovisions once, invalidates workspaces, and doesn't loop on failure;navigationTaskBinderprovisions scratch only for repo-less tasks with no workspace.@posthog/core(242 files) and@posthog/ui(284 files) pass;pnpm typecheckclean across the workspace;biome lint packages/corereports zeronoRestrictedImports.Automatic notifications
Created with PostHog Code