Skip to content

feat(editing): pre-load a message into edit mode via editing.initialTarget#136

Merged
StephenTangCook merged 1 commit into
mainfrom
feat/editing-initial-target
Jul 2, 2026
Merged

feat(editing): pre-load a message into edit mode via editing.initialTarget#136
StephenTangCook merged 1 commit into
mainfrom
feat/editing-initial-target

Conversation

@StephenTangCook

Copy link
Copy Markdown
Contributor

What

Adds an optional editing.initialTarget prop so a host can boot BlockKitchen straight into edit mode at mount, skipping the load dialog.

Answers the question "can block-kitchen take a pre-loaded Slack message and open in edit mode?" — previously initialBlocks only seeded a blank-canvas draft (no channel/ts lock, no update path); the only way into true edit mode was the user pasting a permalink or picking a recent message.

API

initialTarget reuses the ok: true branch of the existing LoadResult — the same shape the host already returns from onLoadMessage on success — so there's no new type to learn:

export interface EditingConfig {
  onLoadMessage: (input: LoadMessageInput) => Promise<LoadResult>;
  onUpdate: (payload: UpdatePayload) => Promise<UpdateResult>;
  loadRecentMessages?: (channelId: string) => Promise<RecentMessage[]>;
  initialTarget?: Extract<LoadResult, { ok: true }>; // new
}

Usage:

<BlockKitchen
  editing={{
    onLoadMessage,
    onUpdate,
    initialTarget: {
      ok: true,
      channelId: 'C0123',
      ts: '1699999999.000100',
      blocks: preloadedBlocks,
      editableVia: 'bot',
      channelName: 'general',
    },
  }}
/>

Behavior

  • Read once at mount, like initialBlocks (changing it later needs a remount).
  • Its blocks seed the draft and win over initialBlocks (the blank-canvas seed).
  • If both initialBlocks and editing.initialTarget are given, we console.warn and ignore initialBlocks rather than merging or throwing.

Tests

New test/block-kitchen-initial-target.test.tsx:

  • boots into edit mode (edit-mode banner renders) when initialTarget is set
  • warns + prefers the target's blocks when initialBlocks is also provided

Full suite green (373 tests), typecheck + biome clean.

🤖 Generated with Claude Code

…arget

Add an optional `editing.initialTarget` prop (the `ok: true` branch of
`LoadResult`) that boots BlockKitchen straight into edit mode at mount,
skipping the load dialog. Its `blocks` seed the draft and win over
`initialBlocks`; when both are given we warn and ignore `initialBlocks`.

Read once at mount, like `initialBlocks`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
block-kitchen a7ed7e8 Commit Preview URL

Branch Preview URL
Jul 01 2026, 11:09 PM

@StephenTangCook StephenTangCook merged commit aa73bf6 into main Jul 2, 2026
13 checks passed
@StephenTangCook StephenTangCook deleted the feat/editing-initial-target branch July 2, 2026 00:08
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