/said opens a pane listing every message you sent this session; press one to scroll the transcript to it

A Claude Code mod: /said opens a side panel listing every message you've sent in the session, as a timeline. Press one and the transcript scrolls back to it.

├─).✗ marks one you interrupted, and ! one that ended on an error or a refusal; it appears once the turn ends, and until then the turn's dot pulses. A pause of 10 minutes or more between turns shows on the rail (┆ 25m)./said again to close the panel.In a Claude Code terminal session:
/plugin install said --marketplace hfknight/claude-mod-said
Answer y to add the marketplace, then press Enter to install at user scope. It's active straight away and in every session after.
--resume, aren't.session.start: registers the /said command.command.run, only for said: opens or closes the panel. Other commands aren't seen.session.append: reads each message you send after Claude Code has stored it, to list it and scroll the panel down to it, and each slash command, held until a turn starts with it. It doesn't change or block anything.turn.start: lists the slash command a turn starts with (a skill, a prompt command); commands that don't start a turn, such as /clear, aren't listed. It doesn't change the turn.turn.complete: notes how long the turn took and how it ended; after you interrupt a turn, reads the conversation's messages to drop one that Esc took back into the prompt. It doesn't change the turn.ui.render of your messages in the transcript: notes which are on screen, to move the accent. They're drawn unchanged.ui.render of its own panel: draws the list.claude plugin validate . checks the manifest, marketplace and hooks module; claude plugin test . runs tests/. Run it from this folder with claude --plugin-dir ..
MIT
hooks/register.tsx 311 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register, Timer } from 'claude-code'
3
4import type { Said } from '../types'
5
6const PANE = 'said'
7const prompts = atom({ plugin: 'said', key: 'prompts' } as const, [] as Said[])
8const focus = atom({ plugin: 'said', key: 'focus' } as const, null as string | null)
9const pulse = atom({ plugin: 'said', key: 'pulse' } as const, false)
10
11// Row ids of the person's messages the transcript shows now, as their rows report it.
12const shown = new Set<string>()
13// The topmost of them when the focus last followed it.
14let top: string | undefined
15
16// The focus follows the topmost of those when that changes, so a message sent below
17// it keeps the focus; with none on screen it stays where it was.
18const follow = async ($: EngineInterface) => {
19 const first = (await read($, prompts)).find(one => shown.has(one.uuid))
20 if (first?.uuid === top) return
21 top = first?.uuid
22 if (first !== undefined) await update($, focus, () => first.uuid)
23}
24
25// The message whose turn is running, its dot pulsing on the beat; a reload forgets it.
26let running: string | undefined
27let beat: Timer | undefined
28
29// The pane's window and its tree's height when it was last drawn.
30let seen: { offset: number; bodyRows: number; total: number } | undefined
31
32// Whether a turn was interrupted since the latest message was checked for.
33let isAborted = false
34
35// The slash command stored last, listed once a turn starts with it: one that runs
36// no turn (`/clear`, `/model`, `/said`) never is.
37let waiting: { uuid: string; text: string; at: number } | undefined
38
39// Esc before Claude answers takes the message back into the prompt: once the
40// conversation holds fewer messages of the latest one's text than are listed, it goes.
41const dropTaken = async ($: EngineInterface) => {
42 const list = await read($, prompts)
43 const latest = list.findLast(one => !one.isMidTurn)
44 if (latest === undefined) return
45 const words = latest.text.trim()
46 const kept = (await $.session.messages()).filter(m => m.role === 'user' && m.text.trim() === words).length
47 const listed = list.filter(one => !one.isMidTurn && one.text.trim() === words).length
48 if (kept < listed) await update($, prompts, now => now.filter(one => one.uuid !== latest.uuid))
49}
50
51// Lists a message the person sent and gives it the focus; a turn's message pulses
52// until the turn ends.
53const record = async ($: EngineInterface, one: Said & { at: number; isMidTurn: boolean }) => {
54 await update($, prompts, list => [...list, one])
55 await update($, focus, () => one.uuid)
56 // The pane follows it down once it is drawn with it; with the pane closed, the
57 // scroll is refused and nothing moves.
58 $.clock.after(100, () => void $.ui.scroll({ in: PANE, to: 'end' }))
59 if (!one.isMidTurn) {
60 running = one.uuid
61 beat ??= $.clock.every(800, () => void update($, pulse, isLit => !isLit))
62 }
63}
64
65// One line: whitespace collapsed, cut to the room with an ellipsis.
66export const shorten = (text: string, room: number) => {
67 const flat = text.replace(/\s+/g, ' ').trim() || '(no text)'
68 return flat.length <= room ? flat : flat.slice(0, Math.max(1, room - 1)) + '…'
69}
70
71// A message sent mid-turn reaches the model inside the engine's reminder
72// ("The user sent a new message while you were working: …", then "IMPORTANT: …"
73// or "This is how Claude Code surfaces …");
74// this is the person's own words from it.
75export const unframe = (text: string) => {
76 const sent = text.match(/new message while you were working:\s*([\s\S]*?)\s*(?:\n\s*(?:IMPORTANT:|This is how Claude Code)|<\/system-reminder>|$)/)
77 return (sent?.[1] ?? text).replace(/<\/?system-reminder>/g, '').trim()
78}
79
80// A slash command is stored inside the engine's tags; this is its name as typed,
81// less a plugin's namespace, and the words after it. Undefined for any other message.
82export const command = (text: string) => {
83 const name = text.match(/<command-name>\s*\/?(?:[^<:]*:)?([^<]*?)\s*<\/command-name>/)?.[1]
84 if (name === undefined) return undefined
85 const args = text.match(/<command-args>([\s\S]*?)<\/command-args>/)?.[1] ?? ''
86 return { name: `/${name}`, args: args.trim() }
87}
88
89// 24-hour local time, as `10:36`.
90export const clockTime = (ms: number) => {
91 const d = new Date(ms)
92 return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`
93}
94
95// A length of time to the second, as `38s`, `4m12s` or `1h05m`.
96export const span = (ms: number) => {
97 const s = Math.round(ms / 1000)
98 const m = Math.floor(s / 60)
99 if (s < 60) return `${s}s`
100 if (m < 60) return `${m}m${String(s % 60).padStart(2, '0')}s`
101 return `${Math.floor(m / 60)}h${String(m % 60).padStart(2, '0')}m`
102}
103
104// A pause between turns to the minute, as `25m` or `1h05m`.
105export const pause = (ms: number) => {
106 const m = Math.round(ms / 60_000)
107 return m < 60 ? `${m}m` : `${Math.floor(m / 60)}h${String(m % 60).padStart(2, '0')}m`
108}
109
110// What ends a turn's row once Claude is done: how long it took, after ✗ if you interrupted
111// it or ! if it stopped on an error or a refusal. Nothing for a mid-turn message.
112export const tail = (one: Said) => {
113 if (one.isMidTurn || one.tookMs === undefined) return undefined
114 const mark = one.ended === 'aborted' ? '✗ ' : one.ended === 'error' || one.ended === 'refusal' ? '! ' : ''
115 return mark + span(one.tookMs)
116}
117
118// Turns this far apart get the pause shown between them.
119const LONG_PAUSE = 10 * 60_000
120
121export const register: Register = on => {
122 on('session.start', async ($, e, next) => {
123 await $.command.register({
124 name: 'said',
125 description: 'Toggle a pane of the messages you sent; press one to jump to it',
126 })
127 return next(e)
128 })
129
130 on('command.run', { command: 'said' }, async $ => {
131 const isOpen = (await $.ui.panes()).some(pane => pane.id === PANE)
132 if (isOpen) {
133 await $.ui.close({ id: PANE })
134 return { text: 'Closed the Said pane.' }
135 }
136 const opened = await $.ui.open({ id: PANE, title: 'Said' })
137 // Opens at the latest message. The body becomes this plugin's to scroll a moment
138 // after the pane is placed ("not this plugin's site" until then), so it retries.
139 for (let tries = 0; opened.isPlaced && tries < 10; tries++) {
140 if ((await $.ui.scroll({ in: PANE, to: 'end' })).deny === undefined) break
141 await $.clock.sleep(20)
142 }
143 return { text: 'Opened the Said pane.' }
144 })
145
146 // A turn's length and ending go on the latest turn listed, once: a turn nobody sent
147 // (a background agent's report) finds it already timed.
148 // A turn interrupted may have taken its message back; it is gone from the
149 // conversation by now, or by the next message, which checks again.
150 on('turn.complete', async ($, e, next) => {
151 const done = await next(e)
152 if (e.agentId === undefined) {
153 running = undefined
154 beat?.cancel()
155 beat = undefined
156 await update($, pulse, () => false)
157 await update($, prompts, list => {
158 const i = list.findLastIndex(one => !one.isMidTurn)
159 if (i === -1 || list[i]?.tookMs !== undefined) return list
160 return list.map((one, j) => (j === i ? { ...one, tookMs: e.durationMs, ended: e.reason } : one))
161 })
162 }
163 if (e.isAborted && e.agentId === undefined) {
164 isAborted = true
165 await dropTaken($)
166 }
167 return done
168 })
169
170 // The person's own prompts on the main conversation, kept with the row id
171 // the transcript draws them under; one sent mid-turn comes in as a delivery.
172 on('session.append', async ($, e, next) => {
173 const isPersons = e.origin.kind === 'composer' || e.origin.kind === 'bridge'
174 const isPrompt = e.door === 'prompt' || e.door === 'delivery'
175 // Checked before this one is stored, so the same words sent again aren't counted.
176 if (isPrompt && isPersons && e.agentId === undefined && isAborted) {
177 isAborted = false
178 await dropTaken($)
179 }
180 const stored = await next(e)
181 if (e.agentId === undefined && stored.deny === undefined) {
182 const text = stored.message.content.map(block => (block.type === 'text' ? block.text : '')).join(' ')
183 if (isPrompt && isPersons) await record($, { uuid: stored.uuid, text, at: await $.clock.now(), isMidTurn: e.door === 'delivery' })
184 // Its origin doesn't say who ran it; a turn that starts with its text does.
185 if (e.door === 'command' && command(text) !== undefined) waiting = { uuid: stored.uuid, text, at: await $.clock.now() }
186 }
187 return stored
188 })
189
190 on('turn.start', async ($, e, next) => {
191 if (waiting !== undefined && waiting.text.trim() === e.text.trim()) {
192 await record($, { ...waiting, isMidTurn: false })
193 waiting = undefined
194 }
195 return next(e)
196 })
197
198 // Passes every row through as drawn, noting only whether it is on screen. A render
199 // hook may not write, so the change is handed to a timer.
200 on('ui.render', { component: 'UserMessage' }, ($, e, next) => {
201 const isPersons = e.props.origin.kind === 'composer' || e.props.origin.kind === 'bridge'
202 if (isPersons && e.props.onScreen !== undefined) {
203 const was = shown.has(e.requestId)
204 if (e.props.onScreen === null) shown.delete(e.requestId)
205 else shown.add(e.requestId)
206 if (was !== shown.has(e.requestId)) $.clock.after(0, () => void follow($))
207 }
208 return next(e)
209 })
210
211 on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
212 const { Box, Text, Button } = $.ui.resolve(e)
213 const list = await read($, prompts)
214 if (list.length === 0) return <Text dimColor>Nothing said yet.</Text>
215
216 const columns = e.props.bodyColumns
217 // The accent marks the turn the transcript is at: the focus, or a mid-turn focus's
218 // turn; the latest turn while there is none.
219 const current = await read($, focus)
220 let accent = list.findIndex(one => one.uuid === current)
221 if (accent === -1) accent = list.findLastIndex(one => !one.isMidTurn)
222 while (accent > 0 && list[accent]?.isMidTurn) accent--
223 const midTurns = list.filter(one => one.isMidTurn).length
224 const working = list.reduce((sum, one) => sum + (one.tookMs ?? 0), 0)
225 // Rows the tree takes: one per message, the rail between turns, the rule and the footer.
226 const total = list.length + list.filter((one, i) => i > 0 && !one.isMidTurn).length + 2
227 // A pane at the end stays there when it gets shorter (the prompt grows, a notice shows)
228 // or the list longer, so the footer stays in view; scrolling up moves neither.
229 const { offset, bodyRows } = e.props.scroll
230 const wasAtEnd = seen !== undefined && seen.offset + seen.bodyRows >= seen.total
231 const isResized = seen !== undefined && (seen.bodyRows !== bodyRows || seen.total !== total)
232 if (wasAtEnd && isResized && offset + bodyRows < total) $.clock.after(0, () => void $.ui.scroll({ in: PANE, to: 'end' }))
233 seen = { offset, bodyRows, total }
234 const isLit = running === undefined || (await read($, pulse))
235 return (
236 // Docked, it fills the pane so the footer sits at the bottom under a short list.
237 <Box flexDirection="column" minHeight={e.props.placement === 'dock' ? bodyRows : undefined}>
238 {list.flatMap((one, i) => {
239 const jump = async () => {
240 await update($, focus, () => one.uuid)
241 const moved = await $.ui.scroll({ to: { requestId: one.uuid }, block: 'start' })
242 if (moved.deny !== undefined) $.ui.toast(`Couldn't jump there: ${moved.deny}`)
243 }
244 // A turn is a dot on the rail; a message sent mid-turn branches off it.
245 const marker = one.isMidTurn ? (
246 <Text color="subtle">{' ├─ '}</Text>
247 ) : (
248 <Text>
249 <Text color={i === accent ? 'claude' : 'subtle'}>
250 {one.at === undefined ? ' ' : clockTime(one.at)}
251 {` ${(i === accent ? '●○' : '•◦')[one.uuid === running && !isLit ? 1 : 0]} `}
252 </Text>
253 </Text>
254 )
255 const width = one.isMidTurn ? 9 : 8
256 // The end of the row sits at the right edge, dot leaders running up to it.
257 const end = tail(one)
258 const slash = command(one.text)
259 const words = slash === undefined ? (one.isMidTurn ? unframe(one.text) : one.text) : `${slash.name} ${slash.args}`
260 const label = shorten(words, columns - width - (end === undefined ? 0 : end.length + 3))
261 const after =
262 end === undefined
263 ? []
264 : [
265 <Text key={`t-${one.uuid}`}>
266 <Text color="subtle">{` ${'·'.repeat(Math.max(1, columns - width - label.length - end.length - 2))} `}</Text>
267 <Text color="subtle">{end}</Text>
268 </Text>,
269 ]
270 const row = (
271 <Box key={`r-${one.uuid}`} flexDirection="row">
272 {marker}
273 {slash === undefined ? (
274 <Button key={`m-${one.uuid}`} plain label={label} dimColor={one.isMidTurn} hover={{ color: 'claude' }} onPress={jump} />
275 ) : (
276 // The command's name in grey, the words after it as any message's.
277 <Button key={`m-${one.uuid}`} plain hover={{ color: 'claude' }} onPress={jump}>
278 <Text color="subtle">{label.slice(0, slash.name.length)}</Text>
279 {label.slice(slash.name.length)}
280 </Button>
281 )}
282 {after}
283 </Box>
284 )
285 if (i === 0 || one.isMidTurn) return [row]
286 // A long pause since the turn before shows on the rail between them.
287 const before = list.slice(0, i).findLast(other => !other.isMidTurn)
288 const idle = one.at === undefined || before?.at === undefined ? 0 : one.at - before.at - (before.tookMs ?? 0)
289 return [
290 <Text key={`g-${one.uuid}`} color="subtle">
291 {idle >= LONG_PAUSE ? ` ┆ ${pause(idle)}` : ' │'}
292 </Text>,
293 row,
294 ]
295 })}
296 <Box key="spacer" flexGrow={1} />
297 {/* Under the list, where the pane sits, so it stays in view. */}
298 <Text key="rule" color="subtle">
299 {'─'.repeat(columns)}
300 </Text>
301 <Text key="footer">
302 <Text bold>said</Text>
303 <Text color="inactive">
304 {` · ${list.length} sent${midTurns > 0 ? ` · ${midTurns} mid-turn` : ''}${working > 0 ? ` · ${span(working)} working` : ''}`}
305 </Text>
306 </Text>
307 </Box>
308 )
309 })
310}
311types/index.d.ts 19 lines1// `at` and `isMidTurn` are absent on rows kept before they were recorded. `tookMs` and `ended`
2// are how long Claude took over a turn and why it stopped, absent until it does.
3export type Said = {
4 uuid: string
5 text: string
6 at?: number
7 isMidTurn?: boolean
8 tookMs?: number
9 ended?: 'answer' | 'aborted' | 'refusal' | 'error'
10}
11
12declare module 'claude-code' {
13 interface PluginState {
14 // `focus` is the row id of the message the transcript is at, or null before one is known.
15 // `pulse` flips while a turn runs, its message's dot drawn hollow when it is false.
16 said: { prompts: Said[]; focus: string | null; pulse: boolean }
17 }
18}
19