feat: compose-only mode — optional send integration + onValidationChange#138
Draft
StephenTangCook wants to merge 1 commit into
Draft
feat: compose-only mode — optional send integration + onValidationChange#138StephenTangCook wants to merge 1 commit into
StephenTangCook wants to merge 1 commit into
Conversation
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
Contributor
Deploying with
|
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the send integration optional as a group: provide
loadChannels/loadSendAsUserStatus/onSendfor 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. AddsonValidationChangeso 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:
BlockKitchenPropsis nowBlockKitchenBaseProps & (BlockKitchenSendProps | BlockKitchenComposeOnlyProps); the compose-only branch pins the trio (andediting) toundefined. Wiring only some of the three is a type error rather than a silently dead send button. Runtimeconsole.warns cover untyped JS consumers. Fully backward compatible for existing consumers.editingrequires the trio.chat.updateis inherently bound to a channel + timestamp, so the update flow only exists alongside the send integration.onValidationChangefires on verdict change only (piggybacking the builder's debounced validation pass, deduped against the last-notified verdict), always scoped to themessagesurface — 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 typecheckpnpm lintpnpm test(379 tests, 30 files — includes browser-mode Storybook tests)pnpm buildNew tests in
test/block-kitchen-compose-only.test.tsx:onValidationChangereports{ valid: true, errorCount: 0, errors: [] }for a valid draft and a non-empty error list for an invalid oneeditingwithout the trio warns and is ignored@ts-expect-errorassertions (enforced bypnpm typecheck) pin the all-or-nothing unionNotes for reviewer
BlockKitchendestructures through aBase & 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.Meta<SendModeProps>) because arg inference collapses the props union tonever.Toolbargains ashowSendprop (defaulttrue), 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