접었다 펼 수 있는 깃 커밋 그래프 패널 (/git-graph)

Claude Code 모드 모음 (CLI · 데스크톱 앱 Code 탭 공용)
| 플러그인 | 설명 | |
|---|---|---|
usage-band | 입력창 위에 5시간 / 주간 / Fable 주간 사용량 게이지 표시 (claude.ai Pro·Max 로그인 필요) | |
git-graph | 접었다 펼 수 있는 깃 커밋 그래프 패널. 세션 시작 때 자동으로 열리지 않고 /git-graph로 열면 그래프가 펼쳐진 상태로 보임. ▾ (c)로 접기. 레인(브랜치)이 많으면 그래프 폭을 제한하고 ◀ ▶ (h l)로 좌우 이동. /git-graph [저장소 경로] | |
pretty-replies | 답변 왼쪽에 세로 테두리와 여백을 그림. 답변의 첫 블록은 주황(Claude 색), 도구 호출 뒤 이어지는 블록은 흐린 색. `/pretty [on\ | off]`로 켜고 끔(인자 없으면 토글, 설정은 유지) |
Claude Code에서:
/plugin marketplace add nemokoala/claude-mods
/plugin install usage-band@nemokoala-mods
/plugin install git-graph@nemokoala-mods
/plugin install pretty-replies@nemokoala-mods
또는 터미널에서:
claude plugin marketplace add nemokoala/claude-mods
claude plugin install usage-band@nemokoala-mods
claude plugin install git-graph@nemokoala-mods
claude plugin install pretty-replies@nemokoala-mods
설치 후 새 세션부터 적용됩니다.
hooks/register.tsx 524 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Changes, Commit, Graph, GraphError } from '../types'
5
6const PANE = 'git-graph'
7const repo = atom({ plugin: 'git-graph', key: 'repo' } as const, null)
8// The pane opens only on /git-graph, and opens with the graph showing.
9const isCollapsed = atom({ plugin: 'git-graph', key: 'isCollapsed' } as const, false)
10const limit = atom({ plugin: 'git-graph', key: 'limit' } as const, 40)
11const graph = atom({ plugin: 'git-graph', key: 'graph' } as const, null)
12const laneOffset = atom({ plugin: 'git-graph', key: 'laneOffset' } as const, 0)
13
14const SEP = '\x1f'
15const LANE_COLORS = ['#3b82f6', '#10b981', '#f59e0b', '#ec4899', '#8b5cf6', '#06b6d4', '#ef4444', '#84cc16']
16
17async function git($: EngineInterface, dir: string | null, args: string[]) {
18 const argv = dir ? ['git', '-C', dir, ...args] : ['git', ...args]
19 // GIT_OPTIONAL_LOCKS=0: `status` must never take the index lock a git
20 // command the person runs at the same moment needs.
21 return $.process.run(argv, { timeoutMs: 15_000, env: { GIT_OPTIONAL_LOCKS: '0' } })
22}
23
24// The pseudo-commit standing for the working tree's uncommitted changes.
25const WORKTREE = 'WORKTREE'
26
27function countChanges(porcelain: string): Changes | null {
28 const c: Changes = { staged: 0, unstaged: 0, untracked: 0 }
29 for (const line of porcelain.split('\n')) {
30 if (line.length < 3) continue
31 const [x, y] = [line[0], line[1]]
32 if (x === '?' && y === '?') { c.untracked++; continue }
33 if (x !== ' ') c.staged++
34 if (y !== ' ') c.unstaged++
35 }
36 return c.staged + c.unstaged + c.untracked > 0 ? c : null
37}
38
39function describeChanges(c: Changes): string {
40 return [
41 c.staged ? `스테이징 ${c.staged}` : '',
42 c.unstaged ? `수정 ${c.unstaged}` : '',
43 c.untracked ? `새 파일 ${c.untracked}` : '',
44 ].filter(Boolean).join(' · ')
45}
46
47const POLL_MS = 3_000
48const FULL_REFRESH_MS = 60_000
49let lastSeen = ''
50let lastFull = 0
51let isPolling = false
52
53// Where HEAD and every branch and tag point, and which files are changed:
54// it moves on any commit, checkout, merge, rebase, reset, fetch, branch
55// edit, or a file edited, staged or added.
56async function fingerprint($: EngineInterface, dir: string | null): Promise<string> {
57 const [refs, head, status] = await Promise.all([
58 git($, dir, ['show-ref', '--head']),
59 git($, dir, ['symbolic-ref', '-q', 'HEAD']),
60 git($, dir, ['status', '--porcelain']),
61 ])
62 return refs.exitCode === 0 ? `${head.stdout}\n${refs.stdout}\n${status.stdout}` : ''
63}
64
65// Runs on a timer: redraws when the repository moved, and once a minute
66// anyway so the "n minutes ago" times stay current.
67async function isOpen($: EngineInterface): Promise<boolean> {
68 return (await $.ui.panes()).some(pane => pane.id === PANE)
69}
70
71async function poll($: EngineInterface): Promise<void> {
72 if (isPolling || !(await isOpen($))) return
73 isPolling = true
74 try {
75 const g = await read($, graph)
76 const dir = g && !('error' in g) ? g.root : await read($, repo)
77 const isStale = (await $.clock.now()) - lastFull > FULL_REFRESH_MS
78 if (isStale || (await fingerprint($, dir)) !== lastSeen) await refresh($)
79 } catch {
80 // A failed check just waits for the next tick.
81 } finally {
82 isPolling = false
83 }
84}
85
86async function refresh($: EngineInterface): Promise<void> {
87 lastFull = await $.clock.now()
88 const dir = await read($, repo)
89 lastSeen = await fingerprint($, dir).catch(() => '')
90 const n = await read($, limit)
91 let next: Graph | GraphError
92 try {
93 const top = await git($, dir, ['rev-parse', '--show-toplevel'])
94 if (top.exitCode !== 0) {
95 next = { error: `${dir ?? '현재 폴더'}는 깃 저장소가 아니에요. /git-graph <경로> 로 저장소를 지정하세요.` }
96 } else {
97 const root = top.stdout.trim()
98 const [head, headSha, log, ascii, status] = await Promise.all([
99 git($, root, ['rev-parse', '--abbrev-ref', 'HEAD']),
100 git($, root, ['rev-parse', '-q', '--verify', 'HEAD']),
101 git($, root, ['log', '--all', '--topo-order', '-n', String(n),
102 `--format=%H${SEP}%P${SEP}%D${SEP}%s${SEP}%an${SEP}%ar`]),
103 git($, root, ['log', '--all', '--graph', '--decorate', '-n', String(n), '--format=%s%d %h']),
104 git($, root, ['status', '--porcelain']),
105 ])
106 const changes = countChanges(status.stdout)
107 const commits: Commit[] = log.stdout.split('\n').filter(Boolean).map(line => {
108 const [sha, parents, refs, subject, author, when] = line.split(SEP)
109 return {
110 sha,
111 parents: parents ? parents.split(' ') : [],
112 refs: refs ? refs.split(', ').filter(Boolean) : [],
113 subject: subject ?? '',
114 author: author ?? '',
115 when: when ?? '',
116 }
117 })
118 const asciiLines = ascii.stdout.split('\n').filter(Boolean)
119 if (changes) {
120 // Uncommitted work sits on top of HEAD, as its would-be child.
121 const parent = headSha.exitCode === 0 ? headSha.stdout.trim() : ''
122 commits.unshift({
123 sha: WORKTREE,
124 parents: parent ? [parent] : [],
125 refs: [],
126 subject: '커밋하지 않은 변경',
127 author: describeChanges(changes),
128 when: '',
129 })
130 asciiLines.unshift(`◌ 커밋하지 않은 변경 (${describeChanges(changes)})`)
131 }
132 next = {
133 root,
134 branch: head.stdout.trim(),
135 commits,
136 ascii: asciiLines,
137 changes,
138 }
139 }
140 } catch (err) {
141 next = { error: `git 실행 실패: ${String(err)}` }
142 }
143 await update($, graph, () => next)
144}
145
146// ---- layout -------------------------------------------------------------
147
148type Edge = { from: number; lane: number; to: number | null }
149
150// Assigns each commit a lane and records, per parent link, which lane the
151// line travels down in between the child's row and the parent's row.
152function layout(commits: Commit[]) {
153 const lanes: (string | null)[] = []
154 const placed: number[] = []
155 const edges: Edge[] = []
156 const pending = new Map<string, Edge[]>()
157 let width = 1
158
159 const freeSlot = (avoid: number) => {
160 for (let i = 0; i < lanes.length; i++) if (lanes[i] === null && i !== avoid) return i
161 lanes.push(null)
162 return lanes.length - 1
163 }
164
165 commits.forEach((c, row) => {
166 let lane = lanes.indexOf(c.sha)
167 if (lane === -1) lane = freeSlot(-1)
168 for (let i = 0; i < lanes.length; i++) if (lanes[i] === c.sha) lanes[i] = null
169 placed.push(lane)
170 for (const e of pending.get(c.sha) ?? []) e.to = row
171 pending.delete(c.sha)
172
173 c.parents.forEach((p, idx) => {
174 // The first parent always continues in this commit's lane, even when
175 // another lane already heads for it: both lines meet at the parent.
176 let k: number
177 if (idx === 0 && lanes[lane] === null) {
178 k = lane
179 lanes[k] = p
180 } else {
181 k = lanes.indexOf(p)
182 if (k === -1) {
183 k = freeSlot(lane)
184 lanes[k] = p
185 }
186 }
187 const edge: Edge = { from: row, lane: k, to: null }
188 edges.push(edge)
189 pending.set(p, [...(pending.get(p) ?? []), edge])
190 })
191 width = Math.max(width, lanes.length, lane + 1)
192 while (lanes.length && lanes[lanes.length - 1] === null) lanes.pop()
193 })
194 return { placed, edges, width }
195}
196
197const esc = (s: string) =>
198 s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
199
200const textWidth = (s: string, size: number) =>
201 [...s].reduce((w, ch) => w + (ch.charCodeAt(0) > 0x1100 ? size : size * 0.56), 0)
202
203function clip(s: string, maxW: number, size: number): string {
204 if (textWidth(s, size) <= maxW) return s
205 let out = ''
206 for (const ch of s) {
207 if (textWidth(out + ch + '…', size) > maxW) break
208 out += ch
209 }
210 return out + '…'
211}
212
213const PAD = 12
214// The graph area never takes more than this, nor more than GRAPH_SHARE of the
215// pane: lanes beyond it are panned to with ◀ ▶.
216const GRAPH_MAX = 160
217const GRAPH_SHARE = 0.3
218const MIN_VISIBLE_LANES = 4
219
220// Lanes draw closer together as there are more of them.
221const laneSpacing = (lanes: number) => (lanes <= 6 ? 14 : lanes <= 10 ? 12 : 10)
222
223// How far apart lanes are drawn and how many fit in the graph area at once.
224export function laneView(lanes: number, W: number): { laneW: number; visible: number } {
225 const laneW = laneSpacing(lanes)
226 const maxW = Math.min(GRAPH_MAX, Math.round(W * GRAPH_SHARE))
227 const fit = Math.max(MIN_VISIBLE_LANES, Math.floor((maxW - 2 * PAD) / laneW) + 1)
228 return { laneW, visible: Math.min(lanes, fit) }
229}
230
231export type GraphView = {
232 source: string
233 height: number
234 /** Lanes the whole history needs, how many are drawn, and the first drawn. */
235 lanes: number
236 visible: number
237 offset: number
238}
239
240export function svgGraph(g: Graph, W: number, offset = 0): GraphView {
241 const ROW = 28
242 const FS = 12
243 const { placed, edges, width } = layout(g.commits)
244 const { laneW, visible } = laneView(width, W)
245 const off = Math.max(0, Math.min(offset, width - visible))
246 const H = g.commits.length * ROW + 6
247 const x = (lane: number) => PAD + (lane - off) * laneW
248 const y = (row: number) => 3 + row * ROW + ROW / 2
249 const color = (lane: number) => LANE_COLORS[lane % LANE_COLORS.length]
250 const dotR = laneW >= 14 ? 4.5 : 4
251 const textX = PAD + visible * laneW + 8
252 // The graph area's edges: lanes outside them are clipped and faded.
253 const areaL = PAD - laneW / 2
254 const areaR = PAD + (visible - 0.5) * laneW
255 const hiddenLeft = off > 0
256 const hiddenRight = off + visible < width
257 const isClipped = hiddenLeft || hiddenRight
258 const isInView = (lane: number) => lane >= off && lane < off + visible
259 const lines: string[] = []
260 const parts: string[] = []
261
262 for (const e of edges) {
263 const x1 = x(placed[e.from])
264 const y1 = y(e.from)
265 const half = ROW / 2
266 let d = `M${x1} ${y1}`
267 let cx = x1
268 let cy = y1
269 // One row's worth of S-curve from the current point over to lane x `nx`.
270 const swing = (nx: number) => {
271 d += ` C${cx} ${cy + half} ${nx} ${cy + half} ${nx} ${cy + ROW}`
272 cx = nx
273 cy += ROW
274 }
275 if (e.to !== null && e.to === e.from + 1) {
276 swing(x(placed[e.to]))
277 } else {
278 swing(x(e.lane))
279 if (e.to === null) {
280 d += ` L${cx} ${H}`
281 } else {
282 const x2 = x(placed[e.to])
283 const y2 = y(e.to)
284 if (y2 - ROW > cy) { d += ` L${cx} ${y2 - ROW}`; cy = y2 - ROW }
285 if (cy < y2) swing(x2)
286 }
287 }
288 const dash = g.commits[e.from].sha === WORKTREE ? ' stroke-dasharray="3 3"' : ''
289 lines.push(`<path d="${d}" stroke="${color(e.lane)}" stroke-width="2" fill="none" stroke-linecap="round" opacity="0.9"${dash}/>`)
290 }
291
292 g.commits.forEach((c, row) => {
293 const lane = placed[row] ?? 0
294 const cx = x(lane)
295 const cy = y(row)
296 const col = color(lane)
297 // A commit in a lane panned out of view: a marker at that edge, in its color.
298 if (!isInView(lane)) {
299 parts.push(lane < off
300 ? `<path d="M1 ${cy} L6 ${cy - 4} L6 ${cy + 4} Z" fill="${col}"/>`
301 : `<path d="M${areaR + 7} ${cy} L${areaR + 2} ${cy - 4} L${areaR + 2} ${cy + 4} Z" fill="${col}"/>`)
302 }
303 if (c.sha === WORKTREE) {
304 lines.push(`<circle cx="${cx}" cy="${cy}" r="5.5" class="bg" stroke="${col}" stroke-width="2" stroke-dasharray="2.5 2"/>`)
305 const tx = textX
306 parts.push(`<text x="${tx}" y="${cy + 4}" class="wt">${esc(c.subject)}</text>`)
307 parts.push(`<text x="${tx + textWidth(c.subject, FS) + 12}" y="${cy + 4}" class="meta">${esc(c.author)}</text>`)
308 return
309 }
310 if (c.refs.some(r => r.startsWith('HEAD'))) {
311 lines.push(`<circle cx="${cx}" cy="${cy}" r="6.5" class="bg" stroke="${col}" stroke-width="2.5"/>`)
312 lines.push(`<circle cx="${cx}" cy="${cy}" r="2.5" fill="${col}"/>`)
313 } else if (c.parents.length > 1) {
314 lines.push(`<circle cx="${cx}" cy="${cy}" r="${dotR}" class="bg" stroke="${col}" stroke-width="2"/>`)
315 } else {
316 lines.push(`<circle cx="${cx}" cy="${cy}" r="${dotR}" fill="${col}"/>`)
317 }
318
319 // The subject leads; the branch and tag badges, the short hash and who
320 // and when line up against the right edge.
321 const sha = c.sha.slice(0, 7)
322 const right = W - PAD
323 const badges = c.refs.slice(0, 3).filter(raw => raw !== 'HEAD').map(raw => {
324 const isHeadRef = raw.startsWith('HEAD -> ')
325 const isTag = raw.startsWith('tag: ')
326 const label = isHeadRef ? raw.slice(8) : isTag ? raw.slice(5) : raw
327 const kind = isHeadRef ? 'head' : isTag ? 'tag' : raw.includes('/') ? 'remote' : 'local'
328 return { label, kind, w: textWidth(label, FS - 1) + 14 }
329 })
330 const badgesW = badges.reduce((w, b) => w + b.w + 5, 0)
331
332 // In a narrow pane the hash goes first, then who and when, so the
333 // subject keeps room to be read.
334 const who = `${c.author} · ${c.when}`
335 const meta = [
336 { text: `${sha} ${who}`, hasSha: true, minSubject: 220 },
337 { text: who, hasSha: false, minSubject: 160 },
338 { text: '', hasSha: false, minSubject: 0 },
339 ].map(m => ({ ...m, w: m.text ? textWidth(m.text, FS - 1) + 12 : 0 }))
340 .find(m => right - m.w - badgesW - textX >= m.minSubject)!
341 let bx = right - meta.w - badgesW
342 const room = bx - textX - 8
343 if (room > 30) {
344 parts.push(`<text x="${textX}" y="${cy + 4}" class="subj">${esc(clip(c.subject, room, FS))}</text>`)
345 }
346 for (const b of badges) {
347 parts.push(`<rect x="${bx}" y="${cy - 9}" width="${b.w}" height="18" rx="9" class="b-${b.kind}"/>`)
348 parts.push(`<text x="${bx + 7}" y="${cy + 4}" class="t-${b.kind}">${esc(b.label)}</text>`)
349 bx += b.w + 5
350 }
351 if (meta.text) {
352 parts.push(`<text x="${right}" y="${cy + 4}" text-anchor="end" class="meta">`
353 + (meta.hasSha ? `<tspan class="sha">${sha}</tspan>${esc(meta.text.slice(sha.length))}` : esc(meta.text))
354 + '</text>')
355 }
356 })
357
358 const style = `<style>
359 text{font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI","Malgun Gothic",sans-serif;font-size:${FS}px}
360 .sha{font-family:ui-monospace,"Cascadia Code",Consolas,monospace;font-size:11px;fill:#8b949e}
361 .subj{fill:#1f2328}.meta{fill:#6e7781;font-size:11px}.bg{fill:#ffffff}
362 .wt{fill:#b45309;font-style:italic;font-weight:600}
363 .b-head{fill:#3b82f6}.t-head{fill:#ffffff;font-size:11px;font-weight:600}
364 .b-local{fill:#10b98126;stroke:#10b981}.t-local{fill:#047857;font-size:11px}
365 .b-remote{fill:#8b949e22;stroke:#8b949e}.t-remote{fill:#57606a;font-size:11px}
366 .b-tag{fill:#f59e0b26;stroke:#f59e0b}.t-tag{fill:#b45309;font-size:11px}
367 @media (prefers-color-scheme: dark){
368 .subj{fill:#e6edf3}.meta{fill:#8b949e}.bg{fill:#1e1e1e}.wt{fill:#fbbf24}
369 .t-local{fill:#6ee7b7}.t-remote{fill:#c9d1d9}.t-tag{fill:#fcd34d}
370 }
371 </style>`
372 // Lines and dots; clipped to the graph area, the cut edges faded out by a
373 // mask (any background shows through) when some lanes are panned out of view.
374 let graphArea = lines.join('')
375 if (isClipped) {
376 const FADE = 10
377 const fadeL = hiddenLeft ? areaL + FADE : areaL
378 const fadeR = hiddenRight ? areaR - FADE : areaR
379 const defs = `<defs>
380 <linearGradient id="fadeL"><stop offset="0" stop-color="#000"/><stop offset="1" stop-color="#fff"/></linearGradient>
381 <linearGradient id="fadeR"><stop offset="0" stop-color="#fff"/><stop offset="1" stop-color="#000"/></linearGradient>
382 <mask id="lanes" maskUnits="userSpaceOnUse" x="0" y="0" width="${W}" height="${H}">
383 ${hiddenLeft ? `<rect x="${areaL}" y="0" width="${FADE}" height="${H}" fill="url(#fadeL)"/>` : ''}
384 <rect x="${fadeL}" y="0" width="${fadeR - fadeL}" height="${H}" fill="#fff"/>
385 ${hiddenRight ? `<rect x="${fadeR}" y="0" width="${FADE}" height="${H}" fill="url(#fadeR)"/>` : ''}
386 </mask>
387 </defs>`
388 graphArea = `${defs}<g mask="url(#lanes)">${graphArea}</g>`
389 }
390 const source = `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">${style}${graphArea}${parts.join('')}</svg>`
391 return { source, height: H, lanes: width, visible, offset: off }
392}
393
394// ---- hooks --------------------------------------------------------------
395
396export const register: Register = on => {
397 on('session.start', async ($, e, next) => {
398 const result = await next(e)
399 await $.command.register({
400 name: 'git-graph',
401 description: '깃 그래프 패널 열기 (인자로 저장소 경로를 주면 그 저장소를 표시)',
402 })
403 // Polling and redraws only run while the pane is open (see poll).
404 $.clock.every(POLL_MS, () => void poll($))
405 return result
406 })
407
408 on('command.run', { command: 'git-graph' }, async ($, e) => {
409 const arg = e.args.trim().replace(/^["']|["']$/g, '')
410 if (arg) {
411 await update($, repo, () => arg)
412 await update($, laneOffset, () => 0)
413 }
414 await update($, isCollapsed, () => false)
415 await refresh($)
416 await $.ui.open({ id: PANE, title: 'Git graph' })
417 const g = await read($, graph)
418 return { text: g && 'error' in g ? g.error : 'Git graph 패널을 열었어요.' }
419 })
420
421 // Commits and checkouts usually happen during a turn: redraw after each one.
422 on('turn.complete', async ($, e, next) => {
423 const result = await next(e)
424 if (await isOpen($)) await refresh($)
425 return result
426 })
427
428 on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
429 const ui = $.ui.resolve(e)
430 const { Box, Text, Button } = ui
431 const Svg = 'Svg' in ui ? ui.Svg : undefined
432 const g = await read($, graph)
433 const collapsed = await read($, isCollapsed)
434
435 const reload = <Button key="reload" hotkey="r" dimColor label="↻ 새로고침" onPress={() => refresh($)} />
436
437 if (!g) return <Text dimColor>불러오는 중…</Text>
438 if ('error' in g) {
439 return (
440 <Box flexDirection="column" gap={1}>
441 <Text dimColor>{g.error}</Text>
442 <Box flexDirection="row">{reload}</Box>
443 </Box>
444 )
445 }
446
447 const head = g.commits.find(c => c.refs.some(r => r.startsWith('HEAD')))
448 const name = g.root.split(/[\\/]/).pop() ?? g.root
449 const header = (
450 <Box flexDirection="row" alignItems="center" gap={1} flexWrap="wrap">
451 <Button
452 key="toggle"
453 hotkey="c"
454 plain
455 label={collapsed ? '▸' : '▾'}
456 onPress={() => update($, isCollapsed, v => !v)}
457 />
458 <Text bold>{name}</Text>
459 <Text color="#3b82f6" bold>⎇ {g.branch}</Text>
460 {head ? <Text dimColor>{head.sha.slice(0, 7)}</Text> : null}
461 <Box flexGrow={1} />
462 {reload}
463 </Box>
464 )
465
466 if (collapsed) {
467 return (
468 <Box flexDirection="column">
469 {header}
470 {g.changes ? (
471 <Text color="#f59e0b" wrap="truncate-end">◌ 커밋하지 않은 변경 ({describeChanges(g.changes)})</Text>
472 ) : null}
473 {head ? <Text dimColor wrap="truncate-end">{head.subject}</Text> : null}
474 </Box>
475 )
476 }
477
478 const more = (
479 <Button
480 key="more"
481 hotkey="m"
482 dimColor
483 label={`더 보기 (${g.commits.length}개 표시 중)`}
484 onPress={async () => {
485 await update($, limit, n => Math.min(n + 30, 300))
486 await refresh($)
487 }}
488 />
489 )
490
491 if (Svg) {
492 const W = Math.max(360, Math.min(1100, Math.round(e.props.bodyColumns * 7.5)))
493 const { source, height, lanes, visible, offset } = svgGraph(g, W, await read($, laneOffset))
494 const maxOff = lanes - visible
495 const step = Math.max(1, Math.floor(visible / 2))
496 const pan = (by: number) => update($, laneOffset, v => Math.max(0, Math.min(maxOff, Math.min(v, maxOff) + by)))
497 // Only while some lanes do not fit: pan the graph area over them.
498 const panner = maxOff > 0 ? (
499 <Box flexDirection="row" alignItems="center" gap={1}>
500 <Button key="lanes-left" hotkey="h" dimColor={offset === 0} label="◀" onPress={() => pan(-step)} />
501 <Text dimColor>레인 {offset + 1}–{offset + visible} / {lanes}</Text>
502 <Button key="lanes-right" hotkey="l" dimColor={offset === maxOff} label="▶" onPress={() => pan(step)} />
503 </Box>
504 ) : null
505 return (
506 <Box flexDirection="column" gap={1}>
507 {header}
508 {panner}
509 <Svg source={source} alt={`${name} 커밋 그래프, 최근 ${g.commits.length}개`} width={W} height={height} />
510 <Box flexDirection="row">{more}</Box>
511 </Box>
512 )
513 }
514
515 return (
516 <Box flexDirection="column">
517 {header}
518 {g.ascii.map((line, i) => <Text key={`l${i}`} wrap="truncate-end">{line}</Text>)}
519 <Box flexDirection="row">{more}</Box>
520 </Box>
521 )
522 })
523}
524types/index.d.ts 35 lines1export type Commit = {
2 sha: string
3 parents: string[]
4 refs: string[]
5 subject: string
6 author: string
7 when: string
8}
9
10export type Changes = { staged: number; unstaged: number; untracked: number }
11
12export type Graph = {
13 root: string
14 branch: string
15 /** Newest first; led by a `WORKTREE` row while there are uncommitted changes. */
16 commits: Commit[]
17 ascii: string[]
18 changes: Changes | null
19}
20
21export type GraphError = { error: string }
22
23declare module 'claude-code' {
24 interface PluginState {
25 'git-graph': {
26 repo: string | null
27 isCollapsed: boolean
28 limit: number
29 graph: Graph | GraphError | null
30 /** The first lane drawn when there are more lanes than the graph area holds. */
31 laneOffset: number
32 }
33 }
34}
35