feat(channels): add Canvas mode to the channel composer's mode selector#3348
Conversation
The move to the channel feed + tab view lost the prompt-to-canvas entry the old channel landing had. Add a "Canvas" toggle to the composer's mode selector (mirroring Autoresearch): while armed, submitting the prompt creates a freeform canvas in the channel, kicks off generation, and opens it. Generated-By: PostHog Code Task-Id: e556b691-318b-4472-8771-d397fc3d221d
|
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 no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Reuse trackAndCreateCanvas + toastError for the composer's canvas create, collapse ModeSelector's duplicated toggle refs/items into one data-driven list, unify the composer's submit branch (TaskInput idiom), move analytics out of the state updater, pass the parent-fetched channel context into useGenerateFreeformCanvas to skip its duplicate fetch, and destructure generate() opts once. Generated-By: PostHog Code Task-Id: e556b691-318b-4472-8771-d397fc3d221d
Fixes the React Doctor only-export-components warning on NewCanvasMenu.tsx by moving the CreateSurface type and trackAndCreateCanvas helper to a plain module. Generated-By: PostHog Code Task-Id: e556b691-318b-4472-8771-d397fc3d221d
|
Reviews (1): Last reviewed commit: "refactor(canvas): move trackAndCreateCan..." | Re-trigger Greptile |
| useStarter: true, | ||
| }); | ||
| if (!taskId) return; | ||
| editorRef.current?.clear(); | ||
| setCanvasArmed(false); | ||
| void navigate({ |
There was a problem hiding this comment.
Generation Link Failure Is Hidden
When canvas generation creates the task but fileTask or setGenerationTask fails inside generateCanvas, this branch still receives a taskId, clears the prompt, disarms Canvas mode, and navigates to the new canvas. The user can end up on a canvas whose running generation is not linked or filed in the channel feed, with no way to recover the submitted prompt from this composer.
| pendingValueRef.current = null; | ||
| // Picking a plain mode leaves canvas mode; the two are exclusive. | ||
| if (canvasActive) canvas?.onToggle(); |
There was a problem hiding this comment.
Selecting a plain mode while Canvas is active disarms it by calling canvas.onToggle(), but that callback flips state rather than setting Canvas off. If the menu close callback runs after Canvas was already turned off by another state update, or the user selects the underlying current mode during a stale close sequence, this can arm Canvas again and make the next submit generate a canvas instead of a normal task.
Problem
Since the move to the new channel UX (feed composer + Home/History/Artifacts tabs), the prompt-to-canvas entry the old channel landing had is gone — the only way to generate a canvas is the "New canvas" button, which opens an empty canvas first.
Changes
Canvas generation is now a mode in the channel composer's mode selector, following the existing Autoresearch pattern:
ModeSelector/PromptInputgain an optional "Canvas" toggle; while armed the trigger reads "Canvas", and picking a plain mode disarms it.ChannelHomeComposer, submitting with Canvas armed creates a freeform canvas in the channel, kicks off generation from the prompt (filed to the channel feed like other generation runs), and navigates to the canvas. Model/reasoning/workspace pickers hide while armed since generation resolves its own model and always runs in the cloud.useGenerateFreeformCanvasnow takes the dashboard pergenerate()call so the composer can create the canvas at submit time.Channel action/Dashboard actionevents (newcanvas_mode_toggleaction type). Whole surface remains behind the project-bluebird flag.How did you test this?
pnpm --filter @posthog/ui typecheckandpnpm --filter @posthog/shared typecheckModeSelectortest covering the armed trigger state.Automatic notifications
Created with PostHog Code