Clear channel composer instantly and show optimistic kickoff in feed - #3350
Conversation
|
😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
tested locally, it works |
|
Reviews (1): Last reviewed commit: "Scroll the channel feed to the bottom on..." | Re-trigger Greptile |
| // optimistic card and give the prompt back so the user can retry. | ||
| onPendingEnd(id); | ||
| pendingIdRef.current = null; | ||
| editor.setContent(prompt); |
There was a problem hiding this comment.
Structured Prompt Content Is Lost
When task creation fails after a prompt with mention or file chips, this restores only the flattened contentToPlainText string. The retry prompt keeps the visible @label text but loses the chip ids and metadata, so the next submit no longer sends the same structured references.
| if (pendingIdRef.current) { | ||
| onPendingEnd(pendingIdRef.current); | ||
| pendingIdRef.current = null; |
There was a problem hiding this comment.
| queryClient.setQueryData<Task[]>( | ||
| channelFeedQueryKey(backendChannel?.id), | ||
| (old) => insertTaskDedup(old, task) ?? old, | ||
| ); |
There was a problem hiding this comment.
When the channel feed query has not populated yet, old is undefined and insertTaskDedup(old, task) also returns undefined. The pending row is removed on success, but the real task is not inserted into the cache, so the feed falls back to waiting for the refetch instead of showing the created card immediately.
There was a problem hiding this comment.
Clean optimistic UI addition in the UI layer only — no data model, API contract, or infra changes. Key correctness invariants verified: handleSubmit returns Promise<boolean> (failure check is sound), insertTaskDedup handles undefined cache correctly, and error path restores editor content.
New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.
There was a problem hiding this comment.
Purely additive optimistic-UI change in the feed layer — no API contracts, data models, or infra touched. All three bot comments are addressed in the current diff: the empty-cache case uses a ternary guard before calling insertTaskDedup, failure recovery restores the full structured content object, and the pending-ID tracking uses a FIFO array rather than a single ref.
…croll (rebased on main) Resolved version of PR #3350 rebased onto current main. Reconciles the optimistic-clear / pending-kickoff / self-post-scroll feature with main's newly-added canvas-mode generation in the channel composer (both now coexist), and drops two prompt/origin helper functions that main's feed presentation superseded. Squashed single commit so it can be force-applied onto the PR branch: git push --force origin posthog-code/channel-composer-instant-clear-merged:posthog-code/channel-composer-instant-clear Generated-By: PostHog Code Task-Id: 20f9fe72-9b7b-44bb-9fde-75f94be4b6ee
5d19790 to
687ec71
Compare
New commits pushed (delta classified non_linear_history) — stamphog approval dismissed; re-review running automatically.
|
/trunk merge |
1 similar comment
|
/trunk merge |
…croll (rebased on main) Re-resolved version of PR #3350 on top of current main. Reconciles the optimistic-clear / pending-kickoff / self-post-scroll feature with main's newly added Slack-style channel intro + system feed messages: the feed now interleaves tasks and system rows by timestamp (main) while still appending optimistic "Starting…" pending rows and following the user's own posts to the bottom (this PR). WebsiteChannelHome keeps both the pending state and main's context.md onboarding dialog. Single squashed commit so it can be force-applied onto the PR branch. Generated-By: PostHog Code Task-Id: 20f9fe72-9b7b-44bb-9fde-75f94be4b6ee
687ec71 to
66321bf
Compare
New commits pushed (delta classified non_linear_history) — stamphog approval dismissed; re-review running automatically.
There was a problem hiding this comment.
All three previously flagged bot concerns are addressed in the current diff: empty-cache seeding uses a ternary guard, failure recovery restores the full structured content snapshot, and pending IDs use a FIFO array. No data models, API contracts, or infra are touched.
|
/trunk merge |
|
An error occurred while submitting your PR to the queue: |
Problem
In a Bluebird channel, submitting a task had a visible lag: the composer only cleared and the card only appeared after the task-creation round trip (and its feed invalidate/refetch) resolved. Because the input still showed the typed prompt, it looked like the keystroke hadn't registered, so people pressed enter twice.
Why: Raquel reported hitting enter twice because the input didn't clear and the message didn't show up in the channel messages immediately — the ask was to clear the input right away, surface the message in the feed instantly, and show a loading state while the task actually "takes" rather than leaving text sitting in the box.
Changes
handleSubmitas an override so clearing early can't race the content read.Scoped to the channel feed surface (
WebsiteChannelHome/ChannelHomeComposer/ChannelFeedView).How did you test this?
pnpm --filter @posthog/ui typecheck— passes.biome checkon the changed files — passes.Automatic notifications
Created with PostHog Code