Repository navigation
fix(agent): skills install/uninstall now refresh; harden sessionless dispatch - #63
Merged
Merged
Conversation
cmd_refresh_skills gated cache invalidation behind a 5s process-global rate limit. That limit was consumed by the harmless scan the GUI fires on startup, page open, and agent (re)connect, so the invalidation that matters - the one right after install/uninstall writes to disk - was silently skipped. get_commands then kept returning the pre-write cache and the Skills view showed stale installed/uninstalled state until restart. Drop the rate limit and invalidate unconditionally; invalidation is O(1) and the rescan warms the cache so the GUI's follow-up get_commands hits the fast path with the new state. Remove the now-inapplicable rate-limit test. Co-Authored-By: Claude Opus 4.8 <[email protected]>
refresh_skills was registered in the session-scoped branch, so the sessionless call the GUI/CLI make right after install/uninstall (no session_id) failed with 'session not found' and was swallowed by the best-effort caller. cmd_refresh_skills never ran, the skills discovery cache was never invalidated, and get_commands kept returning the pre-write list - the installed/uninstalled state only caught up after restart or the 60s TTL. Move it next to get_commands in the sessionless branch. The existing test missed this because make_cmd() always injects a session id; add a regression test that calls it with an empty session. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Follow-up audit to the refresh_skills session-mismatch fix: - Drop the unreachable `new_session` arm from the session-scoped branch. It is dispatched in the sessionless branch above (a new session has no existing session to resolve), so an arm after the resolution gate was dead code. Replaced with a NOTE so it isn't "helpfully" re-added. - Drop the `abort_shell` no-op command and its test. It had zero callers anywhere (agent/TUI/GUI/CLI/channels) and did nothing but return ok — real shell abort flows through the agent-loop `abort` command (the GUI runs-panel terminate button already uses it). Keeping a silent ok for an unimplemented command was misleading; an unknown command now errors honestly. - Add `sessionless_commands_do_not_require_session_id`: a table-driven regression test. make_cmd() always injects a session id, which hid the refresh_skills bug (a sessionless command silently moved into the session-scoped branch). The test builds each sessionless command with an empty session and asserts it never trips the resolution gate (the unique "pass a valid session_id" phrase) and is a known command. cargo fmt/clippy/test all clean (765 passed). Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
问题
GUI「全部技能」点击「安装」/「卸载」后,按钮状态不更新,只有重启才显示正确状态。安装/卸载本身是成功的(磁盘已写入),纯粹是展示层没刷新。
根因(两个叠加的 bug)
refresh_skills被错误地放进 session-scoped 分支。 GUI/CLI 在安装/卸载后会立即调用refresh_skills且不带 session_id,于是它撞上 session 解析门、返回 "session not found"。GUI 的agent_bridge::refresh_skills是 best-effort(let _ =吞掉错误),所以这个失败完全静默 —— 缓存从未失效,已安装列表直到重启 / TTL 过期才更新。cmd_refresh_skills里的进程级 5s 限流也会被启动 / 打开页面时的扫描消耗掉,导致安装/卸载后的那次失效被跳过。修复
refresh_skills移到 sessionless 分支(与get_commands并列),无需 session 即可失效缓存。cmd_refresh_skills改为无条件失效缓存:安装/卸载是在上次扫描之后写盘的,缓存对它们必然是脏的;失效是 O(1),随后的重扫会重新填充(并预热缓存,让 GUI 紧接着的get_commands命中快路径拿到新状态)。删除限流常量与LAST_REFRESH静态量。审计收尾(防止同类问题)
new_session死分支(它在上方 sessionless 分支已处理),留 NOTE 防止被「好心」加回。abort_shell及其测试:全仓(agent/TUI/GUI/CLI/channels)零调用方,且 handler 什么都不做只返回 ok —— 真正的 shell 终止走 agent loop 的abort命令(GUI runs 面板的终止按钮用的就是它)。让一个未实现的命令静默返回 ok 会误导调用方。sessionless_commands_do_not_require_session_id:make_cmd()总会注入 session id,恰好掩盖了 refresh_skills 这类「sessionless 命令被误挪进 session-scoped 分支」的 bug。该测试用空 session 构造每个 sessionless 命令,断言它既不撞 session 解析门(唯一的 "pass a valid session_id" 措辞)、也是已知命令。验证
cargo fmt --check/cargo clippy --all-targets -D warnings/cargo test --lib全部通过(765 passed)。🤖 Generated with Claude Code