Skip to content

feat: compose-only mode — optional send integration + onValidationChange#138

Draft
StephenTangCook wants to merge 1 commit into
mainfrom
claude/slack-editor-audience-boundary-uykjuy
Draft

feat: compose-only mode — optional send integration + onValidationChange#138
StephenTangCook wants to merge 1 commit into
mainfrom
claude/slack-editor-audience-boundary-uykjuy

Conversation

@StephenTangCook

Copy link
Copy Markdown
Contributor

Summary

Makes the send integration optional as a group: provide loadChannels / loadSendAsUserStatus / onSend for the built-in send flow (unchanged), or omit all three and the builder renders no send button — a pure Block Kit editor whose host app owns the send flow. Adds onValidationChange so a host-rendered CTA can gate on the exact validation verdict the issues sheet shows.

Why

When composing is one step in a flow the host app owns (audience selection, scheduling, multi-channel fan-out), the moment of commitment belongs outside the builder — but today the send trio is required and the "Review & send" button can't be removed, forcing either a dual-CTA UX or CSS hacks. The host also had no access to the builder's validation verdict, so an external CTA would have to re-run the validator and risk drifting from what the issues sheet displays.

Design choices:

  • All-or-nothing, not individually optional. BlockKitchenProps is now BlockKitchenBaseProps & (BlockKitchenSendProps | BlockKitchenComposeOnlyProps); the compose-only branch pins the trio (and editing) to undefined. Wiring only some of the three is a type error rather than a silently dead send button. Runtime console.warns cover untyped JS consumers. Fully backward compatible for existing consumers.
  • editing requires the trio. chat.update is inherently bound to a channel + timestamp, so the update flow only exists alongside the send integration.
  • onValidationChange fires on verdict change only (piggybacking the builder's debounced validation pass, deduped against the last-notified verdict), always scoped to the message surface — the same verdict the issues chip/sheet displays.

New exports: ValidationSummary, BlockKitchenBaseProps, BlockKitchenSendProps, BlockKitchenComposeOnlyProps. README gains a "Compose-only mode (bring your own send flow)" section with a wizard-step example.

Test plan

  • pnpm typecheck
  • pnpm lint
  • pnpm test (379 tests, 30 files — includes browser-mode Storybook tests)
  • pnpm build

New tests in test/block-kitchen-compose-only.test.tsx:

  • compose-only render hides the send button, rest of toolbar intact
  • send trio wired → send button renders as before
  • onValidationChange reports { valid: true, errorCount: 0, errors: [] } for a valid draft and a non-empty error list for an invalid one
  • partial wiring warns and hides the send button; editing without the trio warns and is ignored
  • @ts-expect-error assertions (enforced by pnpm typecheck) pin the all-or-nothing union

Notes for reviewer

  • BlockKitchen destructures through a Base & Partial<Send> widening cast: TS's correlated-union narrowing otherwise flags the runtime guards as "always true" (TS2774), and the guards must exist for untyped consumers anyway.
  • The Storybook meta now pins the send-enabled branch (Meta<SendModeProps>) because arg inference collapses the props union to never.
  • Toolbar gains a showSend prop (default true), so the compose-only path is a no-op for every existing usage.

🤖 Generated with Claude Code

https://claude.ai/code/session_01J2JGjyg1LC9RxdjBFR8oeJ


Generated by Claude Code

Split BlockKitchenProps into a shared base plus an all-or-nothing send
integration union: provide loadChannels/loadSendAsUserStatus/onSend for
the built-in send flow, or omit all three and the builder renders no send
button, becoming a pure editor whose host owns the send flow. Partial
wiring is a type error (and a runtime console warning for JS consumers);
`editing` requires the trio since chat.update is channel-bound.

Add onValidationChange, reporting { valid, errorCount, errors } whenever
the draft's verdict changes — the exact verdict the issues sheet shows,
validated against the message surface — so a host-rendered CTA can gate
on validity without re-running the validator and risking drift.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J2JGjyg1LC9RxdjBFR8oeJ
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 2, 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 4484967 Commit Preview URL

Branch Preview URL
Jul 02 2026, 12:35 AM

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