You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
keep /models favorite/recent callbacks short by using list references instead of embedding provider/model IDs
keep model search result callbacks short by storing the selected models in interaction metadata
add regression coverage for long Fireworks-style model IDs that exceed Telegram callback_data limits
Why
Telegram rejects inline keyboard callback_data values longer than 64 bytes. Long provider/model IDs such as Fireworks deployment paths could make the model menu fail with BUTTON_DATA_INVALID before the user could select anything.
@fengjikui thanks for the fix. One issue before merging:
Stale clicks on result buttons can select a wrong model. After the model-search interaction is cleared (e.g. by the next interactionManager.start()), clicking an already-rendered model:result:0 button reaches handleModelSelect and parseLegacyModelCallback parses it as providerID="result", modelID="0" — and the bogus model gets selected. Pre-PR, the real provider/model were embedded in the callback_data, so stale clicks still worked.
Same shape for model:list:recent:0 reaching handleModelSearchResults (the messageId guard mitigates it, but the legacy branch would otherwise read it as providerID="list", modelID="recent:0").
Could you make the legacy fallbacks reject the new prefixes? E.g. in handleModelSelect, explicitly drop/log model:result: instead of falling through to parseLegacyModelCallback, and exclude model:list: from the fallback in handleModelSearchResults. That way stale clicks fail safe instead of selecting a wrong model.
Thanks for catching that. I pushed c6f1b53 to make the new short callback prefixes fail safe instead of falling through to the legacy parser:
model:result:* is now rejected by handleModelSelect when the search interaction is no longer active, so stale result buttons no longer become providerID="result" / modelID="0".
unresolved model:list:* callbacks no longer fall back to legacy parsing in handleModelSelect.
handleModelSearchResults also rejects short model:list:* / model:result:* prefixes from its legacy fallback path.
Added regression coverage for stale model:result:0, unresolved model:list:recent:0, and the search-results fallback case.
Validation:
npm test -- tests/bot/handlers/model.test.ts (19 tests)
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
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
/modelsfavorite/recent callbacks short by using list references instead of embedding provider/model IDsWhy
Telegram rejects inline keyboard
callback_datavalues longer than 64 bytes. Long provider/model IDs such as Fireworks deployment paths could make the model menu fail withBUTTON_DATA_INVALIDbefore the user could select anything.Fixes #178.
Validation
npx prettier --check src/bot/menus/model-selection-menu.ts src/bot/callbacks/model-selection-callback-handler.ts tests/bot/handlers/model.test.tsnpm test -- --run tests/bot/handlers/model.test.tsnpm run buildnpm run lintnpm testgit diff --check