Skip to content

refactor(canvas): move freeform authoring contract to @posthog/shared#3601

Open
adboio wants to merge 1 commit into
mainfrom
posthog-code/canvas-shared-refactor
Open

refactor(canvas): move freeform authoring contract to @posthog/shared#3601
adboio wants to merge 1 commit into
mainfrom
posthog-code/canvas-shared-refactor

Conversation

@adboio

@adboio adboio commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Problem

working on some canvas generation improvements; need to be able to pass canvas instructions to system prompt

Changes

moving some canvas instruction prompting to @posthog/shared

How did you test this?

Automatic notifications

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

@trunk-io

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

adboio commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 72f3e5a.

@adboio
adboio force-pushed the posthog-code/canvas-shared-refactor branch 2 times, most recently from 3b038cd to f73be5a Compare July 20, 2026 19:56
@adboio
adboio marked this pull request as ready for review July 20, 2026 19:57
@adboio adboio added the Stamphog This will request an autostamp by stamphog on small changes label Jul 20, 2026 — with Graphite App
@adboio
adboio requested a review from a team July 20, 2026 19:57

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR modifies package.json exports and the tsup build config in @posthog/shared, which triggered the deps_toolchain gate. These are build infrastructure changes that require a human reviewer to verify the new package entrypoints are correctly wired before merging.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 20, 2026
@greptile-apps

greptile-apps Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/shared/src/canvas-freeform-prompt.ts:26
**Conflicting Canvas Output Contract**

The canvas task is repo-less and publishes complete source through `desktop-file-system-canvas-partial-update`, but this line now tells the agent to maintain a working file with editing tools. It also conflicts with the later instruction not to edit files and to return a fenced block, so the agent can follow the wrong output path and finish without publishing the canvas.

```suggestion
  "- Produce the COMPLETE single-file React source using the publishing mechanism specified by the caller. Do not write or edit files on disk.",
```

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

"",
"OUTPUT FORMAT — the app is ONE complete file:",
"- The file MUST `export default` a single React component that takes no props.",
"- Maintain it as a working file with your file-editing tools: seed it once, then apply changes as TARGETED edits. Do not regenerate the whole file for a small change, and do not paste the source into chat — a short sentence describing the change is enough.",

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 Conflicting Canvas Output Contract

The canvas task is repo-less and publishes complete source through desktop-file-system-canvas-partial-update, but this line now tells the agent to maintain a working file with editing tools. It also conflicts with the later instruction not to edit files and to return a fenced block, so the agent can follow the wrong output path and finish without publishing the canvas.

Suggested change
"- Maintain it as a working file with your file-editing tools: seed it once, then apply changes as TARGETED edits. Do not regenerate the whole file for a small change, and do not paste the source into chat — a short sentence describing the change is enough.",
"- Produce the COMPLETE single-file React source using the publishing mechanism specified by the caller. Do not write or edit files on disk.",
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/shared/src/canvas-freeform-prompt.ts
Line: 26

Comment:
**Conflicting Canvas Output Contract**

The canvas task is repo-less and publishes complete source through `desktop-file-system-canvas-partial-update`, but this line now tells the agent to maintain a working file with editing tools. It also conflicts with the later instruction not to edit files and to return a fenced block, so the agent can follow the wrong output path and finish without publishing the canvas.

```suggestion
  "- Produce the COMPLETE single-file React source using the publishing mechanism specified by the caller. Do not write or edit files on disk.",
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Relocate the freeform canvas authoring contract — the system-prompt builder
(freeformSystemPromptFor), the import whitelist, the starter scaffold, and the
freeform template id — from @posthog/core into @posthog/shared, so @posthog/agent
can consume it (for the canvas_checkout tool) without a core↔agent package cycle.

Pure move: @posthog/core/canvas/{canvasTemplates,freeformSchemas,freeformWhitelist,
freeformStarter} now re-export from @posthog/shared, so existing consumers are
unchanged.

Generated-By: PostHog Code
Task-Id: 2ed89933-091b-446c-af91-5cc72d939b3b
@adboio
adboio force-pushed the posthog-code/canvas-shared-refactor branch from f73be5a to 72f3e5a Compare July 20, 2026 20:49
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