tmux-ide 1.2.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/bin/cli.js +4 -216
  2. package/bin/cli.ts +536 -0
  3. package/package.json +33 -14
  4. package/src/__tests__/support.ts +186 -0
  5. package/src/{attach.js → attach.ts} +7 -4
  6. package/src/cli.test.ts +314 -0
  7. package/src/command-center/discovery.test.ts +265 -0
  8. package/src/command-center/discovery.ts +296 -0
  9. package/src/command-center/index.ts +31 -0
  10. package/src/command-center/schemas.ts +57 -0
  11. package/src/command-center/server.test.ts +818 -0
  12. package/src/command-center/server.ts +1426 -0
  13. package/src/config-cli.test.ts +86 -0
  14. package/src/config.test.ts +205 -0
  15. package/src/config.ts +313 -0
  16. package/src/detect.test.ts +142 -0
  17. package/src/{detect.js → detect.ts} +31 -15
  18. package/src/dispatch.ts +102 -0
  19. package/src/doctor.test.ts +119 -0
  20. package/src/doctor.ts +167 -0
  21. package/src/init.test.ts +101 -0
  22. package/src/init.ts +144 -0
  23. package/src/inspect.test.ts +67 -0
  24. package/src/{inspect.js → inspect.ts} +95 -10
  25. package/src/integration.test.ts.skip +276 -0
  26. package/src/js-yaml.d.ts +10 -0
  27. package/src/launch.test.ts +222 -0
  28. package/src/launch.ts +494 -0
  29. package/src/lib/auth/auth-service.test.ts +178 -0
  30. package/src/lib/auth/auth-service.ts +227 -0
  31. package/src/lib/auth/middleware.test.ts +119 -0
  32. package/src/lib/auth/middleware.ts +56 -0
  33. package/src/lib/auth/types.ts +13 -0
  34. package/src/lib/authorship.test.ts +242 -0
  35. package/src/lib/authorship.ts +280 -0
  36. package/src/lib/cast/recorder.test.ts +127 -0
  37. package/src/lib/cast/recorder.ts +148 -0
  38. package/src/lib/daemon-watchdog.ts +102 -0
  39. package/src/lib/daemon.ts +417 -0
  40. package/src/lib/dot-path.test.ts +66 -0
  41. package/src/lib/dot-path.ts +17 -0
  42. package/src/lib/errors.ts +44 -0
  43. package/src/lib/event-log.test.ts +189 -0
  44. package/src/lib/event-log.ts +237 -0
  45. package/src/lib/github-pr.ts +182 -0
  46. package/src/lib/hq/client.test.ts +154 -0
  47. package/src/lib/hq/client.ts +142 -0
  48. package/src/lib/hq/mdns.test.ts +54 -0
  49. package/src/lib/hq/mdns.ts +88 -0
  50. package/src/lib/hq/registry.test.ts +237 -0
  51. package/src/lib/hq/registry.ts +145 -0
  52. package/src/lib/hq/types.ts +44 -0
  53. package/src/lib/ipc/socket-protocol.test.ts +126 -0
  54. package/src/lib/ipc/socket-protocol.ts +324 -0
  55. package/src/lib/launch-plan.test.ts +119 -0
  56. package/src/lib/launch-plan.ts +90 -0
  57. package/src/lib/log.test.ts +39 -0
  58. package/src/lib/log.ts +71 -0
  59. package/src/lib/metrics.test.ts +213 -0
  60. package/src/lib/metrics.ts +345 -0
  61. package/src/lib/orchestrator.test.ts +2358 -0
  62. package/src/lib/orchestrator.ts +1792 -0
  63. package/src/lib/{output.js → output.ts} +18 -10
  64. package/src/lib/plan-store.test.ts +148 -0
  65. package/src/lib/plan-store.ts +131 -0
  66. package/src/lib/research.test.ts +208 -0
  67. package/src/lib/research.ts +475 -0
  68. package/src/lib/round-trip.test.ts +341 -0
  69. package/src/lib/session-monitor.test.ts +152 -0
  70. package/src/lib/session-monitor.ts +282 -0
  71. package/src/lib/session-options.test.ts +146 -0
  72. package/src/lib/{session-options.js → session-options.ts} +11 -6
  73. package/src/lib/shell.test.ts +20 -0
  74. package/src/lib/shell.ts +8 -0
  75. package/src/lib/sizes.test.ts +73 -0
  76. package/src/lib/{sizes.js → sizes.ts} +4 -4
  77. package/src/lib/skill-registry.test.ts +134 -0
  78. package/src/lib/skill-registry.ts +86 -0
  79. package/src/lib/slugify.test.ts +35 -0
  80. package/src/lib/slugify.ts +10 -0
  81. package/src/lib/task-store.ts +352 -0
  82. package/src/lib/tmux.test.ts +500 -0
  83. package/src/lib/tmux.ts +372 -0
  84. package/src/lib/token-tracker.test.ts +102 -0
  85. package/src/lib/token-tracker.ts +70 -0
  86. package/src/lib/tunnels/cloudflare.test.ts +73 -0
  87. package/src/lib/tunnels/cloudflare.ts +254 -0
  88. package/src/lib/tunnels/manager.test.ts +63 -0
  89. package/src/lib/tunnels/manager.ts +132 -0
  90. package/src/lib/tunnels/ngrok.test.ts +94 -0
  91. package/src/lib/tunnels/ngrok.ts +261 -0
  92. package/src/lib/tunnels/tailscale.test.ts +103 -0
  93. package/src/lib/tunnels/tailscale.ts +1048 -0
  94. package/src/lib/tunnels/types.ts +44 -0
  95. package/src/lib/validation.test.ts +289 -0
  96. package/src/lib/validation.ts +123 -0
  97. package/src/lib/webhook.ts +51 -0
  98. package/src/lib/workflow-store.ts +209 -0
  99. package/src/lib/ws-v3/protocol.test.ts +127 -0
  100. package/src/lib/ws-v3/protocol.ts +160 -0
  101. package/src/lib/yaml-io.test.ts +125 -0
  102. package/src/lib/{yaml-io.js → yaml-io.ts} +5 -4
  103. package/src/ls.test.ts +76 -0
  104. package/src/{ls.js → ls.ts} +4 -4
  105. package/src/metrics-cli.ts +177 -0
  106. package/src/notify.ts +85 -0
  107. package/src/orchestrator-status.ts +228 -0
  108. package/src/plan.ts +117 -0
  109. package/src/postinstall.test.ts +79 -0
  110. package/src/remote.test.ts +115 -0
  111. package/src/remote.ts +148 -0
  112. package/src/restart.ts +24 -0
  113. package/src/schemas/domain.ts +422 -0
  114. package/src/schemas/ide-config.ts +148 -0
  115. package/src/schemas/index.ts +53 -0
  116. package/src/send.test.ts +70 -0
  117. package/src/send.ts +181 -0
  118. package/src/skill.test.ts +114 -0
  119. package/src/skill.ts +138 -0
  120. package/src/status.ts +66 -0
  121. package/src/stop.test.ts +176 -0
  122. package/src/stop.ts +47 -0
  123. package/src/task.test.ts +1466 -0
  124. package/src/task.ts +1143 -0
  125. package/src/tunnel.test.ts +80 -0
  126. package/src/tunnel.ts +133 -0
  127. package/src/types.ts +15 -0
  128. package/src/ui/index.ts +32 -0
  129. package/src/ui/terminal/index.ts +9 -0
  130. package/src/ui/types.ts +91 -0
  131. package/src/ui/web/base.css +80 -0
  132. package/src/ui/web/components/Box.tsx +59 -0
  133. package/src/ui/web/components/Input.tsx +32 -0
  134. package/src/ui/web/components/ScrollBox.tsx +60 -0
  135. package/src/ui/web/components/Text.tsx +28 -0
  136. package/src/ui/web/hooks.ts +106 -0
  137. package/src/ui/web/index.ts +27 -0
  138. package/src/ui/web/render.ts +77 -0
  139. package/src/ui/web/utils/color.test.ts +93 -0
  140. package/src/ui/web/utils/color.ts +27 -0
  141. package/src/validate.test.ts +385 -0
  142. package/src/validate.ts +217 -0
  143. package/src/widgets/changes/index.tsx +576 -0
  144. package/src/widgets/config/index.tsx +440 -0
  145. package/src/widgets/costs/index.tsx +216 -0
  146. package/src/widgets/explorer/breadcrumbs.tsx +77 -0
  147. package/src/widgets/explorer/footer.tsx +20 -0
  148. package/src/widgets/explorer/header.tsx +23 -0
  149. package/src/widgets/explorer/index.tsx +408 -0
  150. package/src/widgets/explorer/tree-model.test.ts +214 -0
  151. package/src/widgets/explorer/tree-model.ts +103 -0
  152. package/src/widgets/explorer/tree.tsx +156 -0
  153. package/src/widgets/lib/config-model.ts +116 -0
  154. package/src/widgets/lib/files.test.ts +103 -0
  155. package/src/widgets/lib/files.ts +88 -0
  156. package/src/widgets/lib/git.test.ts +151 -0
  157. package/src/widgets/lib/git.ts +88 -0
  158. package/src/widgets/lib/pane-comms.test.ts +178 -0
  159. package/src/widgets/lib/pane-comms.ts +192 -0
  160. package/src/widgets/lib/theme.ts +151 -0
  161. package/src/widgets/lib/watcher.ts +50 -0
  162. package/src/widgets/mission-control/activity-feed.tsx +59 -0
  163. package/src/widgets/mission-control/agent-panel.tsx +132 -0
  164. package/src/widgets/mission-control/command-bar.tsx +63 -0
  165. package/src/widgets/mission-control/index.tsx +751 -0
  166. package/src/widgets/mission-control/task-panel.tsx +238 -0
  167. package/src/widgets/preview/index.tsx +415 -0
  168. package/src/widgets/resolve.ts +40 -0
  169. package/src/widgets/setup/agent-naming.tsx +112 -0
  170. package/src/widgets/setup/config-tree.tsx +238 -0
  171. package/src/widgets/setup/detect-panel.tsx +72 -0
  172. package/src/widgets/setup/field-editor.tsx +265 -0
  173. package/src/widgets/setup/footer.tsx +107 -0
  174. package/src/widgets/setup/index.tsx +340 -0
  175. package/src/widgets/setup/layout-picker.tsx +96 -0
  176. package/src/widgets/setup/orchestrator-panel.tsx +200 -0
  177. package/src/widgets/setup/review-panel.tsx +140 -0
  178. package/src/widgets/setup/setup-model.test.ts +303 -0
  179. package/src/widgets/setup/setup-model.ts +188 -0
  180. package/src/widgets/tasks/index.tsx +129 -0
  181. package/src/widgets/tasks/task-detail.tsx +309 -0
  182. package/src/widgets/tasks/task-form.tsx +193 -0
  183. package/src/widgets/tasks/task-list.tsx +205 -0
  184. package/src/widgets/tasks/task-model.test.ts +473 -0
  185. package/src/widgets/tasks/task-model.ts +157 -0
  186. package/templates/AGENTS.md +20 -0
  187. package/templates/missions.yml +41 -0
  188. package/templates/skills/backend.md +30 -0
  189. package/templates/skills/frontend.md +30 -0
  190. package/templates/skills/general-worker.md +30 -0
  191. package/templates/skills/researcher.md +69 -0
  192. package/templates/skills/reviewer.md +30 -0
  193. package/src/config.js +0 -341
  194. package/src/doctor.js +0 -91
  195. package/src/init.js +0 -73
  196. package/src/launch.js +0 -245
  197. package/src/lib/dot-path.js +0 -16
  198. package/src/lib/errors.js +0 -35
  199. package/src/lib/launch-plan.js +0 -49
  200. package/src/lib/session-monitor.js +0 -179
  201. package/src/lib/tmux.js +0 -237
  202. package/src/restart.js +0 -16
  203. package/src/status.js +0 -35
  204. package/src/stop.js +0 -25
  205. package/src/validate.js +0 -154
@@ -0,0 +1,188 @@
1
+ import type { IdeConfig } from "../../schemas/ide-config.ts";
2
+
3
+ // Re-export shared config model utilities
4
+ export {
5
+ type TreeNode,
6
+ flattenConfigTree,
7
+ updateConfigAtPath,
8
+ addPane,
9
+ removePane,
10
+ addRow,
11
+ removeRow,
12
+ deepClone,
13
+ validateSetupConfig,
14
+ } from "../lib/config-model.ts";
15
+
16
+ // ---------------------------------------------------------------------------
17
+ // Layout Presets (setup-specific)
18
+ // ---------------------------------------------------------------------------
19
+
20
+ export interface DetectedInfo {
21
+ devCommand: string | null;
22
+ packageManager: string | null;
23
+ }
24
+
25
+ export interface LayoutPreset {
26
+ id: string;
27
+ label: string;
28
+ description: string;
29
+ diagram: string[];
30
+ buildConfig: (name: string, detected?: DetectedInfo) => IdeConfig;
31
+ }
32
+
33
+ function devCmd(detected?: DetectedInfo): string {
34
+ if (detected?.devCommand) return detected.devCommand;
35
+ if (detected?.packageManager) return `${detected.packageManager} dev`;
36
+ return "npm run dev";
37
+ }
38
+
39
+ function testCmd(detected?: DetectedInfo): string {
40
+ if (detected?.packageManager) return `${detected.packageManager} test`;
41
+ return "npm test";
42
+ }
43
+
44
+ export const PRESETS: LayoutPreset[] = [
45
+ {
46
+ id: "dual-claude",
47
+ label: "Dual Claude",
48
+ description: "Two Claude panes on top, dev server and shell on the bottom.",
49
+ diagram: [
50
+ "┌─────────────────┬─────────────────┐",
51
+ "│ │ │",
52
+ "│ Claude 1 │ Claude 2 │ 70%",
53
+ "│ │ │",
54
+ "├─────────────────┼─────────────────┤",
55
+ "│ Dev Server │ Shell │ 30%",
56
+ "└─────────────────┴─────────────────┘",
57
+ ],
58
+ buildConfig(name: string, detected?: DetectedInfo): IdeConfig {
59
+ return {
60
+ name,
61
+ rows: [
62
+ {
63
+ size: "70%",
64
+ panes: [
65
+ { title: "Claude 1", command: "claude", size: "50%" },
66
+ { title: "Claude 2", command: "claude" },
67
+ ],
68
+ },
69
+ {
70
+ panes: [
71
+ { title: "Dev Server", command: devCmd(detected), size: "50%" },
72
+ { title: "Shell" },
73
+ ],
74
+ },
75
+ ],
76
+ };
77
+ },
78
+ },
79
+ {
80
+ id: "triple-claude",
81
+ label: "Triple Claude",
82
+ description: "Three Claude panes on top for parallel work, dev server and shell below.",
83
+ diagram: [
84
+ "┌───────────┬───────────┬───────────┐",
85
+ "│ │ │ │",
86
+ "│ Claude 1 │ Claude 2 │ Claude 3 │ 70%",
87
+ "│ │ │ │",
88
+ "├───────────┴─────┬─────┴───────────┤",
89
+ "│ Dev Server │ Shell │ 30%",
90
+ "└─────────────────┴─────────────────┘",
91
+ ],
92
+ buildConfig(name: string, detected?: DetectedInfo): IdeConfig {
93
+ return {
94
+ name,
95
+ rows: [
96
+ {
97
+ size: "70%",
98
+ panes: [
99
+ { title: "Claude 1", command: "claude", size: "33%" },
100
+ { title: "Claude 2", command: "claude", size: "34%" },
101
+ { title: "Claude 3", command: "claude" },
102
+ ],
103
+ },
104
+ {
105
+ panes: [
106
+ { title: "Dev Server", command: devCmd(detected), size: "50%" },
107
+ { title: "Shell" },
108
+ ],
109
+ },
110
+ ],
111
+ };
112
+ },
113
+ },
114
+ {
115
+ id: "single-claude",
116
+ label: "Single Claude",
117
+ description: "One wide Claude pane on top, dev server, tests, and shell below.",
118
+ diagram: [
119
+ "┌─────────────────────────────────────┐",
120
+ "│ Claude │ 60%",
121
+ "├──────────┬──────────┬──────────────┤",
122
+ "│ Dev Srv │ Tests │ Shell │ 40%",
123
+ "└──────────┴──────────┴──────────────┘",
124
+ ],
125
+ buildConfig(name: string, detected?: DetectedInfo): IdeConfig {
126
+ return {
127
+ name,
128
+ rows: [
129
+ {
130
+ size: "60%",
131
+ panes: [{ title: "Claude", command: "claude", focus: true }],
132
+ },
133
+ {
134
+ panes: [
135
+ { title: "Dev Server", command: devCmd(detected), size: "33%" },
136
+ { title: "Tests", command: testCmd(detected), size: "34%" },
137
+ { title: "Shell" },
138
+ ],
139
+ },
140
+ ],
141
+ };
142
+ },
143
+ },
144
+ {
145
+ id: "agent-team",
146
+ label: "Agent Team",
147
+ description:
148
+ "Lead + 2 teammates on top, mission control/explorer/preview widgets below with orchestrator.",
149
+ diagram: [
150
+ "┌───────────┬───────────┬───────────┐",
151
+ "│ │ │ │",
152
+ "│ Lead │ Teammate1 │ Teammate2 │ 70%",
153
+ "│ │ │ │",
154
+ "├───────────┼───────────┴───────────┤",
155
+ "│ Mission │ Explorer │ Preview │ 30%",
156
+ "│ Control │ │ │",
157
+ "└───────────┴────────────┴──────────┘",
158
+ ],
159
+ buildConfig(name: string, _detected?: DetectedInfo): IdeConfig {
160
+ return {
161
+ name,
162
+ team: { name: name },
163
+ rows: [
164
+ {
165
+ size: "70%",
166
+ panes: [
167
+ { title: "Lead", command: "claude", role: "lead", focus: true, size: "33%" },
168
+ { title: "Teammate 1", command: "claude", role: "teammate", size: "34%" },
169
+ { title: "Teammate 2", command: "claude", role: "teammate" },
170
+ ],
171
+ },
172
+ {
173
+ panes: [
174
+ { title: "Mission Control", type: "mission-control", size: "40%" },
175
+ { title: "Explorer", type: "explorer", size: "30%" },
176
+ { title: "Preview", type: "preview" },
177
+ ],
178
+ },
179
+ ],
180
+ orchestrator: { enabled: true, auto_dispatch: true },
181
+ };
182
+ },
183
+ },
184
+ ];
185
+
186
+ export function getPreset(id: string): LayoutPreset | undefined {
187
+ return PRESETS.find((p) => p.id === id);
188
+ }
@@ -0,0 +1,129 @@
1
+ import "@opentui/solid/runtime-plugin-support";
2
+ import { parseArgs } from "node:util";
3
+ import { render, useTerminalDimensions } from "@opentui/solid";
4
+ import { RGBA } from "@opentui/core";
5
+ import { createSignal, onMount, onCleanup, Switch, Match } from "solid-js";
6
+ import { createTheme, type RGBA as RGBAType } from "../lib/theme.ts";
7
+ import { watchDirectory } from "../lib/watcher.ts";
8
+ import { loadTasks, ensureTasksDir, getTasksDir, type Task } from "./task-model.ts";
9
+ import { TaskList } from "./task-list.tsx";
10
+ import { TaskDetail } from "./task-detail.tsx";
11
+ import { TaskForm } from "./task-form.tsx";
12
+
13
+ const { values } = parseArgs({
14
+ options: {
15
+ session: { type: "string" },
16
+ dir: { type: "string" },
17
+ target: { type: "string" },
18
+ theme: { type: "string" },
19
+ },
20
+ });
21
+
22
+ const session = values.session ?? "";
23
+ const dir = values.dir ?? process.cwd();
24
+ const targetTitle = values.target ?? null;
25
+ const themeConfig = values.theme ? JSON.parse(values.theme) : undefined;
26
+
27
+ function toRGBA(c: RGBAType): RGBA {
28
+ return RGBA.fromInts(c.r, c.g, c.b, c.a);
29
+ }
30
+
31
+ type View =
32
+ | { kind: "list" }
33
+ | { kind: "detail"; task: Task }
34
+ | { kind: "form"; mode: "create" | "edit"; task?: Task };
35
+
36
+ render(
37
+ () => {
38
+ const theme = createTheme(themeConfig);
39
+ const dimensions = useTerminalDimensions();
40
+ const [tasks, setTasks] = createSignal(loadTasks(dir));
41
+ const [view, setView] = createSignal<View>({ kind: "list" });
42
+
43
+ function reload() {
44
+ setTasks(loadTasks(dir));
45
+ // If viewing a task detail, refresh it
46
+ const v = view();
47
+ if (v.kind === "detail") {
48
+ const fresh = loadTasks(dir).find((t) => t.id === v.task.id);
49
+ if (fresh) setView({ kind: "detail", task: fresh });
50
+ }
51
+ }
52
+
53
+ // File watcher on .tasks/
54
+ let stopWatch: (() => Promise<void>) | null = null;
55
+ onMount(async () => {
56
+ ensureTasksDir(dir);
57
+ try {
58
+ stopWatch = await watchDirectory(getTasksDir(dir), reload, {
59
+ debounceMs: 300,
60
+ ignore: [],
61
+ });
62
+ } catch {
63
+ /* watcher unavailable */
64
+ }
65
+ });
66
+ onCleanup(async () => {
67
+ await stopWatch?.();
68
+ });
69
+
70
+ return (
71
+ <box
72
+ width={dimensions().width}
73
+ height={dimensions().height}
74
+ backgroundColor={toRGBA(theme.bg)}
75
+ >
76
+ <Switch>
77
+ <Match when={view().kind === "list"}>
78
+ <TaskList
79
+ tasks={tasks()}
80
+ onSelect={(task) => setView({ kind: "detail", task })}
81
+ onNew={() => setView({ kind: "form", mode: "create" })}
82
+ onQuit={() => process.exit(0)}
83
+ theme={theme}
84
+ />
85
+ </Match>
86
+ <Match when={view().kind === "detail"}>
87
+ <TaskDetail
88
+ task={(view() as Extract<View, { kind: "detail" }>).task}
89
+ allTasks={tasks()}
90
+ session={session}
91
+ dir={dir}
92
+ target={targetTitle}
93
+ onBack={() => setView({ kind: "list" })}
94
+ onEdit={(task) => setView({ kind: "form", mode: "edit", task })}
95
+ onTaskUpdate={reload}
96
+ theme={theme}
97
+ />
98
+ </Match>
99
+ <Match when={view().kind === "form"}>
100
+ <TaskForm
101
+ mode={(view() as Extract<View, { kind: "form" }>).mode}
102
+ task={(view() as Extract<View, { kind: "form" }>).task}
103
+ dir={dir}
104
+ onSave={(task) => {
105
+ reload();
106
+ setView({ kind: "detail", task });
107
+ }}
108
+ onCancel={() => {
109
+ const v = view();
110
+ if (v.kind === "form" && v.mode === "edit" && (v as any).task) {
111
+ setView({ kind: "detail", task: (v as any).task });
112
+ } else {
113
+ setView({ kind: "list" });
114
+ }
115
+ }}
116
+ theme={theme}
117
+ />
118
+ </Match>
119
+ </Switch>
120
+ </box>
121
+ );
122
+ },
123
+ {
124
+ targetFps: 30,
125
+ exitOnCtrlC: true,
126
+ useKittyKeyboard: {},
127
+ autoFocus: false,
128
+ },
129
+ );
@@ -0,0 +1,309 @@
1
+ import { Show, For } from "solid-js";
2
+ import { RGBA, TextAttributes } from "@opentui/core";
3
+ import { useKeyboard, useTerminalDimensions } from "@opentui/solid";
4
+ import {
5
+ updateTaskStatus,
6
+ updateTaskAssignee,
7
+ isBlocked,
8
+ type Task,
9
+ type TaskStatus,
10
+ } from "./task-model.ts";
11
+ import {
12
+ sendCommand,
13
+ findPaneByTitle,
14
+ findPaneByPattern,
15
+ listSessionPanes,
16
+ } from "../lib/pane-comms.ts";
17
+ import type { WidgetTheme, RGBA as RGBAType } from "../lib/theme.ts";
18
+
19
+ function toRGBA(c: RGBAType): RGBA {
20
+ return RGBA.fromInts(c.r, c.g, c.b, c.a);
21
+ }
22
+
23
+ function statusColor(status: TaskStatus, theme: WidgetTheme): RGBAType {
24
+ switch (status) {
25
+ case "in-progress":
26
+ return theme.gitModified;
27
+ case "todo":
28
+ return theme.fgMuted;
29
+ case "review":
30
+ return theme.diffHunk;
31
+ case "done":
32
+ return theme.gitAdded;
33
+ }
34
+ }
35
+
36
+ function statusLabel(status: TaskStatus): string {
37
+ switch (status) {
38
+ case "in-progress":
39
+ return "DOING";
40
+ case "todo":
41
+ return "TODO";
42
+ case "review":
43
+ return "REVIEW";
44
+ case "done":
45
+ return "DONE";
46
+ }
47
+ }
48
+
49
+ function priorityDots(priority: number): string {
50
+ switch (priority) {
51
+ case 1:
52
+ return "***";
53
+ case 2:
54
+ return "** ";
55
+ case 3:
56
+ return "* ";
57
+ default:
58
+ return " ";
59
+ }
60
+ }
61
+
62
+ interface TaskDetailProps {
63
+ task: Task;
64
+ allTasks: Task[];
65
+ session: string;
66
+ dir: string;
67
+ target: string | null;
68
+ onBack: () => void;
69
+ onEdit: (task: Task) => void;
70
+ onTaskUpdate: () => void;
71
+ theme: WidgetTheme;
72
+ }
73
+
74
+ export function TaskDetail(props: TaskDetailProps) {
75
+ const dimensions = useTerminalDimensions();
76
+ const t = () => props.task;
77
+ const theme = props.theme;
78
+
79
+ const canStart = () => t().status === "todo";
80
+ const canDone = () => t().status === "in-progress" || t().status === "review";
81
+ const canReview = () => t().status === "in-progress";
82
+
83
+ function resolveTargetPane(): string | null {
84
+ if (!props.session) return null;
85
+ if (props.target) return findPaneByTitle(props.session, props.target);
86
+ return findPaneByPattern(props.session, "claude");
87
+ }
88
+
89
+ function findClaudePane(): { id: string; title: string } | null {
90
+ if (!props.session) return null;
91
+ const panes = listSessionPanes(props.session);
92
+ const claude = panes.find(
93
+ (p) =>
94
+ p.currentCommand.toLowerCase() === "claude" || p.title.toLowerCase().includes("claude"),
95
+ );
96
+ return claude ? { id: claude.id, title: claude.title } : null;
97
+ }
98
+
99
+ useKeyboard((evt) => {
100
+ if (
101
+ evt.name === "escape" ||
102
+ evt.name === "backspace" ||
103
+ evt.name === "h" ||
104
+ evt.name === "left"
105
+ ) {
106
+ props.onBack();
107
+ evt.preventDefault();
108
+ } else if (evt.name === "e") {
109
+ props.onEdit(t());
110
+ evt.preventDefault();
111
+ } else if (evt.name === "s" && canStart()) {
112
+ updateTaskStatus(props.dir, t().id, "in-progress");
113
+ props.onTaskUpdate();
114
+ evt.preventDefault();
115
+ } else if (evt.name === "d" && canDone()) {
116
+ updateTaskStatus(props.dir, t().id, "done");
117
+ props.onTaskUpdate();
118
+ evt.preventDefault();
119
+ } else if (evt.name === "v" && canReview()) {
120
+ updateTaskStatus(props.dir, t().id, "review");
121
+ props.onTaskUpdate();
122
+ evt.preventDefault();
123
+ } else if (evt.name === "a") {
124
+ const claude = findClaudePane();
125
+ if (claude) {
126
+ updateTaskAssignee(props.dir, t().id, claude.title);
127
+ props.onTaskUpdate();
128
+ }
129
+ evt.preventDefault();
130
+ } else if (evt.name === "c") {
131
+ const targetId = resolveTargetPane();
132
+ if (targetId) {
133
+ const task = t();
134
+ const prompt = `Work on this task:\n\nTitle: ${task.title}\nDescription: ${task.description}\nPriority: P${task.priority}${task.tags.length > 0 ? `\nTags: ${task.tags.join(", ")}` : ""}`;
135
+ sendCommand(props.session, targetId, prompt);
136
+ if (task.status === "todo") {
137
+ updateTaskStatus(props.dir, task.id, "in-progress");
138
+ props.onTaskUpdate();
139
+ }
140
+ }
141
+ evt.preventDefault();
142
+ } else if (evt.name === "q") {
143
+ props.onBack();
144
+ evt.preventDefault();
145
+ }
146
+ });
147
+
148
+ const sColor = () => statusColor(t().status, theme);
149
+ const blocked = () => isBlocked(t(), props.allTasks);
150
+
151
+ return (
152
+ <box paddingLeft={1} paddingRight={1}>
153
+ {/* Back bar */}
154
+ <box flexShrink={0} flexDirection="row" justifyContent="space-between">
155
+ <text fg={toRGBA(theme.fgMuted)} onMouseUp={() => props.onBack()}>
156
+ {"< Esc:back"}
157
+ </text>
158
+ <text fg={toRGBA(theme.fgMuted)}>Task {t().id}</text>
159
+ </box>
160
+
161
+ {/* Title */}
162
+ <box flexShrink={0} paddingTop={1} flexDirection="row" gap={1}>
163
+ <text fg={toRGBA(sColor())} flexShrink={0}>
164
+ {priorityDots(t().priority)}
165
+ </text>
166
+ <text fg={toRGBA(theme.fg)} attributes={TextAttributes.BOLD}>
167
+ {t().title}
168
+ </text>
169
+ </box>
170
+
171
+ {/* Status + assignee + blocked */}
172
+ <box flexShrink={0} paddingTop={1} flexDirection="row" gap={2}>
173
+ <text fg={toRGBA(sColor())}>{statusLabel(t().status)}</text>
174
+ <Show when={blocked()}>
175
+ <text fg={toRGBA(theme.gitRemoved)}>BLOCKED</text>
176
+ </Show>
177
+ <Show when={t().assignee}>
178
+ <text fg={toRGBA(theme.fgMuted)}>@{t().assignee}</text>
179
+ </Show>
180
+ </box>
181
+
182
+ {/* Dependencies */}
183
+ <Show when={t().depends_on.length > 0}>
184
+ <box flexShrink={0} flexDirection="row" gap={1}>
185
+ <text fg={toRGBA(theme.fgMuted)}>depends:</text>
186
+ <For each={t().depends_on}>
187
+ {(depId) => {
188
+ const dep = props.allTasks.find((x) => x.id === depId);
189
+ const done = dep?.status === "done";
190
+ return (
191
+ <text fg={toRGBA(done ? theme.gitAdded : theme.gitRemoved)}>
192
+ {depId}
193
+ {done ? " ok" : ""}
194
+ </text>
195
+ );
196
+ }}
197
+ </For>
198
+ </box>
199
+ </Show>
200
+
201
+ {/* Milestone + specialty + fulfills + tags */}
202
+ <Show
203
+ when={t().milestone || t().specialty || t().fulfills?.length > 0 || t().tags.length > 0}
204
+ >
205
+ <box flexShrink={0} flexDirection="row" gap={2}>
206
+ <Show when={t().milestone}>
207
+ <text fg={toRGBA(theme.diffHunk)}>{t().milestone}</text>
208
+ </Show>
209
+ <Show when={t().specialty}>
210
+ <text fg={toRGBA(theme.accent)}>{t().specialty}</text>
211
+ </Show>
212
+ <Show when={t().fulfills?.length > 0}>
213
+ <text fg={toRGBA(theme.gitModified)}>fulfills: {t().fulfills.join(", ")}</text>
214
+ </Show>
215
+ <Show when={t().tags.length > 0}>
216
+ <text fg={toRGBA(theme.fgMuted)}>{t().tags.join(", ")}</text>
217
+ </Show>
218
+ </box>
219
+ </Show>
220
+
221
+ {/* Description */}
222
+ <box flexShrink={0} paddingTop={1}>
223
+ <text fg={toRGBA(t().description ? theme.fg : theme.fgMuted)}>
224
+ {t().description || "(no description)"}
225
+ </text>
226
+ </box>
227
+
228
+ {/* Proof */}
229
+ <Show when={t().proof}>
230
+ <box flexShrink={0} paddingTop={1}>
231
+ <text fg={toRGBA(theme.fgMuted)}>Proof:</text>
232
+ <For each={Object.entries(t().proof!)}>
233
+ {([key, val]) => (
234
+ <text fg={toRGBA(theme.gitAdded)} paddingLeft={1}>
235
+ {key}: {typeof val === "object" ? JSON.stringify(val) : String(val)}
236
+ </text>
237
+ )}
238
+ </For>
239
+ </box>
240
+ </Show>
241
+
242
+ {/* Spacer */}
243
+ <box flexGrow={1} />
244
+
245
+ {/* Separator */}
246
+ <box flexShrink={0} height={1}>
247
+ <text fg={toRGBA(theme.border)} wrapMode="none">
248
+ {"─".repeat(Math.max(0, dimensions().width - 2))}
249
+ </text>
250
+ </box>
251
+
252
+ {/* Actions footer */}
253
+ <box flexShrink={0} flexDirection="row" gap={2}>
254
+ <text fg={toRGBA(theme.fgMuted)} onMouseUp={() => props.onEdit(t())} wrapMode="none">
255
+ e:edit
256
+ </text>
257
+ <Show when={canStart()}>
258
+ <text
259
+ fg={toRGBA(theme.fgMuted)}
260
+ onMouseUp={() => {
261
+ updateTaskStatus(props.dir, t().id, "in-progress");
262
+ props.onTaskUpdate();
263
+ }}
264
+ wrapMode="none"
265
+ >
266
+ s:start
267
+ </text>
268
+ </Show>
269
+ <Show when={canReview()}>
270
+ <text
271
+ fg={toRGBA(theme.fgMuted)}
272
+ onMouseUp={() => {
273
+ updateTaskStatus(props.dir, t().id, "review");
274
+ props.onTaskUpdate();
275
+ }}
276
+ wrapMode="none"
277
+ >
278
+ v:review
279
+ </text>
280
+ </Show>
281
+ <Show when={canDone()}>
282
+ <text
283
+ fg={toRGBA(theme.fgMuted)}
284
+ onMouseUp={() => {
285
+ updateTaskStatus(props.dir, t().id, "done");
286
+ props.onTaskUpdate();
287
+ }}
288
+ wrapMode="none"
289
+ >
290
+ d:done
291
+ </text>
292
+ </Show>
293
+ <text
294
+ fg={toRGBA(theme.fgMuted)}
295
+ onMouseUp={() => {
296
+ const claude = findClaudePane();
297
+ if (claude) {
298
+ updateTaskAssignee(props.dir, t().id, claude.title);
299
+ props.onTaskUpdate();
300
+ }
301
+ }}
302
+ wrapMode="none"
303
+ >
304
+ a:assign
305
+ </text>
306
+ </box>
307
+ </box>
308
+ );
309
+ }