Skip to content

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

mods/diff: the pane-shown row is the built-in panel's own, once per session id, and an ask marks diff_selection_attach

poteatf6cd2ca471f1
diff --git a/mods/diff/hooks/host/host.ts b/mods/diff/hooks/host/host.ts
index be5ed36e..d6bb2bb3 100644
--- a/mods/diff/hooks/host/host.ts
+++ b/mods/diff/hooks/host/host.ts
@@ -104,6 +104,11 @@ export type Host = {
*/
registerCommand: (spec: CommandSpec) => Promise<unknown>
+ /**
+ * `$.session.id`: the session the pane-shown row is latched to.
+ */
+ sessionId: () => Promise<string>
+
/**
* `$.telemetry.mark`; rejects where the telemetry built-in is absent.
*/
diff --git a/mods/diff/hooks/record/features/features.ts b/mods/diff/hooks/record/features/features.ts
index a667977e..0c62039a 100644
--- a/mods/diff/hooks/record/features/features.ts
+++ b/mods/diff/hooks/record/features/features.ts
@@ -3,11 +3,12 @@
* feature surface keeps one series across the swap.
*
* `read` per fetch round, `tabSwitch` per open or close, `baseSwitch` per
- * base pick, `baseResolve` once a session.
+ * base pick, `baseResolve` once a session, `selectionAttach` per diff asked.
*/
export const FEATURES = {
read: 'repl_diff_read',
tabSwitch: 'repl_tab_switch',
baseSwitch: 'repl_diff_base_switch',
baseResolve: 'diff_base_resolve',
+ selectionAttach: 'diff_selection_attach',
} as const
diff --git a/mods/diff/hooks/record/recorder-of.ts b/mods/diff/hooks/record/recorder-of.ts
index 015661f6..d2c242b9 100644
--- a/mods/diff/hooks/record/recorder-of.ts
+++ b/mods/diff/hooks/record/recorder-of.ts
@@ -1,4 +1,5 @@
import type { Host } from '../host'
+import { FEATURES } from './features'
import type { Recorder } from './recorder'
import { safely } from './safely'
import { SHOWN_TRIGGERS } from './shown-triggers'
@@ -6,7 +7,8 @@ import { WIDTH_BUCKETS } from './width-buckets'
/**
* The plugin's Recorder over the host: each row goes through the telemetry
- * built-in's `$.telemetry`; a missing noun or a refused row is dropped.
+ * built-in's `$.telemetry`, named and shaped as the built-in panel's own;
+ * a missing noun or a refused row is dropped.
*
* @param host the engine as session.start bound it
* @returns the recorder
@@ -16,13 +18,13 @@ export const recorderOf = (host: Host): Recorder => ({
shown: (trigger, bucket) =>
safely(() =>
host.log({
- event: 'diff_pane_shown',
+ event: 'tengu_repl_diff_panel_shown',
props: {
trigger: { value: trigger, of: SHOWN_TRIGGERS },
- width_bucket: { value: bucket, of: WIDTH_BUCKETS },
+ terminal_width_bucket: { value: bucket, of: WIDTH_BUCKETS },
},
}),
),
- asked: lines =>
- safely(() => host.log({ event: 'diff_ask_attach', props: { lines } })),
+ asked: () =>
+ safely(() => host.mark({ feature: FEATURES.selectionAttach, kind: 'ok' })),
})
diff --git a/mods/diff/hooks/record/recorder/recorder.ts b/mods/diff/hooks/record/recorder/recorder.ts
index 899d0b99..252e7047 100644
--- a/mods/diff/hooks/record/recorder/recorder.ts
+++ b/mods/diff/hooks/record/recorder/recorder.ts
@@ -13,7 +13,7 @@ export type Recorder = {
mark: (feature: string, outcome: MarkOutcome) => void
/**
- * `tengu_plugin_diff_pane_shown`, once a session.
+ * The built-in panel's `tengu_repl_diff_panel_shown` row, once a session.
*/
shown: (
trigger: (typeof SHOWN_TRIGGERS)[number],
@@ -21,7 +21,8 @@ export type Recorder = {
) => void
/**
- * `tengu_plugin_diff_ask_attach`: a file's diff rode the next prompt.
+ * The built-in's `diff_selection_attach` feature mark: a file's diff rode
+ * the next prompt.
*/
- asked: (lines: number) => void
+ asked: () => void
}
diff --git a/mods/diff/hooks/record/width-buckets/width-buckets.ts b/mods/diff/hooks/record/width-buckets/width-buckets.ts
index a979845b..b3132d63 100644
--- a/mods/diff/hooks/record/width-buckets/width-buckets.ts
+++ b/mods/diff/hooks/record/width-buckets/width-buckets.ts
@@ -1,6 +1,6 @@
/**
- * The terminal-width buckets `diff_pane_shown` reports, the built-in's
- * `tengu_repl_diff_panel_shown` buckets.
+ * The terminal-width buckets the pane-shown row reports, the built-in
+ * panel's own.
*/
export const WIDTH_BUCKETS = [
'under_110',
diff --git a/mods/diff/hooks/register.ts b/mods/diff/hooks/register.ts
index be528660..1527a028 100644
--- a/mods/diff/hooks/register.ts
+++ b/mods/diff/hooks/register.ts
@@ -37,7 +37,7 @@ export function register(on: On) {
let isPaneOpen = false
let hasAutoOpened = false
let columns: number | null = null
- let hasShownOnce = false
+ let shownSessionId: string | null = null
let wasDrawnSinceProbe = false
let armed: Ask.ArmedAsk | null = null
let carrying: Ask.ArmedAsk | null = null
@@ -288,9 +288,10 @@ export function register(on: On) {
isPaneOpen = true
const record = Record.recorderOf(engine)
record.mark(Record.FEATURES.tabSwitch, { kind: 'ok' })
+ const sessionId = await engine.sessionId().catch(() => null)
- if (!hasShownOnce) {
- hasShownOnce = true
+ if (sessionId !== null && sessionId !== shownSessionId) {
+ shownSessionId = sessionId
record.shown(trigger, Record.widthBucketOf(columns))
}
@@ -464,6 +465,7 @@ export function register(on: On) {
openPane: pane => $.ui.open(pane),
closePane: pane => $.ui.close(pane),
registerCommand: spec => $.command.register(spec),
+ sessionId: () => $.session.id(),
mark: entry => $.telemetry.mark(entry),
log: entry => $.telemetry.log(entry),
})
@@ -621,7 +623,7 @@ export function register(on: On) {
const result = await next({ ...e, context: [...context, text] })
if (result.drop === undefined) {
- Record.recorderOf(host).asked(asked.lines)
+ Record.recorderOf(host).asked()
if (armed === asked) {
disarm(host)