Skip to content

feat(sessions): reorder and edit queued messages in place#3242

Draft
gantoine wants to merge 1 commit into
mainfrom
posthog-code/queue-reorder-edit-in-place
Draft

feat(sessions): reorder and edit queued messages in place#3242
gantoine wants to merge 1 commit into
mainfrom
posthog-code/queue-reorder-edit-in-place

Conversation

@gantoine

@gantoine gantoine commented Jul 7, 2026

Copy link
Copy Markdown
Member

What

Two additions to the queued-messages dock (the follow-ups pinned above the composer while a turn is running):

  1. Drag to reorder — each queued card is now draggable. The queue drains in array order, so the order shown is the order the messages send. Uses the existing @dnd-kit/react sortable pattern (same as sidebar folders / browser tabs), with a PointerSensor movement threshold so the card's buttons still take clicks.
  2. Edit in place — the pencil now loads a queued message back into the composer for editing without removing it from the queue. Submitting the edit updates the message where it sits (same id, position, and queue timestamp) instead of appending a new one. If the message already drained or was discarded while being edited, it falls back to sending as a fresh message so nothing is lost. The card being edited is highlighted and gains a cancel (✕) affordance.

Previously the pencil ("return to editor") pulled the message out of the queue entirely; that hook (useReturnQueuedMessageToEditor) is replaced by useEditQueuedMessage / useCancelQueuedMessageEdit.

How

  • coremoveQueuedMessage and updateQueuedMessage store setters; SessionService.updateQueuedMessage mirrors the enqueue normalization (cloud recomputes transport display + raw payload via getCloudPromptTransport; local stores the serialized text).
  • uisessionViewStore tracks the active edit target per task (editingQueuedIdByTaskId); useSessionCallbacks.handleSendPrompt routes to updateQueuedMessage when an edit is in progress; QueuedMessagesDock wires the DragDropProvider + sortable cards and clears a stale edit target if the message leaves the queue.

Testing

  • pnpm --filter @posthog/core typecheck + @posthog/ui typecheck — clean
  • Biome lint — clean
  • New packages/core/src/sessions/sessionQueueEditing.test.ts (9 tests) for the store setters; updated QueuedMessagesDock.test.tsx
  • Full suites: core sessions 267 pass, UI sessions 348 pass

Not yet dogfooded in the running app — happy to do that next.


Created with PostHog Code

Let users drag queued follow-ups to reorder them (the queue drains in
array order, so the order shown is the order they send) and edit a
queued message in the composer without pulling it out of the queue.

- Add moveQueuedMessage and updateQueuedMessage store setters
- Add SessionService.updateQueuedMessage mirroring enqueue normalization
  (cloud recomputes transport display + raw payload; local stores text)
- Track the active edit target in sessionViewStore; the composer's next
  submit updates the message in place, falling back to a fresh send if
  it already drained or was discarded
- Make each queued card a dnd-kit drag handle; highlight the card being
  edited with a cancel affordance

Generated-By: PostHog Code
Task-Id: 96d2978d-909b-4bbf-a45b-44ede597a1b8
@trunk-io

trunk-io Bot commented Jul 7, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

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

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

React Doctor found 1 issue in 1 file · 1 warning.

1 warning

src/features/sessions/components/QueuedMessagesDock.tsx

Reviewed by React Doctor for commit 2e5355e.

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