1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! What the model picker last put on screen, per provider.
//!
//! Telegram caps inline-button `callback_data` at 64 bytes, so a model whose
//! name does not fit is encoded as its *position* in the rendered list and
//! resolved back when the button is tapped. That resolution has to see the
//! same list the user was looking at.
//!
//! Config alone used to reconstruct it, because the picker rendered exactly
//! the `models = [...]` array. Now that the list is the config seed unioned
//! with the provider's live inventory (#761), it cannot. And an unresolved
//! index does not fail safe: the caller falls back to the raw token, so a
//! miss would try to select a model literally named `#7`.
//!
//! This deliberately stores what was rendered rather than caching provider
//! state. It answers "what was on screen when that button was drawn", which
//! stays right even if the provider's inventory changes before the tap.
use HashMap;
use ;
static RENDERED: = new;
/// Record the list a provider's picker just rendered, replacing any previous
/// one. Called on every render so the newest menu is the one indices resolve
/// against.
pub
/// Resolve a button's position back to the model name that occupied it.
///
/// `None` when this provider's picker has not rendered in this process (a
/// restart between render and tap), leaving the caller to fall back to config.
pub