Skip to content

feat(chat): add initialOption and option_groups to ExternalSelect#410

Merged
bensabic merged 2 commits into
mainfrom
josh/external-select-enhancements
Apr 27, 2026
Merged

feat(chat): add initialOption and option_groups to ExternalSelect#410
bensabic merged 2 commits into
mainfrom
josh/external-select-enhancements

Conversation

@dancer
Copy link
Copy Markdown
Collaborator

@dancer dancer commented Apr 21, 2026

summary

follow-up to #397 (external_select implementation)

  • add initialOption prop to ExternalSelect for pre-selecting a value when the modal opens (edit flows)
  • add OptionsLoadGroup type so onOptionsLoad handlers can return grouped options with headers
  • Slack adapter maps initialOption to initial_option and groups to option_groups per Slack's API
  • all new fields are optional - no breaking changes

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview, Comment, Open in v0 Apr 27, 2026 11:32pm
chat-sdk-nextjs-chat Ready Ready Preview, Comment, Open in v0 Apr 27, 2026 11:32pm

@bensabic bensabic force-pushed the josh/external-select-enhancements branch from 46566fe to 5e5d305 Compare April 27, 2026 23:31
@bensabic bensabic merged commit 70281dc into main Apr 27, 2026
10 of 12 checks passed
@bensabic bensabic deleted the josh/external-select-enhancements branch April 27, 2026 23:32
patrick-chinchill added a commit to Chinchill-AI/chat-sdk-python that referenced this pull request May 11, 2026
, #397) (#84)

* feat(externalselect): add initialOption + option_groups (vercel/chat#410, #397)

Ports two upstream PRs that together complete ExternalSelect support:

- vercel/chat#397 introduced ExternalSelectElement and the
  block_suggestion / onOptionsLoad runtime; the runtime half landed
  here in #66 but the modal element type was deferred. This PR adds
  the missing ExternalSelectElement TypedDict + ExternalSelect builder
  and wires up _external_select_to_block in the Slack modal renderer.
- vercel/chat#410 adds two new optional fields on top: initialOption
  (pre-selected option object) and option_groups (labeled sections,
  Slack max 100 groups x 100 options, label max 75 chars). The
  handler return type widens to OptionsLoadResult = list[options] |
  list[OptionsLoadGroup]; the Slack adapter detects grouped form by
  the presence of an "options" key on the first entry and emits
  Slack's option_groups response (mutually exclusive with options
  per Slack's spec).

Hazard #1 (truthiness): min_query_length=0 is preserved (0 means
"fire on every keystroke"); not silently dropped by an `or` fallback.

Hazard #7 (omit vs None): unset initial_option / placeholder /
min_query_length are omitted from the rendered Block Kit element,
not serialized as null.

https://claude.ai/code/session_01FyMxQn2BEAzmwKS1GZczKj

* fix(slack): use is-not-None guard for initial_option in external_select renderer

Address review on PR #84 (modals.py:209). The TS expression
``if (select.initialOption)`` only filters null/undefined since ``{}`` is
truthy in JS. Python ``if initial_option:`` falsely drops a
hand-constructed ``initial_option={}`` because empty dicts are falsy.
Switch to ``is not None`` for parity with TS and consistency with the
``min_query_length is not None`` check three lines above.

Adds test_external_select_initial_option_empty_dict_renders regression
test that fails before the fix.

https://claude.ai/code/session_01FyMxQn2BEAzmwKS1GZczKj

---------

Co-authored-by: Claude <noreply@anthropic.com>
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