Skip to content

feat(channels): add Canvas mode to the channel composer's mode selector#3348

Merged
k11kirky merged 4 commits into
mainfrom
posthog-code/channel-composer-canvas-mode
Jul 10, 2026
Merged

feat(channels): add Canvas mode to the channel composer's mode selector#3348
k11kirky merged 4 commits into
mainfrom
posthog-code/channel-composer-canvas-mode

Conversation

@k11kirky

Copy link
Copy Markdown
Contributor

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/PromptInput gain an optional "Canvas" toggle; while armed the trigger reads "Canvas", and picking a plain mode disarms it.
  • In 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.
  • useGenerateFreeformCanvas now takes the dashboard per generate() call so the composer can create the canvas at submit time.
  • Instrumented with the existing Channel action / Dashboard action events (new canvas_mode_toggle action type). Whole surface remains behind the project-bluebird flag.

How did you test this?

  • pnpm --filter @posthog/ui typecheck and pnpm --filter @posthog/shared typecheck
  • Ran the canvas + message-editor vitest suites (123 tests passing), including a new ModeSelector test covering the armed trigger state.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

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
@trunk-io

trunk-io Bot commented Jul 10, 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 10, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 6eeacd9.

k11kirky added 2 commits July 10, 2026 16:35
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
@k11kirky k11kirky marked this pull request as ready for review July 10, 2026 20:19
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "refactor(canvas): move trackAndCreateCan..." | Re-trigger Greptile

Comment on lines +123 to +128
useStarter: true,
});
if (!taskId) return;
editorRef.current?.clear();
setCanvasArmed(false);
void navigate({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Comment on lines 120 to +122
pendingValueRef.current = null;
// Picking a plain mode leaves canvas mode; the two are exclusive.
if (canvasActive) canvas?.onToggle();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Canvas Disarm Uses A Toggle

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.

@k11kirky k11kirky merged commit 55bd4fd into main Jul 10, 2026
26 checks passed
@k11kirky k11kirky deleted the posthog-code/channel-composer-canvas-mode branch July 10, 2026 20:41
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.

2 participants