kaizen-agent 1.60.0 → 1.60.1
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/cli/pty.test.ts +7 -2
- package/cli/pty.ts +4 -3
- package/cli/web-pr.test.ts +51 -0
- package/cli/web.ts +30 -1
- package/cli/worktree.test.ts +104 -1
- package/cli/worktree.ts +117 -2
- package/package.json +1 -1
- package/web/board/git.ts +309 -62
- package/web/board/panel.ts +15 -15
- package/web/board/run-view.ts +26 -5
- package/web/board/search-match.ts +20 -0
- package/web/board/search.test.ts +20 -0
- package/web/board/search.ts +324 -0
- package/web/board/workspace.ts +2 -0
- package/web/board/ws-board-ui.ts +12 -1
- package/web/board/ws-tabs.test.ts +11 -1
- package/web/board/ws-tabs.ts +4 -1
- package/web/board.html +7 -1
- package/web/board.js +126 -42
- package/web/notebook.js +42 -24
- package/web/notes.html +1 -0
- package/web/term.js +1 -1
- package/web/video.html +1 -0
- package/web/video.js +72 -54
package/web/board/git.ts
CHANGED
|
@@ -1,78 +1,325 @@
|
|
|
1
1
|
import { store } from "./store.ts";
|
|
2
2
|
import { post } from "./api.ts";
|
|
3
3
|
import { key } from "./cards.ts";
|
|
4
|
-
import { $, html } from "./dom.ts";
|
|
4
|
+
import { $, html, raw } from "./dom.ts";
|
|
5
5
|
import { commitMsg } from "./markdown.ts";
|
|
6
6
|
import { openRun } from "./panel.ts";
|
|
7
7
|
import { toast } from "./toast.ts";
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
9
|
+
// The run's Git tab, laid out like Orca's Source Control panel: the branch and its pull
|
|
10
|
+
// request at the top, the run's changed files and the message, then one split button
|
|
11
|
+
// whose label is the next step (commit, push, open the PR, merge it, remove the worktree)
|
|
12
|
+
// with the other steps in its menu, each unavailable one saying why. A run built in the
|
|
13
|
+
// project's own checkout (no worktree) only commits and pushes.
|
|
14
|
+
|
|
15
|
+
// What the user typed and which inline confirm is open, per run: a refresh redraws the tab.
|
|
16
|
+
const ui = new Map<string, { msg?: string; title?: string; body?: string; draft?: boolean; ask?: string }>();
|
|
17
|
+
const st = (c) => {
|
|
18
|
+
let u = ui.get(key(c));
|
|
19
|
+
if (!u) ui.set(key(c), (u = {}));
|
|
20
|
+
return u;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Commits only after the final approval, and only on a finished run.
|
|
24
|
+
export const gitShown = (c) => {
|
|
25
|
+
const g = store.runDoc && store.runDoc.git;
|
|
26
|
+
return (
|
|
27
|
+
!!(g && g.repo) && !c.archived && c.accept !== "needs" && (c.status === "done" || c.awaiting === "approvals.review")
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
// Something is left to do: the footer points at the tab.
|
|
31
|
+
export const gitPending = (c) => {
|
|
32
|
+
if (!gitShown(c)) return false;
|
|
12
33
|
const g = store.runDoc.git,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
b = store.runDoc.branch;
|
|
35
|
+
return (
|
|
36
|
+
g.files.length > 0 ||
|
|
37
|
+
(b
|
|
38
|
+
? (b.upstream && g.ahead > 0) ||
|
|
39
|
+
(b.pr && b.pr.state === "OPEN") ||
|
|
40
|
+
(b.landed && !b.pr) ||
|
|
41
|
+
(b.pr && b.pr.state === "MERGED")
|
|
42
|
+
: g.ahead > 0)
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Every step, in the order the primary button walks them. `why` is set when the step is
|
|
47
|
+
// unavailable; the menu shows it under the label, as Orca does.
|
|
48
|
+
function steps(c) {
|
|
49
|
+
const g = store.runDoc.git,
|
|
50
|
+
b = store.runDoc.branch,
|
|
51
|
+
pr = b && b.pr,
|
|
52
|
+
files = g.files.length,
|
|
53
|
+
open = pr && pr.state === "OPEN";
|
|
54
|
+
const s = [
|
|
55
|
+
{ a: "commit", label: "Commit & push", why: files ? "" : "No changes to commit" },
|
|
56
|
+
{
|
|
57
|
+
a: "push",
|
|
58
|
+
label: "Push",
|
|
59
|
+
why: files
|
|
60
|
+
? "Commit changes first"
|
|
61
|
+
: b && !b.upstream
|
|
62
|
+
? "Not published yet: Create PR pushes it"
|
|
63
|
+
: g.ahead > 0
|
|
64
|
+
? ""
|
|
65
|
+
: "Nothing to push",
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
if (!b) return s;
|
|
69
|
+
const noGh = b.gh ? "" : "Needs the GitHub CLI (gh) and a GitHub remote";
|
|
70
|
+
const prWhy =
|
|
71
|
+
noGh ||
|
|
72
|
+
(files
|
|
73
|
+
? "Commit changes first"
|
|
74
|
+
: pr && pr.state !== "CLOSED"
|
|
75
|
+
? `Pull request #${pr.number} is ${pr.state === "MERGED" ? "merged" : "open"}`
|
|
76
|
+
: "");
|
|
77
|
+
s.push(
|
|
78
|
+
{ a: "pr", label: b.upstream && g.ahead === 0 ? "Create PR" : "Push & create PR", why: prWhy },
|
|
79
|
+
{ a: "draft", label: "Create draft PR", why: prWhy },
|
|
80
|
+
{
|
|
81
|
+
a: "merge",
|
|
82
|
+
label: "Merge PR",
|
|
83
|
+
why:
|
|
84
|
+
noGh ||
|
|
85
|
+
(!open
|
|
86
|
+
? "No open pull request"
|
|
87
|
+
: pr.draft
|
|
88
|
+
? "Draft: mark it ready on GitHub first"
|
|
89
|
+
: files
|
|
90
|
+
? "Commit changes first"
|
|
91
|
+
: g.ahead > 0
|
|
92
|
+
? "Push first"
|
|
93
|
+
: ""),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
a: "remove",
|
|
97
|
+
label: "Remove workspace",
|
|
98
|
+
why: files ? "Commit or discard the changes first" : b.landed ? "" : "Merge the pull request first",
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
return s;
|
|
32
102
|
}
|
|
33
|
-
|
|
103
|
+
|
|
104
|
+
const PR_WORD = { OPEN: "Open", MERGED: "Merged", CLOSED: "Closed" };
|
|
105
|
+
|
|
106
|
+
export function gitTab(c, refresh) {
|
|
107
|
+
const body = $("pbody");
|
|
108
|
+
// A refresh while the user types or a step runs would lose the text or the busy label.
|
|
109
|
+
if (
|
|
110
|
+
refresh &&
|
|
111
|
+
body.querySelector(".gitp") &&
|
|
112
|
+
(body.querySelector(".gitp [data-busy]") || body.querySelector(".gitp")!.contains(document.activeElement))
|
|
113
|
+
)
|
|
114
|
+
return;
|
|
34
115
|
const g = store.runDoc.git,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
116
|
+
b = store.runDoc.branch,
|
|
117
|
+
pr = b && b.pr,
|
|
118
|
+
u = st(c),
|
|
119
|
+
all = steps(c),
|
|
120
|
+
next = all.find((x) => !x.why && x.a !== "draft"),
|
|
121
|
+
files = g.files.length,
|
|
122
|
+
target = b ? `origin/${b.base}` : `${g.remote}/${g.branch || "HEAD"}`;
|
|
123
|
+
if (u.msg === undefined) u.msg = commitMsg(store.runDoc.impl) || c.title || c.text || "";
|
|
124
|
+
const chip = pr
|
|
125
|
+
? html`<a
|
|
126
|
+
class="gchip ${pr.state.toLowerCase()}${pr.draft ? " draft" : ""}"
|
|
127
|
+
href="${pr.url}"
|
|
128
|
+
target="_blank"
|
|
129
|
+
rel="noopener"
|
|
130
|
+
title="Open on GitHub"
|
|
131
|
+
><svg><use href="#t-git" /></svg>#${pr.number}
|
|
132
|
+
${pr.draft && pr.state === "OPEN" ? "Draft" : PR_WORD[pr.state] || pr.state}</a
|
|
133
|
+
>`
|
|
134
|
+
: b && b.checking
|
|
135
|
+
? html`<span class="gchip dim">Checking PR…</span>`
|
|
136
|
+
: b && b.gh && !all.find((x) => x.a === "pr").why
|
|
137
|
+
? html`<button class="gchip" data-a="pr">
|
|
138
|
+
<svg><use href="#t-git" /></svg>Create PR
|
|
139
|
+
</button>`
|
|
140
|
+
: "";
|
|
141
|
+
const k = store.runDoc.commit;
|
|
142
|
+
const empty = files
|
|
143
|
+
? ""
|
|
144
|
+
: html`<div class="gempty">
|
|
145
|
+
<b
|
|
146
|
+
>${pr && pr.state === "MERGED" ? "Merged" : b && b.landed ? "On " + b.base : g.ahead > 0 && (!b || b.upstream) ? "Not pushed yet" : "No changes to commit"}</b
|
|
147
|
+
><span
|
|
148
|
+
>${
|
|
149
|
+
pr && pr.state === "MERGED"
|
|
150
|
+
? `Pull request #${pr.number} is merged into ${b.base}. The worktree and its branch can go.`
|
|
151
|
+
: b && b.landed
|
|
152
|
+
? `Every commit of ${b.branch} is on ${b.base}. The worktree can go.`
|
|
153
|
+
: g.ahead > 0 && (!b || b.upstream)
|
|
154
|
+
? `${g.ahead} commit${g.ahead === 1 ? "" : "s"} ahead of ${target}.`
|
|
155
|
+
: pr && pr.state === "OPEN"
|
|
156
|
+
? `Pull request #${pr.number} is open against ${b.base}.`
|
|
157
|
+
: b && !b.upstream
|
|
158
|
+
? `${b.branch} is not on GitHub yet. Create PR pushes it and opens the pull request.`
|
|
159
|
+
: `Up to date with ${target}.`
|
|
160
|
+
}</span
|
|
161
|
+
>${k && k.sha ? html`<span class="dim">Last commit <code>${k.sha}</code>${k.pushed ? " pushed" : " not pushed"}.</span>` : ""}
|
|
162
|
+
</div>`;
|
|
163
|
+
const changes = files
|
|
164
|
+
? html`<div class="gsec">
|
|
165
|
+
<div class="ghd">Changes <span class="n">${files}</span></div>
|
|
166
|
+
<pre class="files">${g.files.join("\n")}</pre>
|
|
167
|
+
${g.others ? html`<div class="dim">${g.others} other changed file${g.others === 1 ? " is" : "s are"} left alone: they are not this run's.</div>` : ""}${
|
|
168
|
+
g.shared && g.shared.length
|
|
169
|
+
? html`<div class="dim">These files also hold other runs' changes, and a file is committed whole:</div>
|
|
170
|
+
<pre class="files">${g.shared.join("\n")}</pre>`
|
|
171
|
+
: ""
|
|
172
|
+
}<textarea id="gmsg" aria-label="Commit message" placeholder="feat(area): what changed">${u.msg}</textarea>
|
|
173
|
+
<div class="dim" id="glong" hidden>The first line is over 72 characters; logs will cut it short.</div>
|
|
174
|
+
</div>`
|
|
175
|
+
: "";
|
|
176
|
+
// The inline confirm or form the last click opened, in place of the split button.
|
|
177
|
+
const ask =
|
|
178
|
+
u.ask === "pr" || u.ask === "draft"
|
|
179
|
+
? html`<div class="gsec gform">
|
|
180
|
+
<div class="ghd">${u.ask === "draft" ? "Draft pull request" : "Pull request"} into ${b.base}</div>
|
|
181
|
+
<input
|
|
182
|
+
id="gtitle"
|
|
183
|
+
aria-label="Title"
|
|
184
|
+
value="${u.title ?? (commitMsg(store.runDoc.impl) || c.title || "").split("\n")[0]}"
|
|
185
|
+
/><textarea id="gbody" aria-label="Description">${u.body ?? `Run ${c.id}.`}</textarea>
|
|
186
|
+
<div class="row">
|
|
187
|
+
<button class="btn ghost" data-a="cancel">Cancel</button
|
|
188
|
+
><button class="btn pri" data-a="go-${u.ask}">
|
|
189
|
+
${b.upstream && g.ahead === 0 ? "" : "Push & "}${u.ask === "draft" ? "create draft PR" : "create PR"}
|
|
190
|
+
</button>
|
|
191
|
+
</div>
|
|
192
|
+
</div>`
|
|
193
|
+
: u.ask === "merge"
|
|
194
|
+
? html`<div class="gsec gform">
|
|
195
|
+
<div class="ghd">Merge #${pr.number} into ${b.base} by rebase?</div>
|
|
196
|
+
<div class="dim">The worktree stays until you remove it.</div>
|
|
197
|
+
<div class="row">
|
|
198
|
+
<button class="btn ghost" data-a="cancel">Cancel</button
|
|
199
|
+
><button class="btn pri" data-a="go-merge">Merge PR</button>
|
|
200
|
+
</div>
|
|
201
|
+
</div>`
|
|
202
|
+
: u.ask === "remove"
|
|
203
|
+
? html`<div class="gsec gform">
|
|
204
|
+
<div class="ghd">Remove the worktree and delete ${b.branch}?</div>
|
|
205
|
+
<div class="dim">Its work is on ${b.base}. The branch is deleted here and on GitHub.</div>
|
|
206
|
+
<div class="row">
|
|
207
|
+
<button class="btn ghost" data-a="cancel">Cancel</button
|
|
208
|
+
><button class="btn danger" data-a="go-remove">Remove workspace</button>
|
|
209
|
+
</div>
|
|
210
|
+
</div>`
|
|
211
|
+
: "";
|
|
212
|
+
const menu = all
|
|
213
|
+
.map(
|
|
214
|
+
(x) =>
|
|
215
|
+
html`<button data-a="${x.a}" ${x.why ? " disabled" : ""}>
|
|
216
|
+
<span>${x.label}</span>${x.why ? html`<small>${x.why}</small>` : ""}
|
|
217
|
+
</button>`,
|
|
218
|
+
)
|
|
219
|
+
.concat(
|
|
220
|
+
pr
|
|
221
|
+
? [
|
|
222
|
+
html`<hr />
|
|
223
|
+
<a href="${pr.url}" target="_blank" rel="noopener">Open PR on GitHub</a>`,
|
|
224
|
+
]
|
|
225
|
+
: [],
|
|
226
|
+
);
|
|
227
|
+
const split = ask
|
|
228
|
+
? ""
|
|
229
|
+
: html`<div class="split gsplit">
|
|
230
|
+
<button class="btn ${next ? "pri" : ""}" data-a="${next ? next.a : ""}" ${next ? "" : " disabled"}>
|
|
231
|
+
${next ? next.label : "Up to date"}</button
|
|
232
|
+
><button class="btn ${next ? "pri" : ""} gmore" aria-label="More git actions" aria-haspopup="menu">
|
|
233
|
+
<svg><use href="#i-chev" /></svg>
|
|
234
|
+
</button>
|
|
235
|
+
<div class="menu-pop" role="menu" hidden>${raw(menu.join(""))}</div>
|
|
236
|
+
</div>`;
|
|
237
|
+
body.innerHTML = html`<div class="gitp">
|
|
238
|
+
<div class="ghead">
|
|
239
|
+
${chip}
|
|
240
|
+
<div class="gbr" title="${g.branch}">${b ? b.branch : g.branch || "HEAD"}</div>
|
|
241
|
+
<div class="gto">→ ${target}</div>
|
|
242
|
+
</div>
|
|
243
|
+
${changes}${empty}${ask}${split}
|
|
244
|
+
</div>`;
|
|
245
|
+
wire(c, body.querySelector(".gitp"));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function wire(c, el) {
|
|
249
|
+
const u = st(c),
|
|
250
|
+
inp = el.querySelector("#gmsg");
|
|
251
|
+
if (inp) {
|
|
252
|
+
const fit = () => {
|
|
253
|
+
inp.style.height = "auto";
|
|
254
|
+
inp.style.height = Math.min(inp.scrollHeight + 2, innerHeight / 2) + "px";
|
|
255
|
+
$("glong").hidden = inp.value.split("\n")[0].length <= 72;
|
|
256
|
+
};
|
|
257
|
+
inp.oninput = () => {
|
|
258
|
+
u.msg = inp.value;
|
|
259
|
+
fit();
|
|
260
|
+
};
|
|
261
|
+
fit();
|
|
262
|
+
}
|
|
263
|
+
el.querySelector("#gtitle")?.addEventListener("input", (e) => (u.title = e.target.value));
|
|
264
|
+
el.querySelector("#gbody")?.addEventListener("input", (e) => (u.body = e.target.value));
|
|
265
|
+
const more = el.querySelector(".gmore"),
|
|
266
|
+
pop = el.querySelector(".gsplit .menu-pop");
|
|
267
|
+
if (more)
|
|
268
|
+
more.onclick = (e) => {
|
|
269
|
+
e.stopPropagation();
|
|
270
|
+
pop.hidden = !pop.hidden;
|
|
271
|
+
if (!pop.hidden) addEventListener("click", () => (pop.hidden = true), { once: true });
|
|
272
|
+
};
|
|
273
|
+
el.querySelectorAll("[data-a]").forEach((b) => {
|
|
274
|
+
if (!b.dataset.a) return;
|
|
275
|
+
b.onclick = () => act(c, b.dataset.a, b);
|
|
276
|
+
});
|
|
65
277
|
}
|
|
66
|
-
|
|
278
|
+
|
|
279
|
+
const BUSY = {
|
|
280
|
+
commit: "Pushing…",
|
|
281
|
+
push: "Pushing…",
|
|
282
|
+
"go-pr": "Creating PR…",
|
|
283
|
+
"go-draft": "Creating PR…",
|
|
284
|
+
"go-merge": "Merging…",
|
|
285
|
+
"go-remove": "Removing…",
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
async function act(c, a, b) {
|
|
289
|
+
const u = st(c);
|
|
290
|
+
if (a === "cancel") return ((u.ask = undefined), gitTab(c, false));
|
|
291
|
+
// Steps that need a second look open their form or confirm first.
|
|
292
|
+
if (a === "pr" || a === "draft" || a === "merge" || a === "remove") return ((u.ask = a), gitTab(c, false));
|
|
293
|
+
if (a === "commit" && !(u.msg || "").trim()) return toast("A commit message is required");
|
|
67
294
|
b.disabled = true;
|
|
68
295
|
b.dataset.busy = 1;
|
|
69
|
-
b.textContent = "
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
296
|
+
b.textContent = BUSY[a] || "Working…";
|
|
297
|
+
const base = { dir: c.state, id: c.id };
|
|
298
|
+
const r =
|
|
299
|
+
a === "commit" || a === "push"
|
|
300
|
+
? await post("/commit", { ...base, message: a === "commit" ? u.msg : "", files: store.runDoc.git.files })
|
|
301
|
+
: a === "go-pr" || a === "go-draft"
|
|
302
|
+
? await post("/pr", {
|
|
303
|
+
...base,
|
|
304
|
+
op: "create",
|
|
305
|
+
title: u.title ?? $("gtitle").value,
|
|
306
|
+
body: u.body ?? $("gbody").value,
|
|
307
|
+
draft: a === "go-draft",
|
|
308
|
+
})
|
|
309
|
+
: await post("/pr", { ...base, op: a === "go-merge" ? "merge" : "remove" });
|
|
310
|
+
if (r.ok) {
|
|
311
|
+
toast(
|
|
312
|
+
a === "commit" || a === "push"
|
|
313
|
+
? "Committed & pushed " + r.sha
|
|
314
|
+
: a === "go-merge"
|
|
315
|
+
? "Merged"
|
|
316
|
+
: a === "go-remove"
|
|
317
|
+
? "Worktree removed"
|
|
318
|
+
: "Pull request #" + r.pr.number + " opened",
|
|
319
|
+
);
|
|
320
|
+
ui.delete(key(c));
|
|
321
|
+
}
|
|
73
322
|
if (store.openKey !== key(c)) return;
|
|
323
|
+
delete b.dataset.busy;
|
|
74
324
|
await openRun(c, false);
|
|
75
|
-
// A refused message comes back for another try, beside the current file list.
|
|
76
|
-
if (!r.ok && message && store.openKey === key(c) && store.runDoc.git.files && store.runDoc.git.files.length)
|
|
77
|
-
confirmCommit(c, message);
|
|
78
325
|
}
|
package/web/board/panel.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { chat } from "./chat.ts";
|
|
|
7
7
|
import { stopDictation } from "./dictation.ts";
|
|
8
8
|
import { $, html, raw } from "./dom.ts";
|
|
9
9
|
import { fixForm, fixOff } from "./fixes.ts";
|
|
10
|
-
import {
|
|
10
|
+
import { gitPending, gitShown, gitTab } from "./git.ts";
|
|
11
11
|
import { ICON, WORD, need } from "./labels.ts";
|
|
12
12
|
import { attach, brief, md, planQuestions, preview, progress } from "./markdown.ts";
|
|
13
13
|
import { toast } from "./toast.ts";
|
|
@@ -24,6 +24,7 @@ const TABS = [
|
|
|
24
24
|
["Backlog", "backlog"],
|
|
25
25
|
["Work", "impl"],
|
|
26
26
|
["Review", "review"],
|
|
27
|
+
["Git", "git"],
|
|
27
28
|
["Preview", "preview"],
|
|
28
29
|
];
|
|
29
30
|
// keepTab: a link already chose the tab.
|
|
@@ -169,9 +170,11 @@ export async function openRun(c, refresh, again) {
|
|
|
169
170
|
(t) =>
|
|
170
171
|
t[1] === "request" ||
|
|
171
172
|
t[1] === "notes" ||
|
|
172
|
-
(t[1] === "
|
|
173
|
-
?
|
|
174
|
-
:
|
|
173
|
+
(t[1] === "git"
|
|
174
|
+
? gitShown(c)
|
|
175
|
+
: t[1] === "preview"
|
|
176
|
+
? preview(store.runDoc.impl)
|
|
177
|
+
: store.runDoc[t[1]] || (t[1] === "backlog" && c.column === 2 && store.runDoc.progress)),
|
|
175
178
|
);
|
|
176
179
|
if (store.wantTerm === key(c)) store.wantTerm = null;
|
|
177
180
|
// The agent is a centre tab of the run workspace only: the panel never shows a terminal.
|
|
@@ -180,7 +183,7 @@ export async function openRun(c, refresh, again) {
|
|
|
180
183
|
if (view === "run" && store.tab === "preview") store.tab = "review";
|
|
181
184
|
// A tab not written yet falls back to the latest one that is.
|
|
182
185
|
if (store.tab !== "term" && !tabs.some((t) => t[1] === store.tab))
|
|
183
|
-
store.tab = [...tabs].reverse().find((t) => t[1] !== "notes" && !(view === "run" && t[1] === "preview"))[1];
|
|
186
|
+
store.tab = [...tabs].reverse().find((t) => t[1] !== "notes" && t[1] !== "git" && !(view === "run" && t[1] === "preview"))[1];
|
|
184
187
|
if (store.tab !== "term") store.lastTab = store.tab;
|
|
185
188
|
$("panel").classList.toggle("wide", store.tab === "term");
|
|
186
189
|
const pt = $("pterm");
|
|
@@ -212,7 +215,8 @@ export async function openRun(c, refresh, again) {
|
|
|
212
215
|
else if (k === "notes") {
|
|
213
216
|
const ro = c.archived || c.status === "done" || c.status === "abandoned";
|
|
214
217
|
chat(c, doc, ro);
|
|
215
|
-
} else
|
|
218
|
+
} else if (k === "git") gitTab(c, refresh);
|
|
219
|
+
else
|
|
216
220
|
$("pbody").innerHTML = doc
|
|
217
221
|
? raw(md(doc, k === "backlog"))
|
|
218
222
|
: html`<p style="color:var(--dim)">No ${{ request: "request", plan: "plan", impl: "work report", preview: "preview", review: "review", backlog: "backlog" }[k]} yet.</p>`;
|
|
@@ -232,8 +236,9 @@ export async function openRun(c, refresh, again) {
|
|
|
232
236
|
const foot = $("pfoot");
|
|
233
237
|
// A refresh while the commit is being confirmed would wipe the message.
|
|
234
238
|
if (refresh && foot.querySelector(".inl,[data-busy],.more[open]")) return;
|
|
239
|
+
// Git work left on a finished run: the footer points at the Git tab, which holds it.
|
|
235
240
|
const arch =
|
|
236
|
-
|
|
241
|
+
(k !== "git" && gitPending(c) ? `<button class="btn" data-a="gittab">Git…</button>` : "") +
|
|
237
242
|
(c.archived
|
|
238
243
|
? `<button class="btn pri" data-a="restore">Restore</button>`
|
|
239
244
|
: `<button class="btn ghost" data-a="archive">Archive</button>`);
|
|
@@ -253,9 +258,7 @@ export async function openRun(c, refresh, again) {
|
|
|
253
258
|
: qs.length
|
|
254
259
|
? ` Approve first asks you ${qs.length === 1 ? "its question" : "its " + qs.length + " questions"}.`
|
|
255
260
|
: "";
|
|
256
|
-
// gitBtn's buttons restyled as menu rows.
|
|
257
261
|
const more =
|
|
258
|
-
gitBtn(c).replace(/class="btn( pri)?"/g, "") +
|
|
259
262
|
`<button data-a="archive">Archive</button><hr><button data-a="ab" class="danger">Abandon</button>`;
|
|
260
263
|
foot.innerHTML = html`<span class="note">${sent ? "Sent to your agent." : APPROVAL[c.awaiting] + asks}</span><details class="more"><summary class="btn ghost">More</summary><div class="menu-pop">${raw(more)}</div></details>${raw(rs)}<span class="dec"><button class="btn" data-a="revise"${sent ? " disabled" : ""}>Revise</button><button class="btn pri" data-a="approve"${sent ? " disabled" : ""}>${c.awaiting === "findings" ? "Approve as-is" : "Approve"}</button></span>`;
|
|
261
264
|
} else if (c.status === "waiting")
|
|
@@ -274,12 +277,9 @@ export async function openRun(c, refresh, again) {
|
|
|
274
277
|
toggleArchive(c, a === "archive");
|
|
275
278
|
return;
|
|
276
279
|
}
|
|
277
|
-
if (a === "
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
if (a === "commit") {
|
|
282
|
-
confirmCommit(c);
|
|
280
|
+
if (a === "gittab") {
|
|
281
|
+
store.tab = "git";
|
|
282
|
+
openRun(c, true);
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
285
|
if (a === "accept") {
|
package/web/board/run-view.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { termLoad } from "./agent-term.ts";
|
|
|
18
18
|
import { load, post } from "./api.ts";
|
|
19
19
|
import { attach, md, preview } from "./markdown.ts";
|
|
20
20
|
import { layout } from "./terms.ts";
|
|
21
|
-
import { cardHref, markCurrent, railData, titleOf, wsHref, wsOfCard } from "./workspace.ts";
|
|
21
|
+
import { cardHref, markCurrent, railData, stateOf, titleOf, wsHref, wsOfCard } from "./workspace.ts";
|
|
22
22
|
import { type Node, awaiting, chosen, finished, historyOf, leaves, liveIn, loopbackUrl, migrate, pickable, prune, reviewing, stageTabs, toOpen, wsKey } from "./ws-tabs.ts";
|
|
23
23
|
import { drawPick, hidePick, initPick, setOpen } from "./run-pick.ts";
|
|
24
24
|
import { age } from "./labels.ts";
|
|
@@ -76,9 +76,13 @@ let target: { screen: string; dir: "cols" | "rows" } | null = null;
|
|
|
76
76
|
function screens(): Screen[] {
|
|
77
77
|
const s = saved(),
|
|
78
78
|
ids = tabs().map((t) => t.id);
|
|
79
|
-
|
|
79
|
+
// In place: the panes on screen hold these objects, and a gutter drag writes its sizes into them.
|
|
80
|
+
s.screens = s.screens.filter((sc) => {
|
|
80
81
|
const tree = prune(sc.tree, (id) => ids.includes(id));
|
|
81
|
-
|
|
82
|
+
if (!tree) return false;
|
|
83
|
+
sc.tree = tree;
|
|
84
|
+
if (!leaves(tree).includes(sc.focus)) sc.focus = leaves(tree)[0];
|
|
85
|
+
return true;
|
|
82
86
|
});
|
|
83
87
|
for (const id of ids)
|
|
84
88
|
if (!s.screens.some((sc) => leaves(sc.tree).includes(id))) {
|
|
@@ -346,6 +350,8 @@ function build(n: Node, sc: Screen): HTMLElement {
|
|
|
346
350
|
sum = n.sizes[i - 1] + n.sizes[i],
|
|
347
351
|
start = horiz ? ra.left : ra.top;
|
|
348
352
|
g.setPointerCapture(e.pointerId);
|
|
353
|
+
// A frame under the pointer (the Browser, Preview) takes the moves for itself: frames ignore it while dragging.
|
|
354
|
+
document.body.classList.add("rdrag");
|
|
349
355
|
g.onpointermove = (m) => {
|
|
350
356
|
const f = Math.min(0.9, Math.max(0.1, ((horiz ? m.clientX : m.clientY) - start) / total));
|
|
351
357
|
n.sizes[i - 1] = sum * f;
|
|
@@ -353,8 +359,10 @@ function build(n: Node, sc: Screen): HTMLElement {
|
|
|
353
359
|
a.style.flexGrow = String(n.sizes[i - 1]);
|
|
354
360
|
b.style.flexGrow = String(n.sizes[i]);
|
|
355
361
|
};
|
|
356
|
-
g.onpointerup = () => {
|
|
357
|
-
g.onpointermove
|
|
362
|
+
g.onpointerup = g.onlostpointercapture = () => {
|
|
363
|
+
if (!g.onpointermove) return;
|
|
364
|
+
document.body.classList.remove("rdrag");
|
|
365
|
+
g.onpointermove = g.onpointerup = g.onlostpointercapture = null;
|
|
358
366
|
shownSig = sc.id + JSON.stringify(sc.tree);
|
|
359
367
|
save();
|
|
360
368
|
};
|
|
@@ -836,6 +844,19 @@ export function initRunView() {
|
|
|
836
844
|
markCurrent();
|
|
837
845
|
go("ws");
|
|
838
846
|
});
|
|
847
|
+
// Search's Tabs group: open the workspace on the screen holding that tab.
|
|
848
|
+
addEventListener("kz-open-tab", (e: any) => {
|
|
849
|
+
e.preventDefault();
|
|
850
|
+
const { dir, ws, id } = e.detail;
|
|
851
|
+
const k = wsKey(dir, ws),
|
|
852
|
+
s = ALL[k],
|
|
853
|
+
sc = s?.screens?.find((x) => leaves(x.tree).includes(id));
|
|
854
|
+
if (sc) (s.on = sc.id), save();
|
|
855
|
+
if (ctx?.k === k && document.body.classList.contains("runv")) return void draw();
|
|
856
|
+
history.pushState(null, "", wsHref(dir, ws));
|
|
857
|
+
markCurrent();
|
|
858
|
+
go("ws");
|
|
859
|
+
});
|
|
839
860
|
addEventListener("kz-run-preview", openPreview);
|
|
840
861
|
$("pnotes").onclick = () => void projectNotes();
|
|
841
862
|
$("pnlist").onclick = (e) => {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The search palette's matcher, apart from the page so a test can load it.
|
|
2
|
+
export type Item = { group: string; title: string; sub?: string; when?: string; hay: string; at?: number; dot?: string; ico: string; act: () => void };
|
|
3
|
+
|
|
4
|
+
// Every word of the query in the item; a title that starts with it ranks first, then a title
|
|
5
|
+
// holding it, then the rest by recency.
|
|
6
|
+
export function match(list: Item[], q: string): Item[] {
|
|
7
|
+
const words = q.toLowerCase().split(/\s+/).filter(Boolean);
|
|
8
|
+
if (!words.length) return list;
|
|
9
|
+
const lq = q.trim().toLowerCase();
|
|
10
|
+
const score = (i: Item) => {
|
|
11
|
+
const t = i.title.toLowerCase();
|
|
12
|
+
return t.startsWith(lq) ? 0 : t.includes(lq) ? 1 : 2;
|
|
13
|
+
};
|
|
14
|
+
return list
|
|
15
|
+
.filter((i) => {
|
|
16
|
+
const h = (i.title + " " + (i.sub ?? "") + " " + i.hay).toLowerCase();
|
|
17
|
+
return words.every((w) => h.includes(w));
|
|
18
|
+
})
|
|
19
|
+
.sort((a, b) => score(a) - score(b) || (b.at ?? 0) - (a.at ?? 0));
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { match } from "./search-match.ts";
|
|
3
|
+
|
|
4
|
+
const it = (title: string, at = 0, hay = "") => ({ group: "g", title, hay, at, ico: "run", act: () => {} });
|
|
5
|
+
|
|
6
|
+
test("an empty query keeps every item", () => {
|
|
7
|
+
const l = [it("a"), it("b")];
|
|
8
|
+
expect(match(l, " ")).toBe(l);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("every word must be present, in title, sub or keywords", () => {
|
|
12
|
+
const l = [it("Global search", 0, "kaizen"), it("Search tests"), it("Board")];
|
|
13
|
+
expect(match(l, "search kaizen").map((i) => i.title)).toEqual(["Global search"]);
|
|
14
|
+
expect(match(l, "SEARCH").map((i) => i.title).sort()).toEqual(["Global search", "Search tests"]);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("title prefix beats title contains beats keywords, then recency", () => {
|
|
18
|
+
const l = [it("Old board", 5, ""), it("Notes", 9, "board"), it("Board new", 1), it("Board recent", 3)];
|
|
19
|
+
expect(match(l, "board").map((i) => i.title)).toEqual(["Board recent", "Board new", "Old board", "Notes"]);
|
|
20
|
+
});
|