[BUG] `claude plugin test`: a plugin's own `$.ui.focus` fails with "no implementation for ui.focus" even with a test hook
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separately for multiple bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
In claude plugin test, a $.ui.focus call made by the plugin under test rejects with HooksError: no implementation for ui.focus. This happens even when the test registers on('ui.focus', ...). The test's hook is never called.
A $.ui.focus call made by the test body itself reaches the same hook and resolves to {}.
So a test can't check which element a plugin focuses. For example, I can't test that my pane moves the focus to a Button that is still drawn after a press removes the focused one, which works around #100874.
What Should Happen?
A plugin's $.ui.focus should go through the test's ui.focus hooks, as the plugin's state.set calls go through the test's state.set hooks. Or the kit should answer it from the mounted site, as it answers $.ui.invalidate.
Error Messages/Logs
HooksError: no implementation for ui.focus
Steps to Reproduce
- In a plugin, call
$.ui.focus({ requestId: <pane id>, key: <a drawn Button's key> })from aui.presshook, and record the result or the error. - In a test, register
on('ui.focus', ($, e) => { calls.push(e.key); return {} })before the first call on$. - Mount the pane with
$.ui.mountand press a Button withpane.press. callsstays empty, and the plugin's call rejects with the error above.- In the same test, call
$.ui.focus({ requestId: <pane id>, key: <the same key> })from the test body. It resolves to{}, andcallsgets the key.
On a desktop mount, the call rejects this way from a ui.press hook and from a timer started in a ui.render hook. On a terminal mount, a focus call from a press handler doesn't reach the test's hook either.
Claude Model
Not model-related.
Is this a regression?
Don't know.
Claude Code Version
2.1.296
Platform
Anthropic API
Operating System
macOS 15.7.3
Terminal/Shell
Terminal (claude plugin test)
Additional Information
None.