spacehub

surshar / claude-code

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.

Built by Anthropic · github.com/anthropics

mods/diff: the pane-shown row is the built-in panel's own, once per session id, and an ask marks diff_selection_attachBrowse files
poteat authored on Sep 11, 2026 parent 9f306ce · commit f6cd2ca471f1
6 changed files+26 -15compared with 9f306ce
Mmods/diff/hooks/host/host.ts
Mmods/diff/hooks/record/features/features.ts
Mmods/diff/hooks/record/recorder/recorder.ts
Mmods/diff/hooks/record/recorder-of.ts
Mmods/diff/hooks/record/width-buckets/width-buckets.ts
Mmods/diff/hooks/register.ts
@@ -105,6 +105,11 @@
105105 registerCommand: (spec: CommandSpec) => Promise<unknown>
106106
107107 /**
108+ * `$.session.id`: the session the pane-shown row is latched to.
109+ */
110+ sessionId: () => Promise<string>
111+
112+ /**
108113 * `$.telemetry.mark`; rejects where the telemetry built-in is absent.
109114 */
110115 mark: EngineInterface['telemetry']['mark']
@@ -3,11 +3,12 @@
33 * feature surface keeps one series across the swap.
44 *
55 * `read` per fetch round, `tabSwitch` per open or close, `baseSwitch` per
6- * base pick, `baseResolve` once a session.
6+ * base pick, `baseResolve` once a session, `selectionAttach` per diff asked.
77 */
88 export const FEATURES = {
99 read: 'repl_diff_read',
1010 tabSwitch: 'repl_tab_switch',
1111 baseSwitch: 'repl_diff_base_switch',
1212 baseResolve: 'diff_base_resolve',
13+ selectionAttach: 'diff_selection_attach',
1314 } as const
@@ -13,7 +13,7 @@
1313 mark: (feature: string, outcome: MarkOutcome) => void
1414
1515 /**
16- * `tengu_plugin_diff_pane_shown`, once a session.
16+ * The built-in panel's `tengu_repl_diff_panel_shown` row, once a session.
1717 */
1818 shown: (
1919 trigger: (typeof SHOWN_TRIGGERS)[number],
@@ -21,7 +21,8 @@
2121 ) => void
2222
2323 /**
24- * `tengu_plugin_diff_ask_attach`: a file's diff rode the next prompt.
24+ * The built-in's `diff_selection_attach` feature mark: a file's diff rode
25+ * the next prompt.
2526 */
26- asked: (lines: number) => void
27+ asked: () => void
2728 }
@@ -1,4 +1,5 @@
11 import type { Host } from '../host'
2+import { FEATURES } from './features'
23 import type { Recorder } from './recorder'
34 import { safely } from './safely'
45 import { SHOWN_TRIGGERS } from './shown-triggers'
@@ -6,7 +7,8 @@
67
78 /**
89 * The plugin's Recorder over the host: each row goes through the telemetry
9- * built-in's `$.telemetry`; a missing noun or a refused row is dropped.
10+ * built-in's `$.telemetry`, named and shaped as the built-in panel's own;
11+ * a missing noun or a refused row is dropped.
1012 *
1113 * @param host the engine as session.start bound it
1214 * @returns the recorder
@@ -16,13 +18,13 @@
1618 shown: (trigger, bucket) =>
1719 safely(() =>
1820 host.log({
19- event: 'diff_pane_shown',
21+ event: 'tengu_repl_diff_panel_shown',
2022 props: {
2123 trigger: { value: trigger, of: SHOWN_TRIGGERS },
22- width_bucket: { value: bucket, of: WIDTH_BUCKETS },
24+ terminal_width_bucket: { value: bucket, of: WIDTH_BUCKETS },
2325 },
2426 }),
2527 ),
26- asked: lines =>
27- safely(() => host.log({ event: 'diff_ask_attach', props: { lines } })),
28+ asked: () =>
29+ safely(() => host.mark({ feature: FEATURES.selectionAttach, kind: 'ok' })),
2830 })
@@ -1,6 +1,6 @@
11 /**
2- * The terminal-width buckets `diff_pane_shown` reports, the built-in's
3- * `tengu_repl_diff_panel_shown` buckets.
2+ * The terminal-width buckets the pane-shown row reports, the built-in
3+ * panel's own.
44 */
55 export const WIDTH_BUCKETS = [
66 'under_110',
@@ -37,7 +37,7 @@
3737 let isPaneOpen = false
3838 let hasAutoOpened = false
3939 let columns: number | null = null
40- let hasShownOnce = false
40+ let shownSessionId: string | null = null
4141 let wasDrawnSinceProbe = false
4242 let armed: Ask.ArmedAsk | null = null
4343 let carrying: Ask.ArmedAsk | null = null
@@ -288,9 +288,10 @@
288288 isPaneOpen = true
289289 const record = Record.recorderOf(engine)
290290 record.mark(Record.FEATURES.tabSwitch, { kind: 'ok' })
291+ const sessionId = await engine.sessionId().catch(() => null)
291292
292- if (!hasShownOnce) {
293- hasShownOnce = true
293+ if (sessionId !== null && sessionId !== shownSessionId) {
294+ shownSessionId = sessionId
294295 record.shown(trigger, Record.widthBucketOf(columns))
295296 }
296297
@@ -464,6 +465,7 @@
464465 openPane: pane => $.ui.open(pane),
465466 closePane: pane => $.ui.close(pane),
466467 registerCommand: spec => $.command.register(spec),
468+ sessionId: () => $.session.id(),
467469 mark: entry => $.telemetry.mark(entry),
468470 log: entry => $.telemetry.log(entry),
469471 })
@@ -621,7 +623,7 @@
621623 const result = await next({ ...e, context: [...context, text] })
622624
623625 if (result.drop === undefined) {
624- Record.recorderOf(host).asked(asked.lines)
626+ Record.recorderOf(host).asked()
625627
626628 if (armed === asked) {
627629 disarm(host)