The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | export function getDiffHeaderClickAction(event: MouseEvent) { |
| 2 | const path = event.composedPath(); |
| 3 | // Controls own their actions; handling the chevron here too would toggle twice. |
| 4 | for (const node of path) { |
| 5 | if (node instanceof HTMLButtonElement || node instanceof HTMLAnchorElement) return null; |
| 6 | } |
| 7 | const title = path.find( |
| 8 | (node): node is HTMLElement => node instanceof HTMLElement && node.hasAttribute("data-title"), |
| 9 | ); |
| 10 | if (title?.textContent) return { type: "open" as const, filePath: title.textContent }; |
| 11 | |
| 12 | const header = path.find( |
| 13 | (node): node is HTMLElement => |
| 14 | node instanceof HTMLElement && node.hasAttribute("data-diffs-header"), |
| 15 | ); |
| 16 | const root = header?.getRootNode(); |
| 17 | // Pierre renders the prefix through a slot; its React controls live on the shadow host. |
| 18 | const fileKey = |
| 19 | root instanceof ShadowRoot |
| 20 | ? root.host.querySelector("[data-diff-file-key]")?.getAttribute("data-diff-file-key") |
| 21 | : null; |
| 22 | return fileKey ? { type: "toggle" as const, fileKey } : null; |
| 23 | } |