-
Notifications
You must be signed in to change notification settings - Fork 1
feat(chat): port onOptionsLoad handler (#50) #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
752ef84
feat(chat): port onOptionsLoad handler + Slack block_suggestion dispatch
patrick-chinchill 46f3314
fix(options-load): address review feedback on PR #66
patrick-chinchill 7924464
fix(options-load): register timed-out block_suggestion task with wait…
patrick-chinchill 8fc713a
fix(options-load): guard wait_until on timeout path so webhook still …
patrick-chinchill ace58cd
docs(options-load): clarify that [] short-circuits handlers (upstream…
patrick-chinchill 006027e
test(options-load): clean up orphaned slow task in timeout test
patrick-chinchill 1776b7d
fix(slack): restore or-chain for user_name/full_name to match upstream
patrick-chinchill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| from chat_sdk.cards import CardElement | ||
| from chat_sdk.errors import ChatNotImplementedError | ||
| from chat_sdk.logger import Logger, LogLevel | ||
| from chat_sdk.modals import SelectOptionElement | ||
|
|
||
|
|
||
| def _parse_iso(s: str) -> datetime: | ||
|
|
@@ -987,6 +988,22 @@ async def open_modal(self, modal: Any) -> dict[str, str] | None: | |
| return None | ||
|
|
||
|
|
||
| @dataclass | ||
| class OptionsLoadEvent: | ||
| """Event emitted when an adapter needs dynamic options for an external select. | ||
|
|
||
| Port of upstream TS ``OptionsLoadEvent``. Slack dispatches a | ||
| ``block_suggestion`` payload to populate an external-select menu; the | ||
| handler returns the matching options for the current query text. | ||
| """ | ||
|
|
||
| action_id: str | ||
| adapter: Adapter | ||
| query: str | ||
| user: Author | ||
| raw: Any = None | ||
|
|
||
|
|
||
| @dataclass | ||
| class ModalSubmitEvent: | ||
| """Modal form submission event.""" | ||
|
|
@@ -1348,6 +1365,9 @@ def process_slash_command(self, event: Any, options: WebhookOptions | None = Non | |
| def process_modal_submit( | ||
| self, event: Any, context_id: str | None = None, options: WebhookOptions | None = None | ||
| ) -> Awaitable[ModalResponse | None]: ... | ||
| def process_options_load( | ||
| self, event: OptionsLoadEvent, options: WebhookOptions | None = None | ||
| ) -> Awaitable[list[SelectOptionElement] | None]: ... | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive — standard |
||
| def process_modal_close( | ||
| self, event: Any, context_id: str | None = None, options: WebhookOptions | None = None | ||
| ) -> None: ... | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
block_suggestiontimes out, the handler task is only pinned in-process and immediately returned, but it is never passed toWebhookOptions.wait_until. In runtimes that end request work unless tasks are explicitly registered (the same pattern already used elsewhere in this adapter), the timed-outprocess_options_loadtask can be terminated before completion, so the intended late-error logging path may never run. This breaks the commit’s stated timeout behavior specifically in webhook environments that rely onwait_untilfor background work.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 71e2113 — timed-out handler task now registers with
options.wait_until(matching_handle_reaction_eventpattern), then guarded with try/except in 6e96891 in case runtime-provided wait_until raises.