feat(canvas): per-channel CONTEXT.md replacing Settings entry#2589
Conversation
Wires the desktop folder-instructions endpoints (PostHog/posthog#61494) into a per-channel CONTEXT.md entry in the channels sidebar, replacing the placeholder Settings option. Clicking opens a deep-linkable route with rendered/edit toggle; save publishes a new version with optimistic concurrency; a version dropdown surfaces history. Refetches on every mount so the view reflects edits made by other users or agents. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
| size="1" | ||
| variant="solid" | ||
| onClick={onSave} | ||
| disabled={isPublishing || (!hasDraft && hasInstructions)} |
There was a problem hiding this comment.
Saving empty content is possible when the user manually switches to edit mode via the SegmentedControl (bypassing the EmptyState "Create CONTEXT.md" button). In that case
hasDraft is false and hasInstructions is false, so disabled evaluates to false, and clicking "Save new version" publishes an empty string. After the save, hasInstructions is still false (empty string trims to nothing), so the component re-renders the EmptyState — creating a ghost version with no content.
| disabled={isPublishing || (!hasDraft && hasInstructions)} | |
| disabled={isPublishing || (hasInstructions ? !hasDraft : draft.trim().length === 0)} |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ui/src/features/canvas/components/WebsiteContext.tsx
Line: 234
Comment:
Saving empty content is possible when the user manually switches to edit mode via the SegmentedControl (bypassing the EmptyState "Create CONTEXT.md" button). In that case `hasDraft` is `false` and `hasInstructions` is `false`, so disabled evaluates to `false`, and clicking "Save new version" publishes an empty string. After the save, `hasInstructions` is still `false` (empty string trims to nothing), so the component re-renders the EmptyState — creating a ghost version with no content.
```suggestion
disabled={isPublishing || (hasInstructions ? !hasDraft : draft.trim().length === 0)}
```
How can I resolve this? If you propose a fix, please make it concise.…xist Greptile noticed: user can switch to edit mode via SegmentedControl with no prior version and no draft, hitting Save publishes an empty string and re-renders the EmptyState — a ghost v1 with no body. Require non-whitespace draft when there are no instructions yet; preserve no-op-on-clean-edit when a version already exists.
|
React Doctor could not complete this scan.
Reviewed by React Doctor for commit |
video desc
https://www.loom.com/share/84096ec91e3143dca32d70390bffc2ec
Summary
useFolderInstructionshook +WebsiteContextview: rendered/edit toggle, save publishes a new version with optimistic concurrency, version dropdown surfaces history.Notes
latestendpoint today) — selecting an older version shows its metadata and a callout.mainafter the canvas refactor.Test plan
/settingsURL no longer resolves; route gone from generated tree.🤖 Generated with Claude Code