Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
TypeScript
diff: the focus hook answers to either name the engine stamps on its elements (#96953)
Alice T'Poteatc94815511c7f
diff --git a/mods/diff/hooks/names/index.ts b/mods/diff/hooks/names/index.tsindex 70e4a632..7b6da9de 100644--- a/mods/diff/hooks/names/index.ts+++ b/mods/diff/hooks/names/index.ts@@ -3,7 +3,7 @@ export * from './command-name.js'export * from './keys'export * from './pane-id.js'export * from './pane-title.js'-export * from './plugin-name.js'+export * from './plugin-names.js'export * from './texts'export * as default from '.'diff --git a/mods/diff/hooks/names/plugin-name.ts b/mods/diff/hooks/names/plugin-name.tsdeleted file mode 100644index 69f71134..00000000--- a/mods/diff/hooks/names/plugin-name.ts+++ /dev/null@@ -1,5 +0,0 @@-/**- * The plugin's own name, as the engine stamps it on the elements its render- * hooks draw (`ui.press`, `ui.focus`).- */-export const PLUGIN_NAME = 'diff'diff --git a/mods/diff/hooks/names/plugin-names.ts b/mods/diff/hooks/names/plugin-names.tsnew file mode 100644index 00000000..77fcae47--- /dev/null+++ b/mods/diff/hooks/names/plugin-names.ts@@ -0,0 +1,6 @@+/**+ * The names the engine may stamp on the elements this plugin's render hooks+ * draw (`ui.press`, `ui.focus`): its own, and the one a build that carries+ * it registers it under.+ */+export const PLUGIN_NAMES = ['diff', 'cc-plugin-diff'] as constdiff --git a/mods/diff/hooks/register.ts b/mods/diff/hooks/register.tsindex f7929d93..8eda14e7 100644--- a/mods/diff/hooks/register.ts+++ b/mods/diff/hooks/register.ts@@ -833,7 +833,7 @@ export function register(on: On) {return result})- on('ui.focus', { plugin: Names.PLUGIN_NAME }, ($, e, next) => {+ on('ui.focus', { plugin: Names.PLUGIN_NAMES }, ($, e, next) => {const isListed =model.placement === 'inline' && model.dialogView === 'list' && hostdiff --git a/mods/diff/tests/fixtures/ring-onto.ts b/mods/diff/tests/fixtures/ring-onto.tsindex 3871a3c4..849ca778 100644--- a/mods/diff/tests/fixtures/ring-onto.ts+++ b/mods/diff/tests/fixtures/ring-onto.ts@@ -7,12 +7,13 @@ import { PANE } from './pane.js'* elements, as the engine raises it before the ring moves.** @param key the element's key+ * @param plugin the name the engine stamped on the element* @returns the `ui.focus` input*/-export const ringOnto = (key: string): UiFocusInput => ({+export const ringOnto = (key: string, plugin = 'diff'): UiFocusInput => ({component: 'Pane',requestId: PANE.requestId,- plugin: 'diff',+ plugin,element: key,origin: { kind: 'person' },})diff --git a/mods/diff/tests/views.test.ts b/mods/diff/tests/views.test.tsindex 91c8e9ff..1f1bf13d 100644--- a/mods/diff/tests/views.test.ts+++ b/mods/diff/tests/views.test.ts@@ -200,6 +200,24 @@ describe('views', () => {expect(walked).not.toContain('file0.ts')})+ test('the walk follows under the name a build registers', async ($, on) => {+ const world = Fixtures.inRepository(on, Fixtures.MANY_FILES)++ await $.session.start(Fixtures.SESSION)+ await $.command.run(Fixtures.DIALOG_DIFF)+ await world.clock.advance(Fixtures.SETTLE_MS)+ await $.ui.render(Fixtures.INLINE_PANE)++ expect(+ await $.ui.focus(Fixtures.ringOnto('file:file3.ts', 'cc-plugin-diff')),+ ).toEqual({})++ expect(+ world.focused.map(focus => focus.element),+ 'its row once centred',+ ).toEqual(['file:file2.ts'])+ })+test('off fullscreen, the walk stops at the last file', async ($, on) => {const world = Fixtures.inRepository(on, Fixtures.MANY_FILES)