Repository navigation
fix(skill-reco): prefetch the TUI catalogue so a fresh session can recommend - #816
Merged
Merged
Conversation
…commend The TUI's recommender picks from `catalogue − installed`, and that catalogue was only ever loaded by the `/skills` panel. So in a fresh session the candidate set was empty, `recommendation_gates_pass` refused every message, and the feature silently did nothing until the panel had been opened once — from the user's side, "no recommendation ever appears". Verified against a real TUI: a 19-character question in a session that never opened the panel produced no card, no spinner, no explanation; the message just went out. The desktop client has no such gap: it loads the catalogue when it mounts, i.e. long before a 30-byte draft exists. The TUI now does the equivalent, keyed off the draft instead of the startup: `handle_input_changed` starts a quiet `future skills list --json` the moment a draft could produce a card (length window reached, not a slash command, no `/skill` already picked), so the load runs while the user is still typing — and a session that never writes a recommendable message never pays for the child (which reaches the platform over HTTP, ~0.15 s here). `maybe_recommend_skill` starts it too, for a draft that never went through the input's change callback, and never holds a send for it. The prefetch is quiet by construction: it has its own `UiCmd` because nothing on screen asked for it — success fills the same cache the panel fills, failure is dropped in silence (the panel is where a catalogue problem is reported, and opening it, or `r`, retries). One attempt per session, so a failure cannot turn into a child process per keystroke. `draft_could_be_recommended` is split out of `recommendation_gates_pass` so the prefetch asks the same question the gate asks, instead of a second copy of those four rules that can drift from the first. Verified on a real TUI against an isolated agent: the card (primekg) now appears in a fresh session with the draft held. Four new tests pin the prefetch, its silence on failure, that it waits for a recommendable draft, and that a submit starts it without holding the send; all four fail with the two call sites removed.
huichen
enabled auto-merge (squash)
September 24, 2026 04:10
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.
Why no card ever appeared in a fresh TUI session
The TUI's recommender picks from
catalogue − installed, and that catalogue wasonly ever loaded by the
/skillspanel. A session that had not opened the paneltherefore had an empty candidate set:
recommendation_gates_passrefusedevery message, the Jev call was never made, and the message was sent normally —
no card, no spinner, no explanation.
Reproduced against a real TUI: type
查询一下老年痴呆都有哪些常见的致病基因in asession that never opened
/skills, press Enter → the message is sent straightaway. Direct probe of the gateway with the same question and the same candidate
list answers
primekg 0.68(none0.10, gate0.15), i.e. a card should haveappeared — the TUI simply never asked.
The desktop client has no such gap: it loads the catalogue when it mounts,
long before a 30-byte draft exists.
The fix
The TUI now does the equivalent, keyed off the draft rather than the startup:
handle_input_changedstarts a quietfuture skills list --jsonas soon as adraft could produce a card (same rules the gate uses: the toggle, not a slash
command, inside the length window, no
/skillalready picked) — so the loadruns while the user is still typing. A session that never writes a recommendable
message never pays for the child (it reaches the platform over HTTP; ~0.15 s
here).
maybe_recommend_skillstarts it too, for a draft that never went through theinput's change callback (
-p, a scripted submit). It is never awaited: a sendis not held for a catalogue.
UiCmd::SkillsCataloguePrefetchedbecausenothing on screen asked for the call. Success fills the same cache the panel
fills; failure is dropped, since the panel is where a catalogue problem is
reported (opening it, or
r, retries). One attempt per session, so a failurecannot become a child process per keystroke.
draft_could_be_recommendedis split out ofrecommendation_gates_pass, so theprefetch asks the same question the gate asks instead of a second copy of those
four rules that can drift.
Verification
opened
/skills: type the question, press Enter →Looking for a skill that fits…, then the cardRecommended skill /primekg …with the draft still held.Agent log:
skill reco: recommended a skill skill=primekg probability=0.44 none_probability=0.02 latency_ms=1090.recommendable draft, and that a submit starts it without holding the send. All
four fail with the two call sites removed.
cargo fmt -p future-tui --check,cargo clippy -p future-tui --all-targets -- -D warnings,cargo test -p future-tui(2095 passed).Not part of this PR
While verifying I also hit — twice out of four real attempts — the Jev round trip
exceeding the client's 3 s deadline (
agent.log:skill reco: call failed; reason=timeout after 5000ms), in which case the draft is sent with no card andagain no explanation. That is the agent's Jev client / gateway latency, not the
catalogue (the same request took 0.65–1.1 s on the successful attempts and
1.1–1.5 s from
curl). Worth a separate look; it is left alone here.