@sma1lboy/kobe 0.7.30 → 0.7.32
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.
- package/dist/cli/index.js +61 -56
- package/dist/web-ui/assets/AppShell-CT-Wueej.js +8 -0
- package/dist/web-ui/assets/{ChatTerminal-dv25rCIz.js → ChatTerminal-WIjnp057.js} +1 -1
- package/dist/web-ui/assets/{IssuePeek-Dh3qej2l.js → IssuePeek-DS8gwn8L.js} +61 -60
- package/dist/web-ui/assets/{ViewToggle-GsDQZY-j.js → ViewToggle-BM9Leqct.js} +1 -1
- package/dist/web-ui/assets/board-BicE8Mfe.js +1 -0
- package/dist/web-ui/assets/index-B9eBRSoV.css +2 -0
- package/dist/web-ui/assets/{index-j-izWmuG.js → index-BsVnxIKo.js} +2 -2
- package/dist/web-ui/assets/issues-Djlu09em.js +1 -0
- package/dist/web-ui/assets/routes-BmyEyMrf.js +1 -0
- package/dist/web-ui/assets/{task._taskId-BQ5h5DZ2.js → task._taskId-CmRCr8jG.js} +1 -1
- package/dist/web-ui/assets/{vendor-X3nYbtqQ.js → vendor-Bfrh7rZ5.js} +1 -1
- package/dist/web-ui/index.html +2 -2
- package/package.json +1 -1
- package/dist/web-ui/assets/AppShell-DB2eNRP2.js +0 -8
- package/dist/web-ui/assets/board-CbM3YF06.js +0 -1
- package/dist/web-ui/assets/index-LIEeaROP.css +0 -2
- package/dist/web-ui/assets/issues-BXc_TiwK.js +0 -1
- package/dist/web-ui/assets/routes-CS4Lj7ol.js +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -90,7 +90,7 @@ var init_package = __esm(() => {
|
|
|
90
90
|
package_default = {
|
|
91
91
|
$schema: "https://json.schemastore.org/package.json",
|
|
92
92
|
name: "@sma1lboy/kobe",
|
|
93
|
-
version: "0.7.
|
|
93
|
+
version: "0.7.32",
|
|
94
94
|
description: "TUI orchestrator for Claude Code (codename)",
|
|
95
95
|
type: "module",
|
|
96
96
|
packageManager: "bun@1.3.13",
|
|
@@ -7821,6 +7821,60 @@ var init_issues_store = __esm(() => {
|
|
|
7821
7821
|
locks = new Map;
|
|
7822
7822
|
});
|
|
7823
7823
|
|
|
7824
|
+
// ../kobe-daemon/src/daemon/keybindings-watcher.ts
|
|
7825
|
+
import { mkdirSync as mkdirSync2, watch } from "fs";
|
|
7826
|
+
import { homedir as homedir14 } from "os";
|
|
7827
|
+
import { basename as basename3, dirname as dirname6, join as join5 } from "path";
|
|
7828
|
+
function defaultKeybindingsPath(homeDir2 = process.env.KOBE_HOME_DIR ?? homedir14()) {
|
|
7829
|
+
return join5(homeDir2, ".kobe", "settings", "keybindings.yaml");
|
|
7830
|
+
}
|
|
7831
|
+
function startKeybindingsWatcher(bus, options = {}) {
|
|
7832
|
+
const debounceMs = options.debounceMs ?? DEFAULT_KEYBINDINGS_DEBOUNCE_MS;
|
|
7833
|
+
if (debounceMs <= 0)
|
|
7834
|
+
return () => {};
|
|
7835
|
+
const filePath = options.path ?? defaultKeybindingsPath();
|
|
7836
|
+
const dir = dirname6(filePath);
|
|
7837
|
+
const baseYaml = basename3(filePath);
|
|
7838
|
+
const baseYml = baseYaml.replace(/\.yaml$/, ".yml");
|
|
7839
|
+
let rev = 0;
|
|
7840
|
+
bus.publish("keybindings", { rev });
|
|
7841
|
+
let timer = null;
|
|
7842
|
+
const bump = () => {
|
|
7843
|
+
timer = null;
|
|
7844
|
+
try {
|
|
7845
|
+
rev += 1;
|
|
7846
|
+
bus.publish("keybindings", { rev });
|
|
7847
|
+
} catch (err) {
|
|
7848
|
+
logDaemonError("keybindings-watcher", err);
|
|
7849
|
+
}
|
|
7850
|
+
};
|
|
7851
|
+
let watcher = null;
|
|
7852
|
+
try {
|
|
7853
|
+
mkdirSync2(dir, { recursive: true });
|
|
7854
|
+
watcher = watch(dir, (_event, filename) => {
|
|
7855
|
+
if (filename !== null && filename !== baseYaml && filename !== baseYml)
|
|
7856
|
+
return;
|
|
7857
|
+
if (timer)
|
|
7858
|
+
clearTimeout(timer);
|
|
7859
|
+
timer = setTimeout(bump, debounceMs);
|
|
7860
|
+
timer.unref?.();
|
|
7861
|
+
});
|
|
7862
|
+
watcher.on("error", (err) => logDaemonError("keybindings-watcher", err));
|
|
7863
|
+
} catch (err) {
|
|
7864
|
+
logDaemonError("keybindings-watcher", err);
|
|
7865
|
+
}
|
|
7866
|
+
return () => {
|
|
7867
|
+
if (timer) {
|
|
7868
|
+
clearTimeout(timer);
|
|
7869
|
+
timer = null;
|
|
7870
|
+
}
|
|
7871
|
+
watcher?.close();
|
|
7872
|
+
watcher = null;
|
|
7873
|
+
};
|
|
7874
|
+
}
|
|
7875
|
+
var DEFAULT_KEYBINDINGS_DEBOUNCE_MS = 200;
|
|
7876
|
+
var init_keybindings_watcher = () => {};
|
|
7877
|
+
|
|
7824
7878
|
// ../kobe-daemon/src/daemon/lifetime.ts
|
|
7825
7879
|
class DaemonLifetime {
|
|
7826
7880
|
clients;
|
|
@@ -7891,60 +7945,6 @@ var defaultSchedule = (fn, ms) => {
|
|
|
7891
7945
|
};
|
|
7892
7946
|
var init_lifetime = () => {};
|
|
7893
7947
|
|
|
7894
|
-
// ../kobe-daemon/src/daemon/keybindings-watcher.ts
|
|
7895
|
-
import { mkdirSync as mkdirSync2, watch } from "fs";
|
|
7896
|
-
import { homedir as homedir14 } from "os";
|
|
7897
|
-
import { basename as basename3, dirname as dirname6, join as join5 } from "path";
|
|
7898
|
-
function defaultKeybindingsPath(homeDir2 = process.env.KOBE_HOME_DIR ?? homedir14()) {
|
|
7899
|
-
return join5(homeDir2, ".kobe", "settings", "keybindings.yaml");
|
|
7900
|
-
}
|
|
7901
|
-
function startKeybindingsWatcher(bus, options = {}) {
|
|
7902
|
-
const debounceMs = options.debounceMs ?? DEFAULT_KEYBINDINGS_DEBOUNCE_MS;
|
|
7903
|
-
if (debounceMs <= 0)
|
|
7904
|
-
return () => {};
|
|
7905
|
-
const filePath = options.path ?? defaultKeybindingsPath();
|
|
7906
|
-
const dir = dirname6(filePath);
|
|
7907
|
-
const baseYaml = basename3(filePath);
|
|
7908
|
-
const baseYml = baseYaml.replace(/\.yaml$/, ".yml");
|
|
7909
|
-
let rev = 0;
|
|
7910
|
-
bus.publish("keybindings", { rev });
|
|
7911
|
-
let timer = null;
|
|
7912
|
-
const bump = () => {
|
|
7913
|
-
timer = null;
|
|
7914
|
-
try {
|
|
7915
|
-
rev += 1;
|
|
7916
|
-
bus.publish("keybindings", { rev });
|
|
7917
|
-
} catch (err) {
|
|
7918
|
-
logDaemonError("keybindings-watcher", err);
|
|
7919
|
-
}
|
|
7920
|
-
};
|
|
7921
|
-
let watcher = null;
|
|
7922
|
-
try {
|
|
7923
|
-
mkdirSync2(dir, { recursive: true });
|
|
7924
|
-
watcher = watch(dir, (_event, filename) => {
|
|
7925
|
-
if (filename !== null && filename !== baseYaml && filename !== baseYml)
|
|
7926
|
-
return;
|
|
7927
|
-
if (timer)
|
|
7928
|
-
clearTimeout(timer);
|
|
7929
|
-
timer = setTimeout(bump, debounceMs);
|
|
7930
|
-
timer.unref?.();
|
|
7931
|
-
});
|
|
7932
|
-
watcher.on("error", (err) => logDaemonError("keybindings-watcher", err));
|
|
7933
|
-
} catch (err) {
|
|
7934
|
-
logDaemonError("keybindings-watcher", err);
|
|
7935
|
-
}
|
|
7936
|
-
return () => {
|
|
7937
|
-
if (timer) {
|
|
7938
|
-
clearTimeout(timer);
|
|
7939
|
-
timer = null;
|
|
7940
|
-
}
|
|
7941
|
-
watcher?.close();
|
|
7942
|
-
watcher = null;
|
|
7943
|
-
};
|
|
7944
|
-
}
|
|
7945
|
-
var DEFAULT_KEYBINDINGS_DEBOUNCE_MS = 200;
|
|
7946
|
-
var init_keybindings_watcher = () => {};
|
|
7947
|
-
|
|
7948
7948
|
// ../kobe-daemon/src/daemon/ui-prefs-watcher.ts
|
|
7949
7949
|
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, watch as watch2 } from "fs";
|
|
7950
7950
|
import { homedir as homedir15 } from "os";
|
|
@@ -8476,8 +8476,8 @@ var init_server = __esm(() => {
|
|
|
8476
8476
|
init_auto_title_poller();
|
|
8477
8477
|
init_handlers();
|
|
8478
8478
|
init_issues_store();
|
|
8479
|
-
init_lifetime();
|
|
8480
8479
|
init_keybindings_watcher();
|
|
8480
|
+
init_lifetime();
|
|
8481
8481
|
init_paths2();
|
|
8482
8482
|
init_protocol();
|
|
8483
8483
|
init_ui_prefs_watcher();
|
|
@@ -14945,6 +14945,9 @@ async function enginesResponse() {
|
|
|
14945
14945
|
function cliInvocationResponse() {
|
|
14946
14946
|
return Response.json({ api: kobeApiInvocation() });
|
|
14947
14947
|
}
|
|
14948
|
+
function projectsResponse() {
|
|
14949
|
+
return Response.json({ projects: getSavedRepos() });
|
|
14950
|
+
}
|
|
14948
14951
|
function stringValue(value, fallback = "") {
|
|
14949
14952
|
return typeof value === "string" ? value : fallback;
|
|
14950
14953
|
}
|
|
@@ -15117,6 +15120,8 @@ function createRequestHandler(deps) {
|
|
|
15117
15120
|
return enginesResponse();
|
|
15118
15121
|
if (url.pathname === "/api/cli-invocation" && req.method === "GET")
|
|
15119
15122
|
return cliInvocationResponse();
|
|
15123
|
+
if (url.pathname === "/api/projects" && req.method === "GET")
|
|
15124
|
+
return projectsResponse();
|
|
15120
15125
|
if (url.pathname === "/api/settings" && req.method === "GET")
|
|
15121
15126
|
return settingsSnapshot();
|
|
15122
15127
|
if (url.pathname === "/api/settings" && req.method === "PATCH")
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatTerminal-WIjnp057.js","assets/tabs-CmaDBSUQ.js","assets/terminal-CapzGZr6.js","assets/index-BsVnxIKo.js","assets/useNavigate-CXvSccc8.js","assets/index-B9eBRSoV.css","assets/vendor-Bfrh7rZ5.js","assets/ChatTerminal-kHJ-D0s7.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{S as e,_ as t,a as n,d as r,f as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,t as p,v as m,y as h}from"./tabs-CmaDBSUQ.js";import{t as g}from"./useNavigate-CXvSccc8.js";import{n as _,r as v,t as y}from"./ViewToggle-BM9Leqct.js";import{t as b}from"./terminal-CapzGZr6.js";import{a as x,d as S,f as C,g as w,i as T,l as E,n as D,o as O,p as k,r as A,u as j}from"./index-BsVnxIKo.js";import{C as ee,S as te,_ as M,a as ne,b as N,c as P,d as F,f as I,g as re,h as L,i as ie,l as ae,m as R,n as oe,o as se,p as ce,r as le,s as ue,v as de,w as z,x as B,y as fe}from"./vendor-Bfrh7rZ5.js";var pe=z(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),me=z(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),he=z(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),ge=z(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),_e=z(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),ve=z(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ye=z(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),be=z(`layout-panel-left`,[[`rect`,{width:`7`,height:`18`,x:`3`,y:`3`,rx:`1`,key:`2obqm`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}]]),xe=z(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Se=z(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),Ce=z(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),V=z(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),we=z(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Te=z(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),H=e(h(),1);function Ee(e){switch(e){case`running`:return{color:`bg-kobe-orange`,label:`running`};case`waiting_permission`:return{color:`bg-kobe-blue`,label:`needs input`};case`rate_limited`:return{color:`bg-kobe-yellow`,label:`rate limited`};case`error`:return{color:`bg-kobe-red`,label:`error`};case`idle`:return{color:`bg-kobe-green/60`,label:`idle`};default:return{color:`bg-subtle`,label:``}}}function De(e){return Ee(e).color}function Oe(e){return Ee(e).label}function ke(e,t=36){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}var Ae={query:``,statusFilter:`all`,sortMode:`default`,showArchived:!1},je=null,Me=new Set;function U(e){Ae={...Ae,...e};for(let e of Me)e()}function W(e){U({query:e})}function Ne(e){U({statusFilter:e})}function Pe(e){U({sortMode:e})}function Fe(e){U({showArchived:e})}function Ie(e){!e||e===je||(je=e,U({sortMode:e}))}function Le(){return Ae}function Re(){return(0,H.useSyncExternalStore)(e=>(Me.add(e),()=>Me.delete(e)),Le,Le)}function ze(e){let t=Date.parse(e.updatedAt||e.createdAt);return Number.isFinite(t)?t:0}function Be(e,t){let n=ze(t)-ze(e);return n===0?t.id.localeCompare(e.id):n}function Ve(e,t){let n=e.filter(e=>e.kind===`main`),r=e.filter(e=>e.kind!==`main`&&e.pinned),i=e.filter(e=>e.kind!==`main`&&!e.pinned);return t===`recent`&&(r.sort(Be),i.sort(Be)),[...n,...r,...i]}function He(e,t){return N([e.title,e.branch,e.repo,e.worktreePath,e.vendor,e.status].filter(Boolean).join(` `),t)}function Ue(e,t=Date.now()){if(!e)return``;let n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return`just now`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function We(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));if(r<45)return`now`;let i=Math.round(r/60);if(i<60)return`${i}m`;let a=Math.round(i/60);if(a<24)return`${a}h`;let o=Math.round(a/24);if(o<7)return`${o}d`;let s=Math.round(o/7);if(s<5)return`${s}w`;let c=Math.round(o/30);return c<12?`${c}mo`:`${Math.round(o/365)}y`}var G=w();function K({children:e}){return(0,G.jsx)(`div`,{className:`mb-1 text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:e})}var q=`w-full border border-line bg-bg px-2 py-1.5 text-[12px] text-fg placeholder:text-subtle focus:border-line-active focus:outline-none`;function Ge({onClose:e}){let{tasks:t}=A(),n=se(),r=g(),a=(0,H.useRef)(null);I(a);let o=(0,H.useMemo)(()=>{let e=new Set,n=[];for(let r of t){let t=r.repo;t&&!e.has(t)&&(e.add(t),n.push(t))}return n.sort()},[t]),[s,u]=(0,H.useState)(o[0]??``),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(``),[h,_]=(0,H.useState)(``),[v,y]=(0,H.useState)(``),[b,x]=(0,H.useState)(n[0]?.id??`claude`),[S,C]=(0,H.useState)(!1),[w,T]=(0,H.useState)(``),[E,O]=(0,H.useState)(!1),k=s.trim().length>0&&!E;(0,H.useEffect)(()=>{let e=!1;return M().then(t=>{e||!t||S||x(t)}),()=>{e=!0}},[S]);let j=async()=>{if(k){O(!0);try{let t={repo:s.trim()};p.trim()&&(t.title=p.trim()),h.trim()&&(t.branch=h.trim()),v.trim()&&(t.baseRef=v.trim()),b&&(t.vendor=b);let{taskId:n,task:a}=await D(`task.create`,t);i(n);let o=w.trim();o&&(c(n,o),l(n)),r({to:`/task/$taskId`,params:{taskId:n}}),await D(`task.setActive`,{taskId:n}).catch(()=>{}),R(`success`,`Task created: ${a?.title||a?.branch||n}`),e()}catch(e){L(`create task`,e)}finally{O(!1)}}};return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-black/60`,onClick:e,onKeyDown:t=>{t.key===`Escape`&&e()},role:`presentation`,children:(0,G.jsxs)(`div`,{ref:a,role:`dialog`,"aria-modal":`true`,"aria-label":`New task`,className:`w-[28rem] max-w-[calc(100vw-2rem)] border border-line bg-surface shadow-xl`,onClick:e=>e.stopPropagation(),onKeyDown:()=>{},children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-fg`,children:`New Task`}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-subtle`,children:`worktree + engine session`})]}),(0,G.jsxs)(`form`,{className:`space-y-3 px-3 py-3`,onSubmit:e=>{e.preventDefault(),j()},children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{children:`Repo`}),o.length>0&&!d?(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`select`,{value:s,onChange:e=>u(e.target.value),className:`${q} min-w-0 flex-1`,children:o.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{f(!0),u(``)},className:`shrink-0 border border-line bg-bg px-2 text-[11px] text-muted hover:border-primary hover:text-fg`,title:`Type a repo path instead`,children:`path…`})]}):(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{value:s,onChange:e=>u(e.target.value),placeholder:`/absolute/path/to/repo`,className:`${q} min-w-0 flex-1 font-mono`}),o.length>0&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{f(!1),u(o[0]??``)},className:`shrink-0 border border-line bg-bg px-2 text-[11px] text-muted hover:border-primary hover:text-fg`,title:`Pick a known repo`,children:`list`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{children:`Title`}),(0,G.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`optional — auto-titled from the first message`,className:q})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{children:`Branch`}),(0,G.jsx)(`input`,{value:h,onChange:e=>_(e.target.value),placeholder:`auto`,className:`${q} font-mono`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{children:`Base ref`}),(0,G.jsx)(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:`default branch`,className:`${q} font-mono`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{children:`Engine`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>{C(!0),x(e.id)},className:`border px-2 py-1 text-[11px] transition-colors ${b===e.id?`border-primary bg-inset text-fg`:`border-line bg-bg text-muted hover:border-primary hover:text-fg`}`,children:oe(n,e.id)},e.id))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(K,{children:`First prompt`}),(0,G.jsx)(`textarea`,{value:w,onChange:e=>T(e.target.value),placeholder:`optional — waits in the engine composer, ready to send`,rows:2,className:`${q} resize-none`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-line pt-3`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`border border-line bg-bg px-3 py-1.5 text-[11px] text-muted transition-colors hover:border-primary hover:text-fg`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`submit`,disabled:!k,className:`border border-primary bg-inset px-3 py-1.5 text-[11px] text-fg transition-colors hover:bg-primary/10 disabled:opacity-40`,children:E?`Creating…`:`Create task`})]})]})]})})}function Ke({onClose:e}){let{tasks:t}=A(),n=g(),r=(0,H.useRef)(null);I(r);let a=(0,H.useMemo)(()=>{let e=new Set,n=[];for(let r of t)r.repo&&!e.has(r.repo)&&(e.add(r.repo),n.push(r.repo));return n.sort()},[t]),o=(0,H.useMemo)(()=>new Set(t.map(e=>e.worktreePath).filter(Boolean)),[t]),[s,c]=(0,H.useState)(a[0]??``),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null),[h,_]=(0,H.useState)(!1),v=async e=>{if(e){f(!0),u(null);try{let{worktrees:t}=await D(`worktree.discoverAdoptable`,{repo:e});u(t)}catch(e){L(`scan worktrees`,e),u([])}finally{f(!1)}}},y=async t=>{m(t.path);try{let{task:r}=await D(`worktree.adopt`,{repo:s,worktreePath:t.path,branch:t.branch,ifExists:`return`});i(r.id),D(`task.setActive`,{taskId:r.id}).catch(()=>{}),n({to:`/task/$taskId`,params:{taskId:r.id}}),R(`success`,`Adopted ${t.branch||t.path}`),e()}catch(e){L(`adopt worktree`,e)}finally{m(null)}};return h?(0,G.jsx)(Ge,{onClose:e}):a.length===0?(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-black/60`,onClick:e,onKeyDown:t=>{t.key===`Escape`&&e()},role:`presentation`,children:(0,G.jsxs)(`div`,{ref:r,role:`dialog`,"aria-modal":`true`,"aria-label":`Adopt worktree`,className:`flex w-[32rem] max-w-[calc(100vw-2rem)] flex-col border border-line bg-surface shadow-xl`,onClick:e=>e.stopPropagation(),onKeyDown:()=>{},children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-fg`,children:`Adopt worktree`}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-subtle`,children:`pull an existing worktree into kobe`})]}),(0,G.jsxs)(`div`,{className:`px-3 py-6 text-center`,children:[(0,G.jsx)(`p`,{className:`text-[12px] leading-relaxed text-subtle`,children:`No repos known to kobe yet. Create a task in a repo first, then come back to adopt its worktrees.`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>_(!0),className:`mt-4 border border-primary bg-inset px-3 py-1.5 text-[11px] text-fg transition-colors hover:bg-primary/10`,children:`Create a task`})]}),(0,G.jsx)(`div`,{className:`flex justify-end border-t border-line px-3 py-2`,children:(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`border border-line bg-bg px-3 py-1.5 text-[11px] text-muted transition-colors hover:border-primary hover:text-fg`,children:`Close`})})]})}):(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-black/60`,onClick:e,onKeyDown:t=>{t.key===`Escape`&&e()},role:`presentation`,children:(0,G.jsxs)(`div`,{ref:r,role:`dialog`,"aria-modal":`true`,"aria-label":`Adopt worktree`,className:`flex max-h-[80vh] w-[32rem] max-w-[calc(100vw-2rem)] flex-col border border-line bg-surface shadow-xl`,onClick:e=>e.stopPropagation(),onKeyDown:()=>{},children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-fg`,children:`Adopt worktree`}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-subtle`,children:`pull an existing worktree into kobe`})]}),(0,G.jsxs)(`div`,{className:`space-y-2 px-3 py-3`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Repo`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`select`,{value:s,onChange:e=>c(e.target.value),className:`min-w-0 flex-1 border border-line bg-bg px-2 py-1.5 text-[12px] text-fg focus:border-line-active focus:outline-none`,children:a.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void v(s),disabled:!s||d,className:`shrink-0 border border-primary bg-inset px-3 py-1.5 text-[11px] text-fg transition-colors hover:bg-primary/10 disabled:opacity-40`,children:d?`Scanning…`:`Scan`})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto border-t border-line`,children:l===null?(0,G.jsx)(`p`,{className:`px-3 py-6 text-center text-[12px] text-subtle`,children:`Pick a repo and Scan to find adoptable worktrees.`}):l.length===0?(0,G.jsx)(`p`,{className:`px-3 py-6 text-center text-[12px] text-subtle`,children:`No adoptable worktrees found for this repo.`}):l.map(e=>{let t=o.has(e.path);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line-subtle px-3 py-2 last:border-b-0`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate font-mono text-[12px] text-fg`,children:e.branch||`(detached)`}),e.dirty&&(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] text-kobe-yellow`,children:`dirty`}),e.kobeManaged&&(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] text-subtle`,children:`kobe`})]}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] text-subtle`,children:[(0,G.jsx)(`span`,{className:`truncate font-mono`,children:e.path}),e.lastActivityMs>0&&(0,G.jsx)(`span`,{className:`ml-auto shrink-0`,children:Ue(e.lastActivityMs)})]})]}),t?(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] text-subtle`,children:`tracked`}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>void y(e),disabled:p!==null,className:`shrink-0 border border-line bg-bg px-2 py-1 text-[11px] text-muted transition-colors hover:border-primary hover:text-fg disabled:opacity-40`,children:p===e.path?`Adopting…`:`Adopt`})]},e.path)})}),(0,G.jsx)(`div`,{className:`flex justify-end border-t border-line px-3 py-2`,children:(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`border border-line bg-bg px-3 py-1.5 text-[11px] text-muted transition-colors hover:border-primary hover:text-fg`,children:`Close`})})]})})}function qe(e,t){if(!e)return 0;let n=e.toLowerCase(),r=t.toLowerCase(),i=0,a=0,o=-1;for(let e=0;e<r.length&&i<n.length;e++)r[e]===n[i]&&(a+=e-o,o=e,i++);return i===n.length?a:null}function Je(e){return e.filter(e=>!e.archived).sort((e,t)=>{let n=Date.parse(e.updatedAt||e.createdAt)||0,r=Date.parse(t.updatedAt||t.createdAt)||0;return r===n?t.id.localeCompare(e.id):r-n})}function Ye({kind:e}){return e===`new`?(0,G.jsx)(ee,{size:14,strokeWidth:2}):e===`settings`?(0,G.jsx)(we,{size:14,strokeWidth:1.8}):e===`board`?(0,G.jsx)(v,{size:14,strokeWidth:1.8}):e===`workspace`?(0,G.jsx)(be,{size:14,strokeWidth:1.8}):(0,G.jsx)(pe,{size:14,strokeWidth:1.8})}function Xe({open:e,onClose:n,onNewTask:r,onOpenSettings:a}){let{tasks:o,engineStates:s}=A(),{selectedTaskId:c}=t(),l=g(),[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(0),m=(0,H.useRef)(null),h=(0,H.useRef)(null),_=(0,H.useRef)(null);I(h,e),(0,H.useEffect)(()=>{_.current?.querySelector(`[data-index="${f}"]`)?.scrollIntoView({block:`nearest`})},[f]),(0,H.useEffect)(()=>{e&&(d(``),p(0),requestAnimationFrame(()=>m.current?.focus()))},[e]);let v=(0,H.useMemo)(()=>[{id:`action:new`,label:`New task`,hint:`create`,icon:`new`,run:()=>{r(),n()}},{id:`action:board`,label:`Open board`,hint:`kanban`,icon:`board`,run:()=>{l({to:`/board`}),n()}},{id:`action:workspace`,label:`Open workspace`,hint:`workspace`,icon:`workspace`,run:()=>{l(c?{to:`/task/$taskId`,params:{taskId:c}}:{to:`/`}),n()}},{id:`action:settings`,label:`Open settings`,hint:`settings`,icon:`settings`,run:()=>{a(),n()}},...Je(o).map(e=>({id:`task:${e.id}`,label:e.title||e.branch||e.id,hint:e.kind===`main`?`project`:e.branch,icon:`task`,taskId:e.id,run:()=>{i(e.id),D(`task.setActive`,{taskId:e.id}).catch(e=>L(`switch task`,e)),l({to:`/task/$taskId`,params:{taskId:e.id}}),n()}}))],[o,c,l,n,r,a]),y=(0,H.useMemo)(()=>u.trim()?v.map(e=>{let t=`${e.label} ${e.hint??``}`,n=qe(u.trim(),t);return n===null?null:{cmd:e,score:n}}).filter(e=>e!==null).sort((e,t)=>e.score-t.score).map(e=>e.cmd):v,[v,u]);return(0,H.useEffect)(()=>{p(e=>Math.min(e,Math.max(0,y.length-1)))},[y.length]),e?(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-black/50 pt-[12vh]`,onClick:n,onKeyDown:()=>{},role:`presentation`,children:(0,G.jsxs)(`div`,{ref:h,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:`w-[34rem] max-w-[calc(100vw-2rem)] overflow-hidden border border-line bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),onKeyDown:()=>{},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-2.5`,children:[(0,G.jsx)(te,{size:15,strokeWidth:1.8,className:`shrink-0 text-subtle`}),(0,G.jsx)(`input`,{ref:m,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),p(e=>Math.min(e+1,y.length-1))):e.key===`ArrowUp`?(e.preventDefault(),p(e=>Math.max(e-1,0))):e.key===`Enter`?(e.preventDefault(),y[f]?.run()):e.key===`Escape`&&(e.preventDefault(),n())},placeholder:`Jump to a task or run a command…`,className:`min-w-0 flex-1 bg-transparent text-[13px] text-fg placeholder:text-subtle focus:outline-none`}),(0,G.jsx)(`kbd`,{className:`shrink-0 border border-line px-1.5 py-0.5 font-mono text-[10px] text-subtle`,children:`esc`})]}),(0,G.jsx)(`div`,{ref:_,className:`max-h-[50vh] overflow-y-auto py-1`,children:y.length===0?(0,G.jsxs)(`div`,{className:`px-3 py-6 text-center text-[12px] text-subtle`,children:[`No matches for “`,u,`”.`]}):y.map((e,t)=>(0,G.jsxs)(`button`,{type:`button`,"data-index":t,onClick:e.run,onMouseMove:()=>p(t),className:`flex w-full items-center gap-3 px-3 py-2 text-left ${t===f?`bg-inset`:`hover:bg-inset/50`}`,children:[e.taskId?(0,G.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${De(s[e.taskId]?.state)}`}):(0,G.jsx)(`span`,{className:`shrink-0 ${t===f?`text-primary`:`text-subtle`}`,children:(0,G.jsx)(Ye,{kind:e.icon})}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] text-fg`,children:e.label}),e.hint&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-subtle`,children:e.hint})]},e.id))}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-line px-3 py-1.5 font-mono text-[10px] text-subtle`,children:[(0,G.jsx)(`span`,{children:`↑↓ move`}),(0,G.jsx)(`span`,{children:`↵ run`}),(0,G.jsx)(`span`,{children:`esc close`})]})]})}):null}var Ze=[{keys:[`⌘`,`K`],label:`Command palette — jump to a task or run an action`},{keys:[`j`,`k`],label:`Move between tasks in the rail (also ↑ / ↓)`},{keys:[`/`],label:`Focus the task filter — then ↵ jumps to the top match, esc clears`},{keys:[`?`],label:`This help`},{keys:[`esc`],label:`Close a dialog / palette / help`}],Qe=[{keys:[`↑`,`↓`],label:`Move selection`},{keys:[`↵`],label:`Run the selected command`}],$e=[{keys:[`↑`,`↓`],label:`Recall previously-sent prompts (newest first)`},{keys:[`↵`],label:`Send · Shift+↵ for a newline`}],et=[{label:`New task`,detail:`the + in the task rail (or palette → New task)`},{label:`Adopt worktree`,detail:`the folder-in icon next to + — pull an existing worktree in`},{label:`Chat / Vendor / Terminal`,detail:`tab kinds inside a task workspace; Chat has search and a hide-tools toggle`},{label:`Triage`,detail:`task rail status chips (All/Needs) + the Board — filter by what needs you`},{label:`Changes / diff`,detail:`filter files by path, toggle line wrap on a file preview`},{label:`Notifications`,detail:`Settings → Notifications — get pinged when a task needs you`}];function tt({k:e}){return(0,G.jsx)(`kbd`,{className:`inline-flex min-w-[1.4rem] items-center justify-center border border-line bg-inset px-1.5 py-0.5 font-mono text-[11px] text-fg`,children:e})}function nt({keys:e,label:t}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,G.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:e.map(e=>(0,G.jsx)(tt,{k:e},e))}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 text-[12px] text-muted`,children:t})]})}function rt({onClose:e}){let t=(0,H.useRef)(null);return I(t),(0,H.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,onClick:e,onKeyDown:()=>{},role:`presentation`,children:(0,G.jsxs)(`div`,{ref:t,role:`dialog`,"aria-modal":`true`,"aria-label":`Keyboard shortcuts`,className:`w-[30rem] max-w-[calc(100vw-2rem)] border border-line bg-surface shadow-xl`,onClick:e=>e.stopPropagation(),onKeyDown:()=>{},children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-fg`,children:`Keyboard & shortcuts`}),(0,G.jsx)(`kbd`,{className:`border border-line px-1.5 py-0.5 font-mono text-[10px] text-subtle`,children:`esc`})]}),(0,G.jsxs)(`div`,{className:`space-y-4 px-4 py-3`,children:[(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Global`}),Ze.map(e=>(0,G.jsx)(nt,{...e},e.label))]}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`In the command palette`}),Qe.map(e=>(0,G.jsx)(nt,{...e},e.label))]}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`In the engine composer`}),$e.map(e=>(0,G.jsx)(nt,{...e},e.label))]}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Where things are`}),et.map(e=>(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 py-0.5 text-[12px]`,children:[(0,G.jsx)(`span`,{className:`shrink-0 font-semibold text-fg`,children:e.label}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 text-subtle`,children:e.detail})]},e.label))]})]})]})})}async function it(){try{let e=await fetch(`/api/quick-prompts`);if(!e.ok)return{review:null,pr:null};let t=await e.json();return{review:typeof t.review==`string`?t.review:null,pr:typeof t.pr==`string`?t.pr:null}}catch{return{review:null,pr:null}}}async function at(e){let t=await fetch(`/api/quick-prompts`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(`save failed (${t.status})`)}function ot(e){return ne(e)===`claude`?`/review`:`Review the current changes in this worktree critically.`}var st=[`Open a pull request for this task's branch:`,`1. Make sure the work is committed, then push the branch to origin.`,"2. Create the PR with `gh pr create` — write a clear title and a body that summarizes what changed and why, following this repo's conventions."].join(`
|
|
3
|
+
`);function ct({palette:e}){return(0,G.jsx)(`span`,{className:`flex shrink-0 overflow-hidden rounded border border-line`,children:[e.bg,e.primary,e[`kobe-blue`],e[`kobe-green`]].filter(Boolean).map((e,t)=>(0,G.jsx)(`span`,{className:`h-5 w-3`,style:{backgroundColor:e}},t))})}function lt(){let{names:e,palettes:t,active:n,overridden:r}=O();return(0,G.jsxs)(`div`,{className:`border border-line bg-surface p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Appearance`}),r?(0,G.jsx)(`button`,{type:`button`,onClick:T,className:`border border-line bg-bg px-2 py-0.5 text-[10px] text-muted transition-colors hover:border-primary hover:text-fg`,title:`Clear the web-local theme and follow the TUI again`,children:`Follow TUI`}):(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-subtle`,children:`following TUI`})]}),e.length===0?(0,G.jsx)(`p`,{className:`mt-4 text-[12px] text-subtle`,children:`Loading themes…`}):(0,G.jsx)(`div`,{className:`mt-4 grid grid-cols-1 gap-1.5 sm:grid-cols-2`,children:e.map(e=>{let r=e===n;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>x(e),className:`flex items-center gap-2 border px-2 py-1.5 text-left transition-colors ${r?`border-primary bg-inset`:`border-line bg-bg hover:border-primary`}`,children:[(0,G.jsx)(ct,{palette:t[e]??{}}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12px] ${r?`text-fg`:`text-muted`}`,children:e}),r&&(0,G.jsx)(he,{size:13,strokeWidth:2.5,className:`shrink-0 text-primary`})]},e)})})]})}var ut=[[`general`,`General`],[`engines`,`Engines`],[`board`,`Board`],[`dev`,`Dev`],[`notifications`,`Notifications`]];function J({title:e,children:t}){return(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`h2`,{className:`text-[11px] font-bold uppercase tracking-[0.12em] text-subtle`,children:e}),(0,G.jsx)(`div`,{className:`mt-3 space-y-3 text-[12px]`,children:t})]})}function Y({label:e,detail:t,enabled:n,onToggle:r,disabled:i}){return(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border border-line bg-bg p-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-[12px] font-bold text-fg`,children:e}),t?(0,G.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed text-subtle`,children:t}):null]}),(0,G.jsx)(`button`,{type:`button`,onClick:r,disabled:i,className:`shrink-0 border px-2 py-0.5 text-[10px] transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${n?`border-primary bg-inset text-fg`:`border-line bg-surface text-muted hover:border-primary hover:text-fg`}`,children:n?`On`:`Off`})]})}function dt(){let[e,t]=(0,H.useState)(null),[n,r]=(0,H.useState)(!0),[i,a]=(0,H.useState)(!1),o=(0,H.useRef)(0),s=(0,H.useCallback)(async()=>{let e=++o.current;r(!0),a(!1);try{let n=await de();e===o.current&&t(n)}catch(t){e===o.current&&a(!0),L(`load settings`,t)}finally{e===o.current&&r(!1)}},[]);return(0,H.useEffect)(()=>{s()},[s]),{settings:e,loading:n,error:i,reload:s,patch:async e=>{let n=await fe(e);return t(n),n}}}function ft(){return(0,G.jsx)(`div`,{className:`space-y-6`,children:(0,G.jsxs)(J,{title:`Dashboard theme`,children:[(0,G.jsx)(`p`,{className:`text-[11px] leading-relaxed text-subtle`,children:`Pick a theme for this browser, or follow the TUI's theme. This is a browser-local override — it never changes the TUI.`}),(0,G.jsx)(lt,{})]})})}function pt({engine:e,onSave:t,onDefault:n,onRemove:r}){let[i,a]=(0,H.useState)(e.command),[o,s]=(0,H.useState)(e.label),c=/\s--[A-Za-z0-9][\w-]*/.test(o)&&!/\s--[A-Za-z0-9][\w-]*/.test(i);return(0,H.useEffect)(()=>{a(e.command),s(e.label)},[e.command,e.label]),(0,G.jsxs)(`div`,{className:`border border-line bg-bg p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-bold text-fg`,children:e.label}),e.isDefault?(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-primary`,children:`default`}):null,e.isCustom?(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-subtle`,children:`custom`}):null]}),(0,G.jsx)(`div`,{className:`font-mono text-[10px] text-subtle`,children:e.id})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),className:`shrink-0 border border-line bg-surface px-2 py-1 text-[11px] text-muted transition-colors hover:border-primary hover:text-fg`,children:`Make default`})]}),(0,G.jsxs)(`label`,{className:`mt-3 block`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-muted`,children:`Display name (label only)`}),(0,G.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),className:`mt-1 w-full border border-line bg-surface px-2 py-1 text-fg focus:border-line-active focus:outline-none`})]}),(0,G.jsxs)(`label`,{className:`mt-2 block`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-muted`,children:`Launch command (argv that kobe runs)`}),(0,G.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),className:`mt-1 w-full border border-line bg-surface px-2 py-1 font-mono text-fg focus:border-line-active focus:outline-none`})]}),c?(0,G.jsx)(`div`,{className:`mt-2 border border-kobe-yellow/40 bg-kobe-yellow/10 px-2 py-1 text-[11px] leading-relaxed text-kobe-yellow`,children:`This looks like a flag in the display name. Put permission/model flags in Launch command; the label is never executed.`}):null,(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,i,o),className:`border border-primary bg-inset px-2 py-1 text-[11px] text-fg`,children:`Save`}),e.isCustom?(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:`border border-kobe-red/40 bg-kobe-red/10 px-2 py-1 text-[11px] text-kobe-red`,children:`Remove`}):null]})]})}function mt({settings:e,patch:t}){let[n,r]=(0,H.useState)(``),[i,a]=(0,H.useState)(``),[o,s]=(0,H.useState)(``),c=(e,n,r)=>void t({engineUpdates:[{id:e,command:n,label:r}]}).then(()=>R(`success`,`engine saved`));return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(J,{title:`Launch commands`,children:[(0,G.jsx)(`p`,{className:`text-[11px] leading-relaxed text-subtle`,children:`Same shared engine settings as the TUI. Built-ins can be renamed or pointed at a different command. Permission/model flags must live in Launch command, not Display name. Custom engines are available in new task and tab pickers.`}),(0,G.jsx)(`div`,{className:`space-y-2`,children:e.engines.map(e=>(0,G.jsx)(pt,{engine:e,onSave:c,onDefault:e=>void t({defaultEngine:e}).then(()=>R(`success`,`default engine saved`)),onRemove:e=>void t({removeEngine:e}).then(()=>R(`success`,`engine removed`))},e.id))})]}),(0,G.jsxs)(J,{title:`Add engine`,children:[(0,G.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,G.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`id, e.g. aider`,className:`border border-line bg-bg px-2 py-1 text-fg placeholder:text-subtle focus:border-line-active focus:outline-none`}),(0,G.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:`command`,className:`border border-line bg-bg px-2 py-1 font-mono text-fg placeholder:text-subtle focus:border-line-active focus:outline-none`}),(0,G.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`display name`,className:`border border-line bg-bg px-2 py-1 text-fg placeholder:text-subtle focus:border-line-active focus:outline-none`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void t({addEngine:{id:n,command:i,label:o}}).then(()=>{r(``),a(``),s(``),R(`success`,`engine added`)}).catch(e=>L(`add engine`,e)),className:`border border-primary bg-inset px-2 py-1 text-[11px] text-fg`,children:`Add engine`})]})]})}function ht(){let[e,t]=(0,H.useState)(``),[n,r]=(0,H.useState)(``),[i,a]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{let e=!1;return it().then(n=>{e||(t(n.review??``),r(n.pr??``),a(!0))}).catch(t=>{e||L(`load quick-action templates`,t)}),()=>{e=!0}},[]),(0,G.jsxs)(J,{title:`Board quick actions`,children:[(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`text-muted`,children:`Review template`}),(0,G.jsx)(`textarea`,{value:e,onChange:e=>t(e.target.value),placeholder:`default: ${ot(`claude`)}`,rows:3,disabled:!i,className:`mt-1 w-full resize-y border border-line bg-bg p-2 font-mono text-[12px] text-fg placeholder:text-subtle focus:border-line-active focus:outline-none`})]}),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`text-muted`,children:`Open-PR template`}),(0,G.jsx)(`textarea`,{value:n,onChange:e=>r(e.target.value),placeholder:`default:\n${st}`,rows:5,disabled:!i,className:`mt-1 w-full resize-y border border-line bg-bg p-2 font-mono text-[12px] text-fg placeholder:text-subtle focus:border-line-active focus:outline-none`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-subtle`,children:`Empty = built-in default. kobe appends its status/URL guardrails at send time.`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void at({review:e,pr:n}).then(()=>R(`success`,`quick-action templates saved`)).catch(e=>L(`save templates`,e)),disabled:!i,className:`shrink-0 border border-line bg-bg px-2 py-1 text-[11px] text-muted transition-colors hover:border-primary hover:text-fg`,children:`Save`})]})]})}function gt({settings:e,patch:t}){let[n,i]=(0,H.useState)(!1),a=g();return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(J,{title:`Experimental gates`,children:[(0,G.jsx)(Y,{label:`Remote projects`,detail:`Enables SSH-backed remote project setup in the CLI.`,enabled:e.remoteProjects,onToggle:()=>void t({remoteProjects:!e.remoteProjects})}),(0,G.jsx)(Y,{label:`Auto status flow`,detail:`Moves backlog tasks to in progress on turn start and injects the self-report protocol.`,enabled:e.autoStatus,onToggle:()=>void t({autoStatus:!e.autoStatus})}),(0,G.jsx)(Y,{label:`Dispatcher`,detail:`Enables the field-notes dispatcher protocol for repo main sessions.`,enabled:e.dispatcher,onToggle:()=>void t({dispatcher:!e.dispatcher})})]}),(0,G.jsxs)(J,{title:`Browser workspace`,children:[(0,G.jsx)(`p`,{className:`text-[11px] leading-relaxed text-subtle`,children:`Reset the per-task tab layout (open tabs, splits, selection). Pure browser state: tasks, worktrees, notes, and engines are untouched.`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{if(!n){i(!0);return}r(),a({to:`/`}),i(!1)},onBlur:()=>i(!1),className:`border px-3 py-1.5 text-[11px] transition-colors ${n?`border-kobe-red/50 bg-kobe-red/10 text-kobe-red`:`border-line bg-bg text-muted hover:border-primary hover:text-fg`}`,children:n?`Click again to reset layout`:`Reset layout`})]})]})}function _t(){let{supported:e,permission:t,enabled:n}=S();return(0,G.jsx)(`div`,{className:`space-y-6`,children:(0,G.jsxs)(J,{title:`Notifications`,children:[e?(0,G.jsx)(Y,{label:`Desktop notifications`,detail:`Get pinged when a task needs input or errors while this browser tab is in the background.`,enabled:n,onToggle:()=>void E(!n),disabled:t===`denied`&&!n}):(0,G.jsx)(`p`,{className:`text-[11px] leading-relaxed text-subtle`,children:`This browser does not support desktop notifications.`}),t===`denied`&&!n?(0,G.jsx)(`p`,{className:`text-[11px] leading-relaxed text-kobe-yellow`,children:`Notifications are blocked for this site. Allow them in your browser's site settings to turn this on.`}):null]})})}function vt({onClose:e}){let[t,n]=(0,H.useState)(`general`),{settings:r,loading:i,error:a,reload:o,patch:s}=dt(),c=(0,H.useMemo)(()=>ut.find(([e])=>e===t)?.[1]??`Settings`,[t]);return(0,G.jsxs)(`section`,{"data-settings-open":!0,className:`flex min-w-0 flex-1 flex-col bg-bg`,children:[(0,G.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center justify-between border-b border-line bg-surface px-3`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-fg`,children:`Settings`}),(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`border border-line bg-bg px-2 py-1 text-[11px] text-muted transition-colors hover:border-primary hover:text-fg`,children:`Close`})]}),(0,G.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[180px_minmax(0,1fr)] overflow-hidden`,children:[(0,G.jsx)(`nav`,{className:`min-h-0 overflow-auto border-r border-line bg-surface/60 p-2`,children:ut.map(([e,r])=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`mb-1 block w-full border px-2 py-2 text-left text-[12px] transition-colors ${t===e?`border-primary bg-inset text-fg`:`border-transparent text-muted hover:border-line hover:bg-bg hover:text-fg`}`,children:r},e))}),(0,G.jsx)(`main`,{className:`min-h-0 overflow-auto p-4`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,G.jsx)(`h1`,{className:`mb-3 text-[13px] font-bold uppercase tracking-[0.12em] text-fg`,children:c}),a?(0,G.jsxs)(`div`,{className:`border border-line bg-surface p-4 text-[12px]`,children:[(0,G.jsx)(`p`,{className:`text-subtle`,children:`Couldn't load settings (daemon/bridge offline?)`}),(0,G.jsx)(`button`,{type:`button`,onClick:o,className:`mt-3 border border-line bg-bg px-2 py-1 text-[11px] text-muted transition-colors hover:border-primary hover:text-fg`,children:`Retry`})]}):i||!r?(0,G.jsx)(`div`,{className:`border border-line bg-surface p-4 text-[12px] text-subtle`,children:`Loading settings...`}):t===`general`?(0,G.jsx)(ft,{}):t===`engines`?(0,G.jsx)(mt,{settings:r,patch:s}):t===`board`?(0,G.jsx)(ht,{}):t===`dev`?(0,G.jsx)(gt,{settings:r,patch:s}):(0,G.jsx)(_t,{})]})})]})]})}function yt(e){switch(e){case`error`:return`border-kobe-red/50 text-kobe-red`;case`success`:return`border-kobe-green/50 text-kobe-green`;default:return`border-line text-fg`}}function bt(){let e=re();return e.length===0?null:(0,G.jsx)(`div`,{className:`pointer-events-none fixed bottom-10 right-3 z-50 flex w-80 flex-col gap-2`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`pointer-events-auto flex items-start gap-2 border bg-surface px-3 py-2 shadow-lg ${yt(e.kind)}`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-[12px] leading-relaxed`,children:e.message}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>ce(e.id),className:`shrink-0 text-subtle hover:text-fg`,"aria-label":`dismiss notification`,children:(0,G.jsx)(B,{size:13,strokeWidth:2})})]},e.id))})}async function xt(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}async function St(e,t={}){let n=new URLSearchParams({worktreePath:e});t.path&&n.set(`path`,t.path),t.namesOnly&&n.set(`namesOnly`,`1`);let r=await fetch(`/api/diff?${n.toString()}`),i=await r.json();if(!r.ok||i.error)throw Error(i.error??`diff fetch failed (${r.status})`);return{files:i.files??[],raw:i.raw??``}}function Ct(e){switch(e){case`added`:return{label:`A`,cls:`text-kobe-green`};case`untracked`:return{label:`U`,cls:`text-kobe-green`};case`modified`:return{label:`M`,cls:`text-kobe-yellow`};case`deleted`:return{label:`D`,cls:`text-kobe-red`};case`renamed`:return{label:`R`,cls:`text-kobe-blue`};case`copied`:return{label:`C`,cls:`text-kobe-blue`};default:return{label:e.slice(0,1).toUpperCase()||`?`,cls:`text-muted`}}}function wt(e){switch(e){case`hunk`:return`kobe-diff-hunk`;case`meta`:return`kobe-diff-meta`;case`add`:return`kobe-diff-add`;case`del`:return`kobe-diff-del`;default:return`kobe-diff-ctx`}}function Tt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Et(e){let t=e.replace(/\*+/g,`*`).split(`*`).map(Tt).join(`.*`);return RegExp(`^${t}$`)}function Dt(e,t){let n=t.trim(),r=n.startsWith(`!`),i=(r?n.slice(1):n).trim().toLowerCase();if(!i)return!0;let a=e.toLowerCase(),o=i.includes(`*`)?Et(i).test(a):a.includes(i);return r?!o:o}function Ot(e,t){let n=t.trim();return n?e.filter(e=>Dt(e.path,n)):e}var kt=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,At=[`diff --git`,`index `,`--- `,`+++ `,`new file`,`deleted file`,`rename `,`similarity `,`copy `,`\\ No newline`,`Binary files`];function jt(e){return At.some(t=>e.startsWith(t))}function Mt(e){let t=0,n=0;for(let r of Nt(e))r.kind===`add`?t++:r.kind===`del`&&n++;return{added:t,deleted:n}}function Nt(e){let t=e.replace(/\n$/,``).split(`
|
|
4
|
+
`),n=[],r=0,i=0,a=!1;for(let e of t){let t=kt.exec(e);if(t){r=Number.parseInt(t[1],10),i=Number.parseInt(t[2],10),a=!0,n.push({kind:`hunk`,oldLn:null,newLn:null,text:e});continue}if(e.startsWith(`diff --git`)&&(a=!1),e===``||!a&&jt(e)){n.push({kind:`meta`,oldLn:null,newLn:null,text:e});continue}let o=e[0];o===`+`?(n.push({kind:`add`,oldLn:null,newLn:i,text:e}),i++):o===`-`?(n.push({kind:`del`,oldLn:r,newLn:null,text:e}),r++):jt(e)?n.push({kind:`meta`,oldLn:null,newLn:null,text:e}):(n.push({kind:`ctx`,oldLn:r,newLn:i,text:e}),r++,i++)}return n}function Pt({added:e,deleted:t}){return e===0&&t===0?null:(0,G.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px]`,children:[(0,G.jsxs)(`span`,{className:`text-kobe-green`,children:[`+`,e]}),` `,(0,G.jsxs)(`span`,{className:`text-kobe-red`,children:[`−`,t]})]})}function Ft(e){let{worktreeChanges:t}=A(),n=e?t[e]:void 0;return n?`${n.added}:${n.deleted}`:`none`}function It({onRetry:e}){let{daemonConnected:t,streamConnected:n}=A();return!t||!n?(0,G.jsx)(`div`,{className:`px-3 py-4 text-[12px] leading-relaxed text-subtle`,children:`The kobe daemon is offline — changes will reappear once it reconnects.`}):(0,G.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-3 py-4`,children:[(0,G.jsx)(`span`,{className:`text-[12px] text-kobe-red`,children:`Couldn't load changes.`}),(0,G.jsxs)(`button`,{type:`button`,onClick:e,className:`flex items-center gap-1.5 border border-line bg-bg px-2 py-1 text-[11px] text-muted transition-colors hover:border-primary hover:text-fg`,children:[(0,G.jsx)(V,{size:11,strokeWidth:2}),`Retry`]})]})}function Lt({patch:e,wrap:t}){let n=(0,H.useMemo)(()=>Nt(e),[e]);return e.trim()?(0,G.jsx)(`div`,{className:`kobe-diff min-h-0 flex-1 overflow-auto py-2 font-mono text-[12px] leading-[1.15rem] ${t?`kobe-diff-wrap`:``}`,children:n.map((e,t)=>(0,G.jsxs)(`div`,{className:`kobe-diff-row ${wt(e.kind)}`,children:[(0,G.jsx)(`span`,{className:`kobe-diff-gutter`,children:e.oldLn??``}),(0,G.jsx)(`span`,{className:`kobe-diff-gutter`,children:e.newLn??``}),(0,G.jsx)(`span`,{className:`kobe-diff-text`,children:e.text===``?` `:e.text})]},t))}):(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center text-[12px] text-subtle`,children:`No textual diff for this file.`})}function Rt({worktreePath:e,onOpenFile:t}){let[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(null),c=Ft(e),{worktreeChanges:l}=A(),u=e?l[e]:void 0,d=(0,H.useRef)(0),f=(0,H.useCallback)(async()=>{if(!e){r(null),s(null);return}let t=++d.current;a(!0),s(null);try{let n=await St(e,{namesOnly:!0});t===d.current&&r(n)}catch(e){t===d.current&&(s(e instanceof Error?e.message:String(e)),r(null))}finally{t===d.current&&a(!1)}},[e]);(0,H.useEffect)(()=>{f()},[f,c]);let[p,m]=(0,H.useState)(``);(0,H.useEffect)(()=>{m(``)},[e]);let h=n?.files??[],g=(0,H.useMemo)(()=>Ot(h,p),[h,p]);return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:[`Changes`,h.length>0?` · ${h.length}`:``]}),u&&(0,G.jsx)(Pt,{added:u.added,deleted:u.deleted}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void f(),disabled:!e||i,className:`ml-auto rounded border border-line px-1.5 py-0.5 text-[10px] text-muted transition-colors hover:bg-surface disabled:opacity-40`,children:i?`…`:`↻`})]}),e?o?(0,G.jsx)(It,{onRetry:()=>void f()}):h.length===0?(0,G.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-4 text-center`,children:(0,G.jsx)(`div`,{className:`text-[12px] text-subtle`,children:i?`Loading changes…`:`Worktree clean.`})}):(0,G.jsxs)(G.Fragment,{children:[h.length>1&&(0,G.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`&&p&&(e.preventDefault(),m(``))},placeholder:`Filter ${h.length} files… (*.ts, !*.json)`,title:`Match a substring, a *.glob, or !exclude`,spellCheck:!1,className:`mx-3 mb-1 shrink-0 border border-line bg-bg px-2 py-1 font-mono text-[11px] text-fg placeholder:text-subtle focus:border-line-active focus:outline-none`}),g.length===0?(0,G.jsx)(`div`,{className:`px-3 py-3 text-center text-[11px] text-subtle`,children:`No files match.`}):(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:g.map(e=>{let n=Ct(e.status);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e.path),title:e.path,className:`flex w-full items-center gap-2 border-l-2 border-transparent px-3 py-2 text-left transition-colors hover:border-primary hover:bg-inset`,children:[(0,G.jsx)(`span`,{className:`w-3 shrink-0 text-center font-mono text-[11px] font-bold ${n.cls}`,children:n.label}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12px] text-fg/90`,children:ke(e.path,34)}),e.staged&&(0,G.jsx)(`span`,{className:`shrink-0 text-[9px] uppercase text-subtle`,children:`staged`})]},e.path)})})]}):(0,G.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-4 text-center`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[12px] font-semibold text-fg`,children:`No task selected`}),(0,G.jsx)(`div`,{className:`mt-1 max-w-48 text-[12px] leading-relaxed text-subtle`,children:`Select a task to watch its worktree changes.`})]})})]})}function zt({worktreePath:e,path:t}){let[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(null),u=Ft(e),d=(0,H.useRef)(0),f=(0,H.useCallback)(async()=>{if(!e){r(null),l(null);return}let n=++d.current;s(!0),l(null);try{let i=await St(e,{path:t});if(n!==d.current)return;r(i.files.find(e=>e.path===t)??null)}catch(e){n===d.current&&l(e instanceof Error?e.message:String(e))}finally{n===d.current&&s(!1)}},[e,t]);(0,H.useEffect)(()=>{f()},[f,u]);let p=n?Mt(n.patch):null;return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col border border-line bg-bg`,children:[(0,G.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-line px-3`,children:[(0,G.jsx)(`span`,{className:`truncate font-mono text-[12px] text-fg`,title:t,children:t}),p&&(0,G.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,G.jsx)(Pt,{added:p.added,deleted:p.deleted})}),n&&(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-subtle ${p&&(p.added||p.deleted)?``:`ml-auto`}`,children:n.status}),n&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),title:i?`Disable line wrap`:`Wrap long lines`,className:`shrink-0 border px-1.5 py-0.5 font-mono text-[10px] transition-colors ${i?`border-primary bg-inset text-fg`:`border-line bg-bg text-subtle hover:border-primary hover:text-fg`}`,children:`wrap`})]}),c?(0,G.jsx)(It,{onRetry:()=>void f()}):n?(0,G.jsx)(Lt,{patch:n.patch,wrap:i}):o?(0,G.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-[12px] text-subtle`,children:`Loading preview…`}):(0,G.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-[12px] text-subtle`,children:`No diff for this file.`})]})}function X(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var Bt=/^\/api\/issue-assets\/[a-f0-9]{16}\/[A-Za-z0-9_-]+\.[a-z0-9]+$/;function Vt(e){let t=e.trim();return Bt.test(t)?t:null}function Ht(e){let t=e.trim();return/^https?:\/\//i.test(t)?t:t.startsWith(`//`)?null:t.startsWith(`/`)||t.startsWith(`#`)||t.startsWith(`./`)||t.startsWith(`../`)?t:null}function Ut(e){let t=e;return t.includes(`]`)&&t.includes(`)`)&&(t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{let r=Vt(n.replace(/&/g,`&`));return r?`<img src="${X(r)}" alt="${X(t)}" loading="lazy" class="kobe-md-img">`:``})),t.includes(`]`)&&t.includes(`)`)&&(t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{let r=Ht(n.replace(/&/g,`&`));return r?`<a href="${X(r)}" target="_blank" rel="noopener noreferrer" class="kobe-md-link">${t}</a>`:`${t}(${n})`})),t=t.replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`),t=t.replace(/(^|[^*])\*([^*]+)\*/g,`$1<em>$2</em>`),t}function Z(e){return e.split(/(`[^`]+`)/g).map((e,t)=>t%2==1?`<code class="kobe-md-code">${e.slice(1,-1)}</code>`:Ut(e)).join(``)}function Wt(e){let t=e.replace(/\r\n/g,`
|
|
5
|
+
`).split(`
|
|
6
|
+
`),n=[],r=0,i=null,a=()=>{i&&=(n.push(`</${i}>`),null)};for(;r<t.length;){let e=t[r];if(/^```/.test(e)){a();let e=[];for(r++;r<t.length&&!/^```/.test(t[r]);)e.push(X(t[r])),r++;r++,n.push(`<pre class="kobe-md-pre"><code>${e.join(`
|
|
7
|
+
`)}</code></pre>`);continue}if(/^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(e)){a(),n.push(`<hr class="kobe-md-hr" />`),r++;continue}let o=/^(#{1,6})\s+(.*)$/.exec(e);if(o){a();let e=o[1].length;n.push(`<h${e} class="kobe-md-h">${Z(X(o[2]))}</h${e}>`),r++;continue}if(/^>\s?/.test(e)){a(),n.push(`<blockquote class="kobe-md-quote">${Z(X(e.replace(/^>\s?/,``)))}</blockquote>`),r++;continue}let s=/^\s*[-*]\s+(.*)$/.exec(e);if(s){i!==`ul`&&(a(),n.push(`<ul class="kobe-md-ul">`),i=`ul`),n.push(`<li>${Z(X(s[1]))}</li>`),r++;continue}let c=/^\s*\d+\.\s+(.*)$/.exec(e);if(c){i!==`ol`&&(a(),n.push(`<ol class="kobe-md-ol">`),i=`ol`),n.push(`<li>${Z(X(c[1]))}</li>`),r++;continue}if(e.trim()===``){a(),r++;continue}a();let l=[e];for(r++;r<t.length&&t[r].trim()!==``&&!/^(#{1,6}\s|>\s?|```|\s*[-*]\s|\s*\d+\.\s|\s*(-{3,}|\*{3,}|_{3,})\s*$)/.test(t[r]);)l.push(t[r]),r++;n.push(`<p class="kobe-md-p">${Z(X(l.join(` `)))}</p>`)}return a(),n.join(`
|
|
8
|
+
`)}async function Gt(e){let t=await fetch(`/api/notes?taskId=${encodeURIComponent(e)}`);if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`failed to load notes (${t.status})${e?`: ${e}`:``}`)}return(await t.json()).markdown??``}async function Kt(e,t){let n=await fetch(`/api/notes`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({taskId:e,markdown:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`failed to save notes (${n.status})${e?`: ${e}`:``}`)}}function qt(e){switch(e){case`saving`:return`saving…`;case`saved`:return`saved`;case`error`:return`save failed`;default:return``}}var Jt=600;function Yt({children:e,right:t}){return(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:e}),t]})}function Xt({taskId:e,full:t=!1}){let[n,r]=(0,H.useState)(``),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(`idle`),u=(0,H.useMemo)(()=>Wt(n),[n]),d=(0,H.useRef)(null),f=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(d.current&&clearTimeout(d.current),f.current=e,l(`idle`),r(``),a(!1),!e)return;let t=!1;return s(!0),Gt(e).then(n=>{!t&&f.current===e&&r(n)}).catch(()=>{!t&&f.current===e&&r(``)}).finally(()=>{t||s(!1)}),()=>{t=!0}},[e]),(0,H.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let p=(0,H.useCallback)(t=>{if(r(t),!e)return;let n=e;l(`saving`),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{Kt(n,t).then(()=>{f.current===n&&l(`saved`)}).catch(()=>{f.current===n&&l(`error`)})},Jt)},[e]);return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-bg`,children:[(0,G.jsx)(Yt,{right:e?(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c!==`idle`&&(0,G.jsx)(`span`,{className:`text-[10px] ${c===`error`?`text-kobe-red`:`text-subtle`}`,children:qt(c)}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`border px-1.5 py-0.5 text-[10px] transition-colors ${i?`border-primary bg-inset text-fg`:`border-line bg-bg text-muted hover:border-primary hover:text-fg`}`,title:`Toggle markdown preview`,children:i?`Edit`:`Preview`})]}):null,children:`Notes`}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 ${t?`px-0 pb-0`:`px-3 pb-3`}`,children:e?i?(0,G.jsx)(`div`,{className:`h-full w-full overflow-auto bg-surface px-4 py-3 ${t?`border-t border-line`:`rounded border border-line`}`,children:n.trim()?(0,G.jsx)(`div`,{className:`kobe-md text-[12px] leading-relaxed text-fg`,dangerouslySetInnerHTML:{__html:u}}):(0,G.jsx)(`p`,{className:`text-[12px] text-subtle`,children:`Nothing to preview yet.`})}):(0,G.jsx)(`textarea`,{value:n,onChange:e=>p(e.target.value),spellCheck:!1,placeholder:o?`loading notes…`:`Notes for this task — markdown, autosaved.`,disabled:o,className:`h-full w-full resize-none border-line bg-surface px-4 py-3 font-mono text-[12px] leading-relaxed text-fg placeholder:text-subtle focus:border-line-active focus:outline-none disabled:opacity-60 ${t?`border-x-0 border-b-0 border-t`:`rounded border`}`}):(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-center`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[12px] font-semibold text-fg`,children:`No task selected`}),(0,G.jsx)(`div`,{className:`mt-1 max-w-48 text-[12px] leading-relaxed text-subtle`,children:`Pick a task to open its web-only scratchpad.`})]})})})]})}var Zt=[`backlog`,`in_progress`,`in_review`,`done`,`canceled`,`error`],Qt=`DIRTY_WORKTREE`;function $t(e){return e.replace(/_/g,` `)}function Q({name:e,value:t,mono:n=!1}){return(0,G.jsxs)(`div`,{className:`min-w-0 border-b border-line-subtle py-2 last:border-b-0`,children:[(0,G.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:e}),(0,G.jsx)(`div`,{className:`mt-1 min-w-0 truncate text-[12px] text-fg ${n?`font-mono`:``}`,title:t,children:t||`—`})]})}function $({children:e,onClick:t,disabled:n,danger:r=!1}){return(0,G.jsx)(`button`,{type:`button`,onClick:t,disabled:n,className:`border px-2 py-1 text-[11px] transition-colors disabled:opacity-40 ${r?`border-kobe-red/40 text-kobe-red hover:bg-kobe-red/10`:`border-line bg-surface text-muted hover:border-primary hover:text-fg`}`,children:e})}function en({task:e}){let[t,n]=(0,H.useState)(e?.title??``),[r,i]=(0,H.useState)(e?.branch??``),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),l=(0,H.useRef)(null);(0,H.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]);let[u,d]=(0,H.useState)(null),p=se(),m=g();if((0,H.useEffect)(()=>{n(e?.title??``)},[e?.title]),(0,H.useEffect)(()=>{i(e?.branch??``)},[e?.branch]),!e)return(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-center`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[12px] font-semibold text-fg`,children:`No task selected`}),(0,G.jsx)(`div`,{className:`mt-1 max-w-48 text-[12px] leading-relaxed text-subtle`,children:`Pick a task to edit its metadata and worktree state.`})]})});let h=async(e,t)=>{o(e);try{await t()}catch(t){L(e.split(`:`)[0],t)}finally{o(null)}},_=()=>{let n=t.trim();!n||n===e.title||h(`rename`,()=>D(`task.rename`,{taskId:e.id,title:n}))},v=()=>{let t=r.trim();!t||t===e.branch||h(`branch`,()=>D(`task.setBranch`,{taskId:e.id,branch:t}))},y=()=>{xt(e.worktreePath).then(e=>{e&&(c(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>c(!1),1200))})},b=()=>{d(null),h(`archive`,async()=>{await D(`task.archive`,{taskId:e.id,archived:!0}),f(),m({to:`/`}),await D(`task.setActive`,{taskId:null})})},x=()=>{h(`restore`,()=>D(`task.archive`,{taskId:e.id,archived:!1}))},S=t=>{d(null),o(`delete`),(async()=>{try{await D(`task.delete`,{taskId:e.id,force:t}),f(),m({to:`/`}),await D(`task.setActive`,{taskId:null}).catch(()=>{}),R(`success`,`Deleted "${e.title||e.branch}"`)}catch(e){let n=e instanceof Error?e.message:String(e);!t&&n.includes(Qt)?d({kind:`delete`,force:!0}):L(`delete`,e)}finally{o(null)}})()};return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,G.jsxs)(`div`,{className:`border-b border-line px-3 py-3`,children:[(0,G.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Task`}),(0,G.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,G.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),onBlur:_,onKeyDown:e=>{e.key===`Enter`&&_()},className:`min-w-0 flex-1 border border-line bg-bg px-2 py-1.5 text-[12px] text-fg focus:border-line-active focus:outline-none`}),(0,G.jsx)($,{onClick:_,disabled:a===`rename`,children:`Save`})]}),e.archived&&(0,G.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border border-kobe-yellow/40 bg-kobe-yellow/10 px-2 py-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-kobe-yellow`,children:`archived`}),(0,G.jsx)($,{onClick:x,disabled:a!==null,children:`Restore`})]})]}),(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-2`,children:[e.kind===`main`?(0,G.jsx)(Q,{name:`Branch`,value:e.branch,mono:!0}):(0,G.jsxs)(`div`,{className:`min-w-0 border-b border-line-subtle py-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Branch`}),(0,G.jsx)(`div`,{className:`mt-1 flex gap-2`,children:(0,G.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`&&v()},className:`min-w-0 flex-1 border border-line bg-bg px-2 py-1 font-mono text-[12px] text-fg focus:border-line-active focus:outline-none`})})]}),(0,G.jsx)(Q,{name:`Vendor`,value:e.vendor??`claude`}),(0,G.jsx)(Q,{name:`Worktree`,value:e.worktreePath,mono:!0}),(0,G.jsx)(Q,{name:`Repo`,value:e.repo,mono:!0}),(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Status`}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:Zt.map(t=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>void h(`status:${t}`,()=>D(`task.status`,{taskId:e.id,status:t})),disabled:a!==null,className:`border px-2 py-1.5 text-left text-[11px] capitalize transition-colors disabled:opacity-40 ${e.status===t?`border-primary bg-inset text-fg`:`border-line bg-surface text-muted hover:border-primary hover:text-fg`}`,children:$t(t)},t))})]}),(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Vendor`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:p.map(t=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>void h(`vendor:${t.id}`,()=>D(`task.setVendor`,{taskId:e.id,vendor:t.id})),disabled:a!==null,className:`border px-2 py-1 text-[11px] transition-colors disabled:opacity-40 ${(e.vendor??`claude`)===t.id?`border-primary bg-inset text-fg`:`border-line bg-surface text-muted hover:border-primary hover:text-fg`}`,children:t.label},t.id))})]}),(0,G.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,G.jsx)($,{onClick:()=>void h(`pin`,()=>D(`task.pin`,{taskId:e.id,pinned:!e.pinned})),disabled:a!==null,children:e.pinned?`Unpin`:`Pin`}),(0,G.jsx)($,{onClick:()=>void h(`worktree`,()=>D(`task.ensureWorktree`,{taskId:e.id})),disabled:a!==null,children:`Ensure worktree`}),(0,G.jsx)($,{onClick:y,children:s?`Copied`:`Copy path`}),!e.archived&&(0,G.jsx)($,{onClick:()=>d({kind:`archive`}),disabled:a!==null,danger:!0,children:`Archive`})]}),e.kind!==`main`&&(0,G.jsxs)(`div`,{className:`mt-4 border-t border-line-subtle pt-3`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Danger zone`}),(0,G.jsx)($,{onClick:()=>d({kind:`delete`,force:!1}),disabled:a!==null,danger:!0,children:`Delete task + worktree`})]})]}),u?.kind===`archive`&&(0,G.jsx)(F,{title:`Archive task`,body:`Archive "${e.title||e.branch}"? Its tmux session and engine will be stopped; the worktree stays on disk and the task can be restored from the Archived section.`,confirmLabel:`Archive`,danger:!0,busy:a===`archive`,onConfirm:b,onCancel:()=>d(null)}),u?.kind===`delete`&&(0,G.jsx)(F,{title:u.force?`Worktree has uncommitted changes`:`Delete task`,body:u.force?`"${e.title||e.branch}" has uncommitted or untracked changes in its worktree. Force-delete discards them permanently.`:`Delete "${e.title||e.branch}"? This removes the task, kills its engine session, and removes its worktree (branch history stays in git).`,confirmLabel:u.force?`Force delete`:`Delete`,danger:!0,busy:a===`delete`,onConfirm:()=>S(u.force),onCancel:()=>d(null)})]})}function tn({drawer:e=!1,onClose:n}={}){let[r,i]=(0,H.useState)(`overview`),{selectedTaskId:a}=t(),{tasks:o}=A(),c=a?o.find(e=>e.id===a)??null:null;return(0,G.jsxs)(`aside`,{className:e?`flex h-full w-full flex-col bg-bg`:`flex w-80 shrink-0 flex-col border-l border-line bg-bg`,children:[(0,G.jsxs)(`div`,{className:`flex h-9 shrink-0 items-stretch border-b border-line bg-surface`,children:[[`overview`,`notes`,`changes`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`px-3 text-[10px] font-bold uppercase tracking-[0.12em] ${r===e?`border-b-2 border-primary text-fg`:`text-subtle hover:text-muted`}`,children:e===`overview`?`Task`:e===`notes`?`Notes`:`Changes`},e)),e&&n&&(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`ml-auto px-3 text-subtle hover:text-fg`,"aria-label":`Close tools`,children:(0,G.jsx)(B,{size:14,strokeWidth:2})})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:r===`overview`?(0,G.jsx)(en,{task:c}):r===`notes`?(0,G.jsx)(Xt,{taskId:a,full:!0}):(0,G.jsx)(Rt,{worktreePath:c?.worktreePath??null,onOpenFile:e=>{a&&s(a,e)}})})]})}async function nn(e,t){let n=new URLSearchParams(t),r=await fetch(`${e}?${n.toString()}`),i=await r.json();if(!r.ok||i.error)throw Error(i.error??`${e} failed (${r.status})`);return i}function rn(e,t){return nn(`/api/history/sessions`,{worktreePath:e,vendor:t})}async function an(e,t){let{messages:n}=await nn(`/api/history/messages`,{vendor:e,sessionId:t});return n}function on(e){let t=0,n=0,r=0;for(let i of e){let e=i.usage;e&&(t+=e.input_tokens,n+=e.output_tokens,r=e.input_tokens+(e.cache_read_input_tokens??0)+(e.cache_creation_input_tokens??0))}return{inputTokens:t,outputTokens:n,contextTokens:r}}function sn(e){return e>=1e6?`${(e/1e6).toFixed(1)}m`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function cn(e,t,n,r=80){return t-e-n<r}var ln=90;function un(e){let t=e.input;if(t&&typeof t==`object`){let e=e=>typeof t[e]==`string`?t[e]:null,n=e(`command`)??e(`file_path`)??e(`pattern`)??e(`url`)??e(`description`)??e(`prompt`)??e(`query`);if(n)return n.length>ln?`${n.slice(0,ln-1)}…`:n}try{let t=JSON.stringify(e.input);return!t||t===`{}`||t===`null`?``:t.length>ln?`${t.slice(0,ln-1)}…`:t}catch{return``}}function dn(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function fn(e){switch(e.type){case`text`:case`thinking`:return e.text;case`tool_call`:return`${e.name} ${un(e)}`;case`tool_result`:return dn(e.output)}}function pn(e){return e.blocks.map(fn).join(` `)}function mn(e,t){return!(t&&e.type===`tool_call`)}function hn(e,t){return e.blocks.some(e=>e.type===`text`||e.type===`thinking`?e.text.trim()!==``:e.type===`tool_call`?!t:!1)}var gn=2500,_n=600;function vn({call:e,result:t}){let[n,r]=(0,H.useState)(!1),i=un(e),a=t?dn(t.output):``,o=!n&&a.length>_n,s=o?`${a.slice(0,_n)}…`:a,c=a.length>0;return(0,G.jsxs)(`div`,{className:`my-1`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>c&&r(e=>!e),className:`flex w-full items-baseline gap-2 text-left ${c?`cursor-pointer`:`cursor-default`}`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?.isError?`text-kobe-red`:`text-kobe-green`}`,children:`⏺`}),(0,G.jsx)(`span`,{className:`shrink-0 text-[12px] font-semibold text-fg`,children:e.name}),i&&(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-subtle`,children:i}),c&&(0,G.jsx)(`span`,{className:`shrink-0 text-subtle`,children:n?(0,G.jsx)(ge,{size:12}):(0,G.jsx)(_e,{size:12})})]}),(n||!n&&a&&a.length<=_n)&&a&&(0,G.jsx)(`pre`,{className:`mt-1 max-h-96 overflow-auto whitespace-pre-wrap break-words border-l-2 pl-3 font-mono text-[11px] leading-relaxed ${t?.isError?`border-kobe-red/40 text-kobe-red/90`:`border-line text-muted`}`,children:s}),o&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`ml-5 mt-0.5 text-[10px] text-subtle hover:text-fg`,children:`show full output`})]})}function yn({text:e}){let[t,n]=(0,H.useState)(!1);return(0,G.jsxs)(`div`,{className:`my-1`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex items-baseline gap-2 text-[11px] italic text-subtle hover:text-muted`,children:[(0,G.jsx)(`span`,{children:`✱`}),(0,G.jsx)(`span`,{children:t?`thinking`:`thinking…`}),t?(0,G.jsx)(ge,{size:11}):(0,G.jsx)(_e,{size:11})]}),t&&(0,G.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words border-l-2 border-line-subtle pl-3 text-[11px] italic leading-relaxed text-subtle`,children:e})]})}function bn({message:e,results:t,hideTools:n}){let r=[],i=We(e.timestamp),a=!1;return e.blocks.forEach((o,s)=>{if(!mn(o,n))return;let c=`${e.timestamp}-${s}`;if(o.type===`text`){if(!o.text.trim())return;e.role===`user`?(r.push((0,G.jsxs)(`div`,{className:`my-2 flex items-baseline gap-2 border-l-2 border-primary/60 bg-inset/40 px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[12px] font-bold text-primary`,children:`❯`}),(0,G.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words text-[12px] leading-relaxed text-fg`,children:o.text}),i&&!a&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-subtle`,title:e.timestamp,children:i})]},c)),a=!0):r.push((0,G.jsx)(`p`,{className:`my-2 whitespace-pre-wrap break-words text-[12px] leading-relaxed ${e.role===`system`?`text-subtle`:`text-fg/90`}`,children:o.text},c));return}if(o.type===`tool_call`){r.push((0,G.jsx)(vn,{call:o,result:t.get(o.callId)},c));return}if(o.type===`thinking`){o.text.trim()&&r.push((0,G.jsx)(yn,{text:o.text},c));return}}),r.length===0?null:(0,G.jsx)(G.Fragment,{children:r})}function xn({worktreePath:e,vendor:t}){let{daemonConnected:n,streamConnected:r}=A(),i=!n||!r,[a,o]=(0,H.useState)([]),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!0),[d,f]=(0,H.useState)([]),[p,m]=(0,H.useState)(``),[h,g]=(0,H.useState)(!1),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(!1),[x,S]=(0,H.useState)(!0),C=(0,H.useRef)(-1),w=(0,H.useRef)(null),T=(0,H.useRef)(!0),E=(0,H.useRef)(0),D=(0,H.useRef)(!0),O=(0,H.useRef)(null);(0,H.useEffect)(()=>{D.current=l,O.current=s},[l,s]);let k=(0,H.useCallback)(async(n=!1)=>{if(!e)return;let r=E.current;try{let i=await rn(e,t);if(i.latestMtime===C.current&&!n)return;C.current=i.latestMtime;let a=i.sessions.at(-1)??null,s=D.current?a:O.current??a;r=++E.current;let l=s?await an(t,s):[];if(r!==E.current)return;o(i.sessions),f(l),c(s),v(null)}catch(e){r===E.current&&v(e instanceof Error?e.message:String(e))}finally{r===E.current&&b(!0)}},[e,t]),j=(0,H.useRef)(k);(0,H.useEffect)(()=>{j.current=k},[k]),(0,H.useEffect)(()=>{C.current=-1,b(!1),D.current=!0,O.current=null,T.current=!0,u(!0),c(null),m(``),g(!1),S(!0),j.current(!0);let e=window.setInterval(()=>{document.hidden||j.current()},gn);return()=>window.clearInterval(e)},[e,t]);let ee=e=>{let n=e===a.at(-1);D.current=n,O.current=e,u(n),c(e);let r=++E.current;an(t,e).then(e=>{r===E.current&&f(e)}).catch(e=>{r===E.current&&v(e instanceof Error?e.message:String(e))})};(0,H.useEffect)(()=>{let e=w.current;e&&T.current&&(e.scrollTop=e.scrollHeight)},[d]);let M=()=>{let e=w.current;if(!e)return;let t=cn(e.scrollTop,e.scrollHeight,e.clientHeight);T.current=t,S(t)},ne=()=>{let e=w.current;e&&(e.scrollTop=e.scrollHeight,T.current=!0,S(!0))},N=(0,H.useMemo)(()=>{let e=new Map;for(let t of d)for(let n of t.blocks)n.type===`tool_result`&&e.set(n.callId,n);return e},[d]),P=(0,H.useMemo)(()=>on(d),[d]),F=(0,H.useMemo)(()=>d.map(e=>pn(e).toLowerCase()),[d]),I=(0,H.useMemo)(()=>{let e=p.trim().toLowerCase();return d.filter((t,n)=>(!e||F[n].includes(e))&&hn(t,h))},[d,F,p,h]);return e?(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col border border-line bg-bg`,children:[(0,G.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b border-line bg-surface px-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Chat`}),a.length>0&&(0,G.jsx)(`select`,{value:s??``,onChange:e=>ee(e.target.value),className:`max-w-44 border border-line bg-bg px-1 py-0.5 font-mono text-[10px] text-muted focus:outline-none`,title:`Engine session`,children:a.map((e,t)=>(0,G.jsxs)(`option`,{value:e,children:[`#`,t+1,` `,e.slice(0,8),t===a.length-1?` (latest)`:``]},e))}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-3 font-mono text-[10px] text-subtle`,children:[P.contextTokens>0&&(0,G.jsxs)(`span`,{title:`Live context estimate (last turn's full prompt)`,children:[`ctx `,sn(P.contextTokens)]}),P.outputTokens>0&&(0,G.jsxs)(`span`,{title:`Session tokens in / out`,children:[`⇡`,sn(P.inputTokens),` ⇣`,sn(P.outputTokens)]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void k(!0),className:`text-subtle transition-colors hover:text-fg`,title:`Refresh transcript`,"aria-label":`Refresh transcript`,children:(0,G.jsx)(V,{size:11,strokeWidth:2})})]})]}),d.length>0&&(0,G.jsxs)(`div`,{className:`flex h-7 shrink-0 items-center gap-2 border-b border-line px-2`,children:[(0,G.jsx)(te,{size:11,strokeWidth:2,className:`shrink-0 text-subtle`}),(0,G.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`&&p&&(e.preventDefault(),m(``))},placeholder:`Search transcript…`,spellCheck:!1,className:`min-w-0 flex-1 bg-transparent font-mono text-[11px] text-fg placeholder:text-subtle focus:outline-none`}),p.trim()&&(0,G.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-subtle`,children:[I.length,`/`,d.length]}),p.trim()&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(``),className:`shrink-0 text-subtle transition-colors hover:text-fg`,"aria-label":`clear transcript search`,title:`Clear search`,children:(0,G.jsx)(B,{size:12,strokeWidth:2})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`shrink-0 border px-1.5 py-0.5 font-mono text-[10px] transition-colors ${h?`border-primary bg-inset text-fg`:`border-line bg-bg text-subtle hover:border-primary hover:text-fg`}`,title:h?`Show tool calls`:`Hide tool calls — read just the conversation`,children:h?`tools off`:`tools`})]}),(0,G.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,G.jsx)(`div`,{ref:w,onScroll:M,className:`min-h-0 flex-1 overflow-y-auto px-3 py-2`,children:_?i?(0,G.jsx)(`div`,{className:`py-4 text-[12px] leading-relaxed text-subtle`,children:`The kobe daemon is offline — the transcript will reappear once it reconnects.`}):(0,G.jsxs)(`div`,{className:`flex flex-col items-start gap-2 py-4`,children:[(0,G.jsx)(`span`,{className:`text-[12px] text-kobe-red`,children:`Couldn't load the transcript.`}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void k(!0),className:`flex items-center gap-1.5 border border-line bg-bg px-2 py-1 text-[11px] text-muted transition-colors hover:border-primary hover:text-fg`,children:[(0,G.jsx)(V,{size:11,strokeWidth:2}),`Retry`]})]}):y?d.length===0?(0,G.jsx)(`div`,{className:`py-4 text-[12px] leading-relaxed text-subtle`,children:`No engine session recorded for this worktree yet. Open a Vendor tab and start a conversation — the transcript appears here.`}):I.length===0?(0,G.jsxs)(`div`,{className:`py-4 text-[12px] leading-relaxed text-subtle`,children:[`No messages match “`,p.trim(),`”.`]}):I.map((e,t)=>(0,G.jsx)(bn,{message:e,results:N,hideTools:h},`${e.sessionId}-${t}`)):(0,G.jsx)(`div`,{className:`py-4 text-[12px] text-subtle`,children:`Loading transcript…`})}),!x&&I.length>0&&(0,G.jsx)(`button`,{type:`button`,onClick:ne,className:`absolute bottom-3 right-4 flex items-center gap-1 border border-line bg-surface px-2 py-1 font-mono text-[10px] text-muted shadow-md transition-colors hover:border-primary hover:text-fg`,children:`↓ latest`})]})]}):(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center text-[12px] text-subtle`,children:`This task has no worktree yet.`})}var Sn=(0,H.lazy)(()=>C(()=>import(`./ChatTerminal-WIjnp057.js`).then(e=>({default:e.ChatTerminal})),__vite__mapDeps([0,1,2,3,4,5,6,7])));function Cn(){return(0,G.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-[12px] text-subtle`,children:`Loading terminal…`})}function wn(e){return e??`claude`}function Tn({taskId:e,tabId:t,vendor:n}){return(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,G.jsx)(`div`,{className:`grid w-full max-w-2xl grid-cols-1 gap-3 md:grid-cols-3`,children:[{title:`Vendor`,detail:n,body:`Start an engine session for this task.`,icon:me,action:()=>u(e,t,`vendor`)},{title:`Chat`,detail:`transcript`,body:`Read the session as structured messages and tool calls.`,icon:Se,action:()=>u(e,t,`transcript`)},{title:`Terminal`,detail:`shell / worktree`,body:`Open a command shell in this task worktree.`,icon:Te,action:()=>u(e,t,`terminal`)}].map(e=>{let t=e.icon;return(0,G.jsxs)(`button`,{type:`button`,onClick:e.action,className:`group flex min-h-36 flex-col border border-line bg-surface p-4 text-left transition-colors hover:border-primary hover:bg-inset`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center border border-line bg-bg text-muted group-hover:border-primary group-hover:text-primary`,children:(0,G.jsx)(t,{size:17,strokeWidth:1.8})}),(0,G.jsx)(`span`,{className:`truncate text-[10px] uppercase text-subtle`,children:e.detail})]}),(0,G.jsx)(`div`,{className:`mt-5 text-[12px] font-bold uppercase tracking-[0.12em] text-fg`,children:e.title}),(0,G.jsx)(`div`,{className:`mt-2 text-[12px] leading-relaxed text-subtle`,children:e.body})]},e.title)})})})}function En({tab:e,taskId:t,taskWorktreePath:n,taskTitle:r,vendor:i}){return e?.kind===`empty`?(0,G.jsx)(Tn,{taskId:t,tabId:e.id,vendor:i}):e?.kind===`vendor`?(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(Cn,{}),children:(0,G.jsx)(Sn,{tabId:e.id,taskId:t,mode:`engine`},e.id)}):e?.kind===`terminal`?(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(Cn,{}),children:(0,G.jsx)(Sn,{tabId:e.id,taskId:t,mode:`shell`},e.id)}):e?.kind===`transcript`?(0,G.jsx)(xn,{worktreePath:n,vendor:i,title:r},e.id):e?.kind===`file`?(0,G.jsx)(zt,{worktreePath:n,path:e.path},e.id):(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center text-[12px] text-subtle`,children:`Opening a tab…`})}function Dn({tab:e,side:t,children:n,onCloseSplit:r}){return(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[t===`right`&&(0,G.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between border-b border-line bg-surface px-3`,children:[(0,G.jsx)(`span`,{className:`truncate text-[11px] text-muted`,children:e?.title??`Split`}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-[11px] text-subtle hover:text-fg`,"aria-label":`close split`,title:`Close split`,children:`×`})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 p-2`,children:n})]})}function On(){let[e,r]=(0,H.useState)(null),[i,s]=(0,H.useState)(!1),{selectedTaskId:c,tabsByTask:l,activeByTask:u,splitByTask:f}=t(),{tasks:h,jobs:g}=A(),_=c?h.find(e=>e.id===c):null,v=c?l[c]??[]:[],y=c?u[c]:void 0,x=c?f[c]:void 0,S=e=>{if(!c)return;let t=v.find(t=>t.id===e);n(c,e),t&&m(t.kind)&&b(e)},C=v.find(e=>e.id===y)??v[0],w=x&&x!==C?.id?v.find(e=>e.id===x):void 0,T=wn(_?.vendor),E=_?.title||_?.branch||`Session`,D=!!_&&((c?g[c]?.phase===`running`:!1)||_.worktreePath===null);return(0,G.jsxs)(`section`,{className:`flex min-w-0 flex-1 flex-col bg-bg`,children:[(0,G.jsx)(`div`,{className:`flex h-9 shrink-0 items-stretch border-b border-line bg-surface`,children:c?(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-stretch overflow-x-auto`,role:`tablist`,children:[v.map(e=>{let t=e.id===C?.id,n=e.id===w?.id;return(0,G.jsxs)(`div`,{role:`tab`,"aria-selected":t,tabIndex:0,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id),r(e.id)},onDragEnd:()=>{r(null),s(!1)},className:`group flex h-9 select-none items-center gap-2 border-r border-b-2 border-r-line px-3 text-[12px] transition-colors ${t?`border-b-primary bg-bg text-fg`:n?`border-b-kobe-blue bg-inset text-fg`:`border-b-transparent text-muted hover:bg-inset/50`}`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>d(c,e.id),className:`max-w-40 cursor-grab truncate active:cursor-grabbing`,title:n?`${e.title} (split)`:e.title,children:e.title}),n&&(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase text-kobe-blue`,children:`Split`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>S(e.id),className:`text-subtle opacity-0 transition-opacity hover:text-fg group-hover:opacity-100`,"aria-label":`close tab`,title:`Close tab`,children:`×`})]},e.id)}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(c),className:`px-3 text-[13px] text-subtle hover:text-fg`,"aria-label":`new tab`,title:`New tab`,children:`+`})]}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 text-[11px] text-subtle`,children:[(0,G.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-subtle`}),`No task selected`]})}),(0,G.jsxs)(`section`,{className:`relative min-h-0 flex-1`,"aria-label":`Workspace`,onDragOver:t=>{if(!c||!e)return;t.preventDefault();let n=t.currentTarget.getBoundingClientRect();s(t.clientX>n.left+n.width/2)},onDragLeave:()=>s(!1),onDrop:t=>{if(!c||!e)return;t.preventDefault();let n=t.currentTarget.getBoundingClientRect();t.clientX>n.left+n.width/2?a(c,e):d(c,e),r(null),s(!1)},children:[c&&C?(0,G.jsxs)(`div`,{className:`flex h-full min-w-0`,children:[(0,G.jsx)(Dn,{tab:C,side:`left`,children:(0,G.jsx)(En,{tab:C,taskId:c,taskWorktreePath:_?.worktreePath??null,taskTitle:E,vendor:T})}),w&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`w-px shrink-0 bg-line`}),(0,G.jsx)(Dn,{tab:w,side:`right`,onCloseSplit:()=>{c&&o(c)},children:(0,G.jsx)(En,{tab:w,taskId:c,taskWorktreePath:_?.worktreePath??null,taskTitle:E,vendor:T})})]})]}):(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,G.jsxs)(`div`,{className:`max-w-md`,children:[(0,G.jsx)(`div`,{className:`font-mono text-[13px] font-bold text-primary`,children:`[kobe web]`}),(0,G.jsx)(`h1`,{className:`mt-4 text-[18px] font-semibold text-fg`,children:_?D?`Setting up this task's worktree…`:`Opening workspace…`:`Select a task to open its workspace.`}),(0,G.jsx)(`p`,{className:`mt-2 text-[12px] leading-relaxed text-subtle`,children:`Web workspaces keep their own browser tabs, split panes, notes, and file previews for each task.`})]})}),e&&(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-y-2 right-2 flex w-[calc(50%-0.5rem)] items-center justify-center border border-dashed ${i?`border-primary bg-primary/10`:`border-line bg-inset/40`}`,children:(0,G.jsx)(`span`,{className:`border border-line bg-bg px-2 py-1 text-[10px] font-bold uppercase tracking-[0.12em] text-muted`,children:`Drop to split right`})})]})]})}function kn({children:e,suffix:t}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:e}),t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`h-px flex-1 bg-line`}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] font-bold uppercase text-primary`,children:t})]}):null]})}function An({task:e,engine:t,job:n,changes:r,engineName:i,active:a,onClick:o}){let s=n?.phase===`running`,c=s?`materializing…`:Oe(t?.state),l=We(e.updatedAt||e.createdAt);return(0,G.jsxs)(`button`,{type:`button`,"data-task-id":e.id,onClick:o,className:`group w-full border-l-2 px-3 py-2 text-left transition-colors ${a?`border-primary bg-inset`:`border-transparent hover:bg-surface`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s?(0,G.jsx)(xe,{size:10,strokeWidth:2.5,className:`shrink-0 animate-spin text-primary`}):(0,G.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${De(t?.state)}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] ${a?`text-fg`:`text-fg/90`}`,children:e.title||e.branch}),(0,G.jsx)(ae,{pr:e.prStatus}),e.pinned&&(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] text-subtle`,children:`PIN`}),(0,G.jsx)(ue,{counts:r})]}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 pl-3.5 text-[11px] text-subtle`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:e.branch||`—`}),(0,G.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,G.jsx)(P,{label:i}),c&&(0,G.jsx)(`span`,{className:`text-muted`,children:c}),l&&(0,G.jsx)(`span`,{className:`text-subtle`,children:l})]})]})]})}function jn({task:e,onRestore:t}){return(0,G.jsxs)(`div`,{className:`group flex items-center gap-2 border-l-2 border-transparent px-3 py-1.5`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12px] text-subtle`,children:e.title||e.branch}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 border border-line bg-surface px-1.5 py-0.5 text-[10px] text-muted opacity-0 transition-opacity hover:border-primary hover:text-fg group-hover:opacity-100`,children:`Restore`})]})}function Mn({onOpenSettings:e,onNewTask:n,onAdopt:r}){let{tasks:a,engineStates:o,jobs:s,worktreeChanges:c,uiPrefs:l,hydrated:u,streamConnected:d}=A(),{selectedTaskId:f}=t(),p=se(),m=(0,H.useMemo)(()=>le(a),[a]),h=e=>ie(p,e,m),{query:_,statusFilter:v,sortMode:y,showArchived:b}=Re(),x=(0,H.useRef)(null),S=(0,H.useRef)(null);(0,H.useEffect)(()=>{f&&x.current?.querySelector(`[data-task-id="${CSS.escape(f)}"]`)?.scrollIntoView({block:`nearest`})},[f]);let C=l?.sortMode;(0,H.useEffect)(()=>{Ie(C)},[C]);let w=(0,H.useMemo)(()=>a.filter(e=>!e.archived),[a]),T=(0,H.useMemo)(()=>a.filter(e=>e.archived&&e.kind!==`main`),[a]),E=(0,H.useMemo)(()=>Ve(w.filter(e=>He(e,_)&&k(o[e.id],c[e.worktreePath],v)),y),[w,_,v,y,o,c]),O=E.filter(e=>e.kind===`main`),j=E.filter(e=>e.kind!==`main`),M=!u||!d&&a.length===0,ne=g(),N=e=>{i(e),D(`task.setActive`,{taskId:e}).catch(()=>{}),ne({to:`/task/$taskId`,params:{taskId:e}})};(0,H.useEffect)(()=>{let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.key,n=t===`ArrowDown`||t===`ArrowUp`,r=t===`j`||t===`ArrowDown`,i=t===`k`||t===`ArrowUp`,a=t===`/`;if(!r&&!i&&!a)return;let o=e.target;if(o&&(o.tagName===`INPUT`||o.tagName===`TEXTAREA`||o.tagName===`SELECT`||o.isContentEditable)||document.querySelector(`[role=dialog],[role=alertdialog]`)||document.querySelector(`[data-settings-open]`))return;if(a){e.preventDefault(),S.current?.focus();return}if(n&&o&&o!==document.body&&!x.current?.contains(o)||E.length===0)return;e.preventDefault();let s=E.findIndex(e=>e.id===f);N(E[s===-1?0:Math.min(Math.max(s+(r?1:-1),0),E.length-1)].id)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E,f]);let P=e=>{D(`task.archive`,{taskId:e.id,archived:!1}).catch(t=>L(`restore "${e.title||e.branch}"`,t))};return(0,G.jsxs)(`aside`,{className:`flex w-64 shrink-0 flex-col border-r border-line bg-bg`,children:[(0,G.jsxs)(`div`,{className:`border-b border-line bg-surface/50 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Tasks`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>Pe(y==="default"?`recent`:`default`),className:`font-mono text-[10px] uppercase ${y===`recent`?`text-primary`:`text-muted hover:text-fg`}`,title:`Toggle task sort`,children:`sort`}),(0,G.jsxs)(`span`,{className:`font-mono text-[10px] text-muted`,children:[E.length,`/`,w.length]}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-muted transition-colors hover:text-primary`,title:`Adopt an existing worktree`,"aria-label":`Adopt worktree`,children:(0,G.jsx)(ye,{size:14,strokeWidth:1.9})}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted transition-colors hover:text-primary`,title:`New task`,"aria-label":`New task`,children:(0,G.jsx)(ee,{size:14,strokeWidth:2.2})})]})]}),(0,G.jsxs)(`label`,{className:`mt-2 flex h-8 items-center gap-2 border border-line bg-bg px-2 text-[12px] text-muted focus-within:border-line-active`,children:[(0,G.jsx)(te,{size:14,strokeWidth:1.8,className:`shrink-0 text-subtle`}),(0,G.jsx)(`input`,{ref:S,value:_,onChange:e=>W(e.target.value),onKeyDown:e=>{e.key===`Enter`&&E.length>0?(e.preventDefault(),N(E[0].id),e.currentTarget.blur()):e.key===`Escape`&&_&&(e.preventDefault(),W(``))},placeholder:`Filter tasks`,className:`min-w-0 flex-1 bg-transparent text-fg placeholder:text-subtle focus:outline-none`}),_&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>W(``),className:`shrink-0 text-subtle hover:text-fg`,"aria-label":`clear task filter`,title:`Clear filter`,children:(0,G.jsx)(B,{size:13,strokeWidth:2})})]}),(0,G.jsx)(`div`,{className:`mt-2 flex items-center gap-1`,children:[{key:`all`,label:`All`,title:`All tasks`},{key:`attention`,label:`Needs`,title:`Needs input / errored / rate-limited`}].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>Ne(e.key),title:e.title,className:`border px-1.5 py-0.5 text-[10px] transition-colors ${v===e.key?`border-primary bg-inset text-fg`:`border-line bg-bg text-subtle hover:border-primary hover:text-fg`}`,children:e.label},e.key))})]}),(0,G.jsxs)(`div`,{ref:x,className:`flex-1 overflow-y-auto`,children:[M?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-4 text-[12px] text-subtle`,children:[(0,G.jsx)(xe,{size:13,strokeWidth:2,className:`animate-spin`}),(0,G.jsx)(`span`,{children:`connecting…`})]}):w.length===0?(0,G.jsxs)(`div`,{className:`px-3 py-4 text-[12px] leading-relaxed text-subtle`,children:[(0,G.jsx)(`p`,{children:`No tasks yet.`}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`mt-3 border border-line bg-surface px-2 py-1 text-[11px] text-muted hover:border-primary hover:text-fg`,children:`+ New task`})]}):E.length===0?(0,G.jsxs)(`div`,{className:`px-3 py-4 text-[12px] leading-relaxed text-subtle`,children:[(0,G.jsx)(`div`,{children:_?`No matches for “${_}”.`:`No tasks in this status.`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{W(``),Ne(`all`)},className:`mt-3 border border-line bg-surface px-2 py-1 text-[11px] text-muted hover:border-primary hover:text-fg`,children:`Clear filter`})]}):(0,G.jsxs)(G.Fragment,{children:[O.length>0&&(0,G.jsx)(kn,{children:`Projects`}),O.map(e=>(0,G.jsx)(An,{task:e,engine:o[e.id],job:s[e.id],changes:c[e.worktreePath],engineName:h(e),active:e.id===f,onClick:()=>N(e.id)},e.id)),j.length>0&&(0,G.jsx)(kn,{suffix:y==="default"?void 0:y,children:`Worktrees`}),j.map(e=>(0,G.jsx)(An,{task:e,engine:o[e.id],job:s[e.id],changes:c[e.worktreePath],engineName:h(e),active:e.id===f,onClick:()=>N(e.id)},e.id))]}),!M&&T.length>0&&(0,G.jsxs)(`div`,{className:`mt-2 border-t border-line-subtle pb-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>Fe(!b),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.12em] text-subtle`,children:`Archived`}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-subtle`,children:T.length}),(0,G.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-subtle`,children:b?`−`:`+`})]}),b&&T.map(e=>(0,G.jsx)(jn,{task:e,onRestore:()=>P(e)},e.id))]})]}),(0,G.jsx)(`div`,{className:`border-t border-line p-2`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:e,className:`flex w-full items-center gap-2 border border-line bg-surface px-2 py-2 text-left text-[12px] text-muted transition-colors hover:border-primary hover:bg-inset hover:text-fg`,children:[(0,G.jsx)(we,{size:15,strokeWidth:1.8}),(0,G.jsx)(`span`,{children:`Settings`})]})})]})}function Nn({onToggleTools:e,onShowHelp:n}){let{daemonConnected:r,streamConnected:i,tasks:a}=A(),{selectedTaskId:o}=t(),s=o?a.find(e=>e.id===o):null,c=r&&i;return(0,G.jsxs)(`header`,{className:`flex h-10 shrink-0 items-center gap-3 border-b border-line bg-surface px-3`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[13px] font-bold text-primary`,children:`[kobe]`}),(0,G.jsx)(y,{}),s?(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`max-w-56 truncate rounded bg-inset px-2 py-0.5 text-[11px] text-fg`,children:s.title||s.branch}),(0,G.jsx)(`span`,{className:`hidden max-w-40 truncate font-mono text-[11px] text-subtle md:inline`,children:s.branch})]}):(0,G.jsx)(`span`,{className:`rounded bg-inset px-2 py-0.5 text-[11px] text-muted`,children:`Workspace`}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-3 text-[11px] text-subtle`,children:[(0,G.jsxs)(`span`,{className:`hidden items-center gap-1.5 sm:flex`,title:!c&&i?"Daemon offline — if it doesn't recover, run `kobe doctor` or `kobe reset` in a terminal.":void 0,children:[(0,G.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${c?`bg-kobe-green`:`bg-kobe-yellow`}`}),(0,G.jsx)(`span`,{children:c?`daemon connected`:i?`no daemon`:`connecting…`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`hidden items-center text-muted transition-colors hover:text-fg sm:flex`,"aria-label":`Keyboard shortcuts`,title:`Keyboard shortcuts (?)`,children:(0,G.jsx)(ve,{size:15,strokeWidth:1.8})}),(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`flex items-center text-muted transition-colors hover:text-fg lg:hidden`,"aria-label":`Toggle task tools`,title:`Task tools`,children:(0,G.jsx)(Ce,{size:15,strokeWidth:1.8})})]})]})}function Pn(){let{tasks:e,update:n}=A(),{selectedTaskId:r}=t(),i=r?e.find(e=>e.id===r):null,a=e.filter(e=>!e.archived).length;return(0,G.jsxs)(`footer`,{className:`flex h-7 shrink-0 items-center gap-4 border-t border-line bg-surface px-3 text-[11px] text-subtle`,children:[(0,G.jsxs)(`span`,{children:[a,` task`,a===1?``:`s`]}),i&&(0,G.jsxs)(`span`,{className:`min-w-0 truncate text-muted`,children:[i.kind===`main`?`project`:`worktree`,` ·`,` `,ke(i.worktreePath,54)]}),(0,G.jsx)(`span`,{className:`ml-auto`,children:n?.latest?`update ${n.latest} available`:`kobe web`})]})}function Fn(){let e=g(),[t,n]=(0,H.useState)(!1),[r,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){e.preventDefault(),l(e=>!e);return}if(e.key===`?`&&!e.metaKey&&!e.ctrlKey&&!e.altKey){let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||(e.preventDefault(),d(!0));return}e.key===`Escape`&&p(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,H.useEffect)(()=>(j(t=>{i(t),D(`task.setActive`,{taskId:t}).catch(()=>{}),e({to:`/task/$taskId`,params:{taskId:t}})}),()=>j(null)),[e]),(0,G.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden bg-bg text-fg`,children:[(0,G.jsx)(Nn,{onToggleTools:()=>p(e=>!e),onShowHelp:()=>d(!0)}),(0,G.jsx)(_,{}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,G.jsx)(Mn,{onOpenSettings:()=>n(!0),onNewTask:()=>a(!0),onAdopt:()=>s(!0)}),t?(0,G.jsx)(vt,{onClose:()=>n(!1)}):(0,G.jsx)(On,{}),(0,G.jsx)(`div`,{className:`hidden lg:flex`,children:(0,G.jsx)(tn,{})}),f&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-30 flex justify-end bg-black/50 lg:hidden`,onClick:()=>p(!1),onKeyDown:e=>{e.key===`Escape`&&p(!1)},role:`presentation`,children:(0,G.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Task tools`,className:`h-full w-80 max-w-[85vw] border-l border-line bg-bg shadow-2xl`,onClick:e=>e.stopPropagation(),onKeyDown:()=>{},children:(0,G.jsx)(tn,{drawer:!0,onClose:()=>p(!1)})})})]}),(0,G.jsx)(Pn,{}),r&&(0,G.jsx)(Ge,{onClose:()=>a(!1)}),o&&(0,G.jsx)(Ke,{onClose:()=>s(!1)}),u&&(0,G.jsx)(rt,{onClose:()=>d(!1)}),(0,G.jsx)(Xe,{open:c,onClose:()=>l(!1),onNewTask:()=>a(!0),onOpenSettings:()=>n(!0)}),(0,G.jsx)(bt,{})]})}export{V as n,Fn as t};
|