@moberg_hr/work-tree 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +632 -173
- package/dist/bin.js.map +1 -1
- package/dist/wd-bin.js +632 -173
- package/dist/wd-bin.js.map +1 -1
- package/package.json +1 -1
package/dist/wd-bin.js
CHANGED
|
@@ -321,26 +321,110 @@ async function fetchRemoteAsync(cwd) {
|
|
|
321
321
|
git(["remote", "set-head", "origin", "--auto"], cwd);
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
-
function
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
324
|
+
function gitAsync(args, cwd) {
|
|
325
|
+
debug("gitAsync", args.join(" "), `cwd=${cwd}`);
|
|
326
|
+
return new Promise((resolve) => {
|
|
327
|
+
execFile(
|
|
328
|
+
"git",
|
|
329
|
+
args,
|
|
330
|
+
{ cwd, encoding: "utf-8", timeout: 6e4, windowsHide: true },
|
|
331
|
+
(err, stdout, stderr) => {
|
|
332
|
+
const r = {
|
|
333
|
+
stdout: (stdout ?? "").toString().trim(),
|
|
334
|
+
stderr: (stderr ?? "").toString().trim(),
|
|
335
|
+
exitCode: err ? err.code ?? 1 : 0
|
|
336
|
+
};
|
|
337
|
+
if (typeof r.exitCode !== "number") r.exitCode = 1;
|
|
338
|
+
if (r.exitCode !== 0) {
|
|
339
|
+
debug("gitAsync failed", { args, exitCode: r.exitCode, stderr: r.stderr });
|
|
340
|
+
}
|
|
341
|
+
resolve(r);
|
|
342
|
+
}
|
|
343
|
+
);
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
async function getDefaultBranchAsync(cwd) {
|
|
347
|
+
const result = await gitAsync(["symbolic-ref", "refs/remotes/origin/HEAD"], cwd);
|
|
348
|
+
if (result.exitCode === 0 && result.stdout) {
|
|
349
|
+
return result.stdout.replace(/^refs\/remotes\/origin\//, "");
|
|
332
350
|
}
|
|
333
351
|
return null;
|
|
334
352
|
}
|
|
335
|
-
function
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
353
|
+
async function refExistsAsync(ref, cwd) {
|
|
354
|
+
return (await gitAsync(["rev-parse", "--verify", ref], cwd)).exitCode === 0;
|
|
355
|
+
}
|
|
356
|
+
async function checkSquashMergedAsync(branch, baseRef, cwd) {
|
|
357
|
+
const mb = await gitAsync(["merge-base", baseRef, branch], cwd);
|
|
358
|
+
if (mb.exitCode !== 0) return false;
|
|
359
|
+
const tree = await gitAsync(["rev-parse", `${branch}^{tree}`], cwd);
|
|
360
|
+
if (tree.exitCode !== 0) return false;
|
|
361
|
+
const dangling = await gitAsync(["commit-tree", tree.stdout, "-p", mb.stdout, "-m", ""], cwd);
|
|
362
|
+
if (dangling.exitCode !== 0) return false;
|
|
363
|
+
const cherry = await gitAsync(["cherry", baseRef, dangling.stdout], cwd);
|
|
364
|
+
if (cherry.exitCode !== 0) return false;
|
|
365
|
+
return cherry.stdout.startsWith("-");
|
|
366
|
+
}
|
|
367
|
+
async function checkMergeStatusAsync(branch, baseRef, cwd) {
|
|
368
|
+
const branchInBase = await gitAsync(["merge-base", "--is-ancestor", branch, baseRef], cwd);
|
|
369
|
+
if (branchInBase.exitCode !== 0) {
|
|
370
|
+
if (await checkSquashMergedAsync(branch, baseRef, cwd)) return "squash-merged";
|
|
371
|
+
return "unrelated";
|
|
372
|
+
}
|
|
373
|
+
const baseInBranch = await gitAsync(["merge-base", "--is-ancestor", baseRef, branch], cwd);
|
|
374
|
+
if (baseInBranch.exitCode === 0) return "merged";
|
|
375
|
+
const tip = await gitAsync(["rev-parse", branch], cwd);
|
|
376
|
+
if (tip.exitCode !== 0) return "unrelated";
|
|
377
|
+
const mainLine = await gitAsync(["rev-list", "--first-parent", "-n", "500", baseRef], cwd);
|
|
378
|
+
if (mainLine.exitCode === 0 && mainLine.stdout.includes(tip.stdout)) {
|
|
379
|
+
return "stale";
|
|
380
|
+
}
|
|
381
|
+
return "merged";
|
|
382
|
+
}
|
|
383
|
+
async function isBranchMergedAsync(branch, cwd, baseBranch) {
|
|
384
|
+
const defaultBranch = await getDefaultBranchAsync(cwd);
|
|
385
|
+
const bases = baseBranch ? [baseBranch] : [defaultBranch, "main", "master"].filter(
|
|
386
|
+
(b) => b !== null
|
|
387
|
+
);
|
|
388
|
+
const uniqueBases = [...new Set(bases)];
|
|
389
|
+
for (const base of uniqueBases) {
|
|
390
|
+
if (await refExistsAsync(`origin/${base}`, cwd)) {
|
|
391
|
+
const baseRef = `origin/${base}`;
|
|
392
|
+
const status = await checkMergeStatusAsync(branch, baseRef, cwd);
|
|
393
|
+
if (status === "merged") return { merged: true, into: baseRef, confidence: "merged" };
|
|
394
|
+
if (status === "squash-merged")
|
|
395
|
+
return { merged: true, into: baseRef, confidence: "squash-merged" };
|
|
396
|
+
if (status === "stale") return { merged: false, into: null, confidence: null };
|
|
397
|
+
}
|
|
398
|
+
if (await refExistsAsync(base, cwd)) {
|
|
399
|
+
const status = await checkMergeStatusAsync(branch, base, cwd);
|
|
400
|
+
if (status === "merged") return { merged: true, into: base, confidence: "merged" };
|
|
401
|
+
if (status === "squash-merged")
|
|
402
|
+
return { merged: true, into: base, confidence: "squash-merged" };
|
|
403
|
+
if (status === "stale") return { merged: false, into: null, confidence: null };
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return { merged: false, into: null, confidence: null };
|
|
407
|
+
}
|
|
408
|
+
async function countConflictsAsync(branch, cwd) {
|
|
409
|
+
const defaultBranch = await getDefaultBranchAsync(cwd) ?? "main";
|
|
410
|
+
const base = await refExistsAsync(`origin/${defaultBranch}`, cwd) ? `origin/${defaultBranch}` : defaultBranch;
|
|
411
|
+
const mergeBase = await gitAsync(["merge-base", base, branch], cwd);
|
|
339
412
|
if (mergeBase.exitCode !== 0) return 0;
|
|
340
|
-
const result =
|
|
413
|
+
const result = await gitAsync(["merge-tree", mergeBase.stdout, base, branch], cwd);
|
|
341
414
|
const conflicts = (result.stdout.match(/^<<<<<<< /gm) || []).length;
|
|
342
415
|
return conflicts;
|
|
343
416
|
}
|
|
417
|
+
async function rebaseOntoMainAsync(branch, cwd) {
|
|
418
|
+
const defaultBranch = await getDefaultBranchAsync(cwd) ?? "main";
|
|
419
|
+
await gitAsync(["fetch", "--quiet"], cwd);
|
|
420
|
+
const base = await refExistsAsync(`origin/${defaultBranch}`, cwd) ? `origin/${defaultBranch}` : defaultBranch;
|
|
421
|
+
const result = await gitAsync(["rebase", base, branch], cwd);
|
|
422
|
+
if (result.exitCode !== 0) {
|
|
423
|
+
await gitAsync(["rebase", "--abort"], cwd);
|
|
424
|
+
return result.stderr || "Rebase failed";
|
|
425
|
+
}
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
344
428
|
function getUnpushedCommits(cwd) {
|
|
345
429
|
const branch = getCurrentBranch(cwd);
|
|
346
430
|
if (!branch) return "";
|
|
@@ -3218,7 +3302,7 @@ import { render } from "ink";
|
|
|
3218
3302
|
|
|
3219
3303
|
// src/tui-ink/App.tsx
|
|
3220
3304
|
import { useState, useEffect, useRef, useCallback, useMemo } from "react";
|
|
3221
|
-
import { Box as
|
|
3305
|
+
import { Box as Box5 } from "ink";
|
|
3222
3306
|
import fs23 from "fs";
|
|
3223
3307
|
import os6 from "os";
|
|
3224
3308
|
import path20 from "path";
|
|
@@ -3535,7 +3619,7 @@ var PtySession = class {
|
|
|
3535
3619
|
cwd;
|
|
3536
3620
|
outputHandler;
|
|
3537
3621
|
_exited = false;
|
|
3538
|
-
|
|
3622
|
+
_status = "idle";
|
|
3539
3623
|
_outputBuffer = "";
|
|
3540
3624
|
_loggedOutput = false;
|
|
3541
3625
|
onExit;
|
|
@@ -3605,13 +3689,18 @@ var PtySession = class {
|
|
|
3605
3689
|
get exited() {
|
|
3606
3690
|
return this._exited;
|
|
3607
3691
|
}
|
|
3692
|
+
/** True when the session is not actively working (idle or needs input). */
|
|
3608
3693
|
get idle() {
|
|
3609
|
-
return this.
|
|
3694
|
+
return this._status !== "running";
|
|
3695
|
+
}
|
|
3696
|
+
/** Live status: 'running', 'idle' (turn finished) or 'attention' (needs input). */
|
|
3697
|
+
get status() {
|
|
3698
|
+
return this._status;
|
|
3610
3699
|
}
|
|
3611
|
-
/** Called by the dashboard when a hook event indicates
|
|
3612
|
-
|
|
3613
|
-
if (this._exited || this.
|
|
3614
|
-
this.
|
|
3700
|
+
/** Called by the dashboard when a hook event indicates a state change. */
|
|
3701
|
+
setStatus(status) {
|
|
3702
|
+
if (this._exited || this._status === status) return;
|
|
3703
|
+
this._status = status;
|
|
3615
3704
|
this.onStatusChange?.();
|
|
3616
3705
|
}
|
|
3617
3706
|
write(data) {
|
|
@@ -4078,7 +4167,7 @@ function renderBufferLines(buffer, cols, rows, scrollBack = 0) {
|
|
|
4078
4167
|
// src/tui-ink/Sidebar.tsx
|
|
4079
4168
|
import React from "react";
|
|
4080
4169
|
import { Box, Text } from "ink";
|
|
4081
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4170
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4082
4171
|
function buildSessionRows(sessions, statusMap) {
|
|
4083
4172
|
if (sessions.length === 0) return [];
|
|
4084
4173
|
const rows = [];
|
|
@@ -4087,7 +4176,7 @@ function buildSessionRows(sessions, statusMap) {
|
|
|
4087
4176
|
for (const s of sessions) {
|
|
4088
4177
|
const key = `${s.target}:${s.branch}`;
|
|
4089
4178
|
const status = statusMap?.get(key);
|
|
4090
|
-
if (status
|
|
4179
|
+
if (status !== void 0 && status !== "stopped") {
|
|
4091
4180
|
active.push(s);
|
|
4092
4181
|
} else {
|
|
4093
4182
|
inactive.push(s);
|
|
@@ -4211,6 +4300,47 @@ function cursorToRow(rows, cursor) {
|
|
|
4211
4300
|
function sessionKey2(s) {
|
|
4212
4301
|
return `${s.target}:${s.branch}`;
|
|
4213
4302
|
}
|
|
4303
|
+
function computeScrollOffset(rows, cursor, contentHeight) {
|
|
4304
|
+
let cursorRowIdx = 0;
|
|
4305
|
+
let selectableCount = 0;
|
|
4306
|
+
for (let i = 0; i < rows.length; i++) {
|
|
4307
|
+
if (rows[i].type !== "header") {
|
|
4308
|
+
if (selectableCount === cursor) {
|
|
4309
|
+
cursorRowIdx = i;
|
|
4310
|
+
break;
|
|
4311
|
+
}
|
|
4312
|
+
selectableCount++;
|
|
4313
|
+
}
|
|
4314
|
+
}
|
|
4315
|
+
if (rows.length > contentHeight && cursorRowIdx >= contentHeight - 1) {
|
|
4316
|
+
return Math.min(
|
|
4317
|
+
cursorRowIdx - contentHeight + 2,
|
|
4318
|
+
rows.length - contentHeight
|
|
4319
|
+
);
|
|
4320
|
+
}
|
|
4321
|
+
return 0;
|
|
4322
|
+
}
|
|
4323
|
+
function InputText({ value, pos, budget }) {
|
|
4324
|
+
let v = value;
|
|
4325
|
+
let p = pos;
|
|
4326
|
+
if (budget !== void 0 && value.length + 1 > budget) {
|
|
4327
|
+
const windowLen = Math.max(1, budget - 1);
|
|
4328
|
+
const start = Math.max(0, p - windowLen);
|
|
4329
|
+
v = value.slice(start, start + windowLen);
|
|
4330
|
+
p = pos - start;
|
|
4331
|
+
}
|
|
4332
|
+
if (p >= v.length) {
|
|
4333
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4334
|
+
/* @__PURE__ */ jsx(Text, { children: v }),
|
|
4335
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2588" })
|
|
4336
|
+
] });
|
|
4337
|
+
}
|
|
4338
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4339
|
+
/* @__PURE__ */ jsx(Text, { children: v.slice(0, p) }),
|
|
4340
|
+
/* @__PURE__ */ jsx(Text, { inverse: true, children: v[p] }),
|
|
4341
|
+
/* @__PURE__ */ jsx(Text, { children: v.slice(p + 1) })
|
|
4342
|
+
] });
|
|
4343
|
+
}
|
|
4214
4344
|
function truncate(str, max) {
|
|
4215
4345
|
if (max <= 1) return "";
|
|
4216
4346
|
return str.length > max ? str.slice(0, max - 1) + "\u2026" : str;
|
|
@@ -4255,8 +4385,8 @@ function SessionRow({
|
|
|
4255
4385
|
active,
|
|
4256
4386
|
width
|
|
4257
4387
|
}) {
|
|
4258
|
-
const dotChar = status === "
|
|
4259
|
-
const dotColor = status === "
|
|
4388
|
+
const dotChar = status === "attention" ? "\u25C6" : status === "idle" ? "\u25C7" : status === "running" ? "\u25CF" : "\u25CB";
|
|
4389
|
+
const dotColor = status === "attention" ? "yellow" : status === "idle" ? "cyan" : status === "running" ? "green" : "gray";
|
|
4260
4390
|
const agoStr = timeAgo(effectiveLastAccessedAt(s));
|
|
4261
4391
|
const mergedLen = merged ? 8 : 0;
|
|
4262
4392
|
const conflictLen = conflicts > 0 ? 2 + String(conflicts).length : 0;
|
|
@@ -4301,11 +4431,8 @@ function ProjectRow({
|
|
|
4301
4431
|
/* @__PURE__ */ jsx(Text, { color: "magenta", children: truncate(name, width - 15) }),
|
|
4302
4432
|
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
4303
4433
|
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "branch:" }),
|
|
4304
|
-
/* @__PURE__ */
|
|
4305
|
-
|
|
4306
|
-
branchInput.value
|
|
4307
|
-
] }),
|
|
4308
|
-
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2588" })
|
|
4434
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
4435
|
+
/* @__PURE__ */ jsx(InputText, { value: branchInput.value, pos: branchInput.pos })
|
|
4309
4436
|
] });
|
|
4310
4437
|
}
|
|
4311
4438
|
return /* @__PURE__ */ jsxs(Box, { width, children: [
|
|
@@ -4363,26 +4490,7 @@ function BorderedPane({
|
|
|
4363
4490
|
}) {
|
|
4364
4491
|
const innerWidth = width - 2;
|
|
4365
4492
|
const contentHeight = height - 2;
|
|
4366
|
-
|
|
4367
|
-
let selectableCount = 0;
|
|
4368
|
-
for (let i = 0; i < sidebarRows.length; i++) {
|
|
4369
|
-
if (sidebarRows[i].type !== "header") {
|
|
4370
|
-
if (selectableCount === cursor) {
|
|
4371
|
-
cursorRowIdx = i;
|
|
4372
|
-
break;
|
|
4373
|
-
}
|
|
4374
|
-
selectableCount++;
|
|
4375
|
-
}
|
|
4376
|
-
}
|
|
4377
|
-
let scrollOffset = 0;
|
|
4378
|
-
if (sidebarRows.length > contentHeight) {
|
|
4379
|
-
if (cursorRowIdx >= contentHeight - 1) {
|
|
4380
|
-
scrollOffset = Math.min(
|
|
4381
|
-
cursorRowIdx - contentHeight + 2,
|
|
4382
|
-
sidebarRows.length - contentHeight
|
|
4383
|
-
);
|
|
4384
|
-
}
|
|
4385
|
-
}
|
|
4493
|
+
const scrollOffset = computeScrollOffset(sidebarRows, cursor, contentHeight);
|
|
4386
4494
|
const rendered = [];
|
|
4387
4495
|
let selectableIdx = 0;
|
|
4388
4496
|
for (let i = 0; i < scrollOffset; i++) {
|
|
@@ -4403,7 +4511,14 @@ function BorderedPane({
|
|
|
4403
4511
|
rendered.push(renderRow(row, rowIdx, sel));
|
|
4404
4512
|
}
|
|
4405
4513
|
}
|
|
4406
|
-
const
|
|
4514
|
+
const hiddenAbove = scrollOffset;
|
|
4515
|
+
const hiddenBelow = Math.max(0, sidebarRows.length - (scrollOffset + contentHeight));
|
|
4516
|
+
const upText = hiddenAbove > 0 ? ` \u2191${hiddenAbove} ` : "";
|
|
4517
|
+
const downText = hiddenBelow > 0 ? ` \u2193${hiddenBelow} ` : "";
|
|
4518
|
+
const titlePart = title ? "\u2500 " + title + " " : "";
|
|
4519
|
+
const topFill = Math.max(0, innerWidth - titlePart.length - upText.length);
|
|
4520
|
+
const topBorder = "\u250C" + titlePart + "\u2500".repeat(topFill) + upText + "\u2510";
|
|
4521
|
+
const bottomBorder = "\u2514" + "\u2500".repeat(Math.max(0, innerWidth - downText.length)) + downText + "\u2518";
|
|
4407
4522
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", width, children: [
|
|
4408
4523
|
/* @__PURE__ */ jsx(Text, { color: borderColor, children: topBorder }),
|
|
4409
4524
|
rendered.map((row, i) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
@@ -4411,12 +4526,13 @@ function BorderedPane({
|
|
|
4411
4526
|
row,
|
|
4412
4527
|
/* @__PURE__ */ jsx(Text, { color: borderColor, children: "\u2502" })
|
|
4413
4528
|
] }, i)),
|
|
4414
|
-
/* @__PURE__ */ jsx(Text, { color: borderColor, children:
|
|
4529
|
+
/* @__PURE__ */ jsx(Text, { color: borderColor, children: bottomBorder })
|
|
4415
4530
|
] });
|
|
4416
4531
|
}
|
|
4417
|
-
|
|
4532
|
+
var Sidebar = React.memo(function Sidebar2({ sidebarRows, cursor, focused, statusMap, conflictCounts, mergedSet, prMap, activeKey, width, height, branchInput, filter }) {
|
|
4418
4533
|
const borderColor = focused ? "cyan" : "gray";
|
|
4419
4534
|
const innerWidth = width - 2;
|
|
4535
|
+
const title = filter ? `Worktrees /${filter.value}${filter.editing ? "\u2588" : ""}` : "Worktrees";
|
|
4420
4536
|
return /* @__PURE__ */ jsx(
|
|
4421
4537
|
BorderedPane,
|
|
4422
4538
|
{
|
|
@@ -4424,7 +4540,7 @@ function Sidebar({ sidebarRows, cursor, focused, statusMap, conflictCounts, merg
|
|
|
4424
4540
|
cursor,
|
|
4425
4541
|
focused,
|
|
4426
4542
|
borderColor,
|
|
4427
|
-
title
|
|
4543
|
+
title,
|
|
4428
4544
|
width,
|
|
4429
4545
|
height,
|
|
4430
4546
|
renderRow: (row, i, sel) => {
|
|
@@ -4465,7 +4581,7 @@ function Sidebar({ sidebarRows, cursor, focused, statusMap, conflictCounts, merg
|
|
|
4465
4581
|
}
|
|
4466
4582
|
}
|
|
4467
4583
|
);
|
|
4468
|
-
}
|
|
4584
|
+
});
|
|
4469
4585
|
function statusColor(status) {
|
|
4470
4586
|
const lower = status.toLowerCase();
|
|
4471
4587
|
if (lower.includes("progress") || lower.includes("review")) return "cyan";
|
|
@@ -4490,7 +4606,7 @@ function JiraListRow({
|
|
|
4490
4606
|
/* @__PURE__ */ jsx(Text, { children: truncate(issue.summary, summaryBudget) })
|
|
4491
4607
|
] });
|
|
4492
4608
|
}
|
|
4493
|
-
|
|
4609
|
+
var PrPane = React.memo(function PrPane2({ prRows, cursor, focused, localBranches, width, height }) {
|
|
4494
4610
|
const borderColor = focused ? "cyan" : "gray";
|
|
4495
4611
|
const innerWidth = width - 2;
|
|
4496
4612
|
return /* @__PURE__ */ jsx(
|
|
@@ -4521,7 +4637,7 @@ function PrPane({ prRows, cursor, focused, localBranches, width, height }) {
|
|
|
4521
4637
|
}
|
|
4522
4638
|
}
|
|
4523
4639
|
);
|
|
4524
|
-
}
|
|
4640
|
+
});
|
|
4525
4641
|
function TaskListRow({
|
|
4526
4642
|
task,
|
|
4527
4643
|
selected,
|
|
@@ -4543,22 +4659,21 @@ function TaskListRow({
|
|
|
4543
4659
|
/* @__PURE__ */ jsx(Text, { dimColor: true, children: idStr })
|
|
4544
4660
|
] });
|
|
4545
4661
|
}
|
|
4546
|
-
function TaskInputRow({ value, width }) {
|
|
4662
|
+
function TaskInputRow({ value, pos, width }) {
|
|
4547
4663
|
const budget = Math.max(4, width - 8);
|
|
4548
4664
|
return /* @__PURE__ */ jsxs(Box, { width, children: [
|
|
4549
4665
|
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
4550
4666
|
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "+ " }),
|
|
4551
|
-
/* @__PURE__ */ jsx(
|
|
4552
|
-
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2588" })
|
|
4667
|
+
/* @__PURE__ */ jsx(InputText, { value, pos, budget })
|
|
4553
4668
|
] });
|
|
4554
4669
|
}
|
|
4555
|
-
|
|
4670
|
+
var TaskPane = React.memo(function TaskPane2({ taskRows, cursor, focused, width, height, taskInput }) {
|
|
4556
4671
|
const borderColor = focused ? "cyan" : "gray";
|
|
4557
4672
|
const innerWidth = width - 2;
|
|
4558
4673
|
const contentHeight = height - 2;
|
|
4559
4674
|
if (taskInput !== null && taskInput !== void 0) {
|
|
4560
4675
|
const rendered = [];
|
|
4561
|
-
rendered.push(/* @__PURE__ */ jsx(TaskInputRow, { value: taskInput, width: innerWidth }, "input"));
|
|
4676
|
+
rendered.push(/* @__PURE__ */ jsx(TaskInputRow, { value: taskInput.value, pos: taskInput.pos, width: innerWidth }, "input"));
|
|
4562
4677
|
let selectableIdx = 0;
|
|
4563
4678
|
for (let i = 0; i < contentHeight - 1 && i < taskRows.length; i++) {
|
|
4564
4679
|
const row = taskRows[i];
|
|
@@ -4613,8 +4728,8 @@ function TaskPane({ taskRows, cursor, focused, width, height, taskInput }) {
|
|
|
4613
4728
|
}
|
|
4614
4729
|
}
|
|
4615
4730
|
);
|
|
4616
|
-
}
|
|
4617
|
-
|
|
4731
|
+
});
|
|
4732
|
+
var JiraPane = React.memo(function JiraPane2({ jiraRows, cursor, focused, width, height }) {
|
|
4618
4733
|
const borderColor = focused ? "cyan" : "gray";
|
|
4619
4734
|
const innerWidth = width - 2;
|
|
4620
4735
|
return /* @__PURE__ */ jsx(
|
|
@@ -4644,12 +4759,13 @@ function JiraPane({ jiraRows, cursor, focused, width, height }) {
|
|
|
4644
4759
|
}
|
|
4645
4760
|
}
|
|
4646
4761
|
);
|
|
4647
|
-
}
|
|
4762
|
+
});
|
|
4648
4763
|
|
|
4649
4764
|
// src/tui-ink/TerminalPane.tsx
|
|
4765
|
+
import React2 from "react";
|
|
4650
4766
|
import { Box as Box2, Text as Text2 } from "ink";
|
|
4651
4767
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
4652
|
-
|
|
4768
|
+
var TerminalPane = React2.memo(function TerminalPane2({ lines, width, height, focused, placeholder, title, scrollback }) {
|
|
4653
4769
|
const borderColor = focused ? "cyan" : "gray";
|
|
4654
4770
|
const innerWidth = width - 2;
|
|
4655
4771
|
const contentHeight = height - 2;
|
|
@@ -4675,8 +4791,10 @@ function TerminalPane({ lines, width, height, focused, placeholder, title }) {
|
|
|
4675
4791
|
}
|
|
4676
4792
|
}
|
|
4677
4793
|
}
|
|
4794
|
+
const scrolledTitle = scrollback && scrollback > 0 ? `${title ?? "Terminal"} \u2500 \u2191${scrollback} paused (pgdn/type to resume)` : title;
|
|
4795
|
+
const topBorder = scrolledTitle ? "\u250C\u2500 " + scrolledTitle + " " + "\u2500".repeat(Math.max(0, innerWidth - scrolledTitle.length - 3)) + "\u2510" : "\u250C" + "\u2500".repeat(innerWidth) + "\u2510";
|
|
4678
4796
|
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", width, children: [
|
|
4679
|
-
/* @__PURE__ */ jsx2(Text2, { color:
|
|
4797
|
+
/* @__PURE__ */ jsx2(Text2, { color: scrollback && scrollback > 0 ? "yellow" : borderColor, children: topBorder }),
|
|
4680
4798
|
content.map((row, i) => /* @__PURE__ */ jsxs2(Box2, { children: [
|
|
4681
4799
|
/* @__PURE__ */ jsx2(Text2, { color: borderColor, children: "\u2502" }),
|
|
4682
4800
|
/* @__PURE__ */ jsx2(Box2, { width: innerWidth, children: row }),
|
|
@@ -4684,19 +4802,20 @@ function TerminalPane({ lines, width, height, focused, placeholder, title }) {
|
|
|
4684
4802
|
] }, i)),
|
|
4685
4803
|
/* @__PURE__ */ jsx2(Text2, { color: borderColor, children: "\u2514" + "\u2500".repeat(innerWidth) + "\u2518" })
|
|
4686
4804
|
] });
|
|
4687
|
-
}
|
|
4805
|
+
});
|
|
4688
4806
|
|
|
4689
4807
|
// src/tui-ink/StatusBar.tsx
|
|
4808
|
+
import React3 from "react";
|
|
4690
4809
|
import { Box as Box3, Text as Text3 } from "ink";
|
|
4691
|
-
import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
4810
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
4692
4811
|
var PANE_HINTS = {
|
|
4693
|
-
sessions: " tab pane j/k nav enter start n new d remove
|
|
4694
|
-
tasks: " tab pane j/k nav enter toggle a add e edit w worktree d remove
|
|
4695
|
-
prs: " tab pane j/k nav enter checkout g sync
|
|
4696
|
-
jira: " tab pane j/k nav enter worktree o open g sync
|
|
4697
|
-
terminal: " tab pane ctrl+] detach "
|
|
4812
|
+
sessions: " tab pane j/k nav / filter enter start n new d remove u rebase g sync ? help q quit ",
|
|
4813
|
+
tasks: " tab pane j/k nav enter toggle a add e edit w worktree d remove ? help q quit ",
|
|
4814
|
+
prs: " tab pane j/k nav enter checkout o open g sync ? help q quit ",
|
|
4815
|
+
jira: " tab pane j/k nav enter worktree o open g sync ? help q quit ",
|
|
4816
|
+
terminal: " tab pane ctrl+] detach pgup/pgdn scroll "
|
|
4698
4817
|
};
|
|
4699
|
-
|
|
4818
|
+
var StatusBar = React3.memo(function StatusBar2({ message, pane, syncing }) {
|
|
4700
4819
|
if (message) {
|
|
4701
4820
|
return /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
4702
4821
|
/* @__PURE__ */ jsxs3(Text3, { color: "yellow", children: [
|
|
@@ -4709,21 +4828,217 @@ function StatusBar({ message, pane, syncing }) {
|
|
|
4709
4828
|
}
|
|
4710
4829
|
return /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
4711
4830
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: PANE_HINTS[pane] }),
|
|
4712
|
-
pane === "sessions" && /* @__PURE__ */ jsxs3(
|
|
4831
|
+
pane === "sessions" && /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
4713
4832
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "[" }),
|
|
4714
4833
|
/* @__PURE__ */ jsx3(Text3, { color: "green", children: "\u25CF" }),
|
|
4715
4834
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " working " }),
|
|
4716
4835
|
/* @__PURE__ */ jsx3(Text3, { color: "yellow", children: "\u25C6" }),
|
|
4717
4836
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " needs input " }),
|
|
4837
|
+
/* @__PURE__ */ jsx3(Text3, { color: "cyan", children: "\u25C7" }),
|
|
4838
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " done " }),
|
|
4718
4839
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "\u25CB stopped]" })
|
|
4719
4840
|
] }),
|
|
4720
4841
|
syncing && /* @__PURE__ */ jsx3(Box3, { flexGrow: 1 }),
|
|
4721
4842
|
syncing && /* @__PURE__ */ jsx3(Text3, { color: "cyan", children: " syncing" })
|
|
4722
4843
|
] });
|
|
4844
|
+
});
|
|
4845
|
+
|
|
4846
|
+
// src/tui-ink/HelpOverlay.tsx
|
|
4847
|
+
import React4 from "react";
|
|
4848
|
+
import { Box as Box4, Text as Text4 } from "ink";
|
|
4849
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
4850
|
+
var HELP = [
|
|
4851
|
+
{ type: "section", label: "Navigation" },
|
|
4852
|
+
{ type: "key", keys: "tab", desc: "cycle pane focus" },
|
|
4853
|
+
{ type: "key", keys: "j/k or \u2191/\u2193", desc: "move cursor" },
|
|
4854
|
+
{ type: "key", keys: "ctrl+d / ctrl+u", desc: "half-page down / up" },
|
|
4855
|
+
{ type: "key", keys: "pgup / pgdn", desc: "page up / down" },
|
|
4856
|
+
{ type: "key", keys: "mouse", desc: "wheel scrolls, click focuses + selects" },
|
|
4857
|
+
{ type: "blank" },
|
|
4858
|
+
{ type: "section", label: "Worktrees pane" },
|
|
4859
|
+
{ type: "key", keys: "enter", desc: "start / show session" },
|
|
4860
|
+
{ type: "key", keys: "/", desc: "filter sessions (enter keeps, esc clears)" },
|
|
4861
|
+
{ type: "key", keys: "n", desc: "new worktree" },
|
|
4862
|
+
{ type: "key", keys: "d", desc: "remove worktree (press d again to confirm)" },
|
|
4863
|
+
{ type: "key", keys: ".", desc: "open in editor" },
|
|
4864
|
+
{ type: "key", keys: "u", desc: "rebase onto main" },
|
|
4865
|
+
{ type: "blank" },
|
|
4866
|
+
{ type: "section", label: "Pull Requests / Jira panes" },
|
|
4867
|
+
{ type: "key", keys: "enter", desc: "checkout PR / create worktree for issue" },
|
|
4868
|
+
{ type: "key", keys: "o", desc: "open in browser" },
|
|
4869
|
+
{ type: "blank" },
|
|
4870
|
+
{ type: "section", label: "Tasks pane" },
|
|
4871
|
+
{ type: "key", keys: "enter or x", desc: "toggle done" },
|
|
4872
|
+
{ type: "key", keys: "a / e / d", desc: "add / edit / remove task" },
|
|
4873
|
+
{ type: "key", keys: "w", desc: "create worktree from task" },
|
|
4874
|
+
{ type: "blank" },
|
|
4875
|
+
{ type: "section", label: "Terminal" },
|
|
4876
|
+
{ type: "key", keys: "ctrl+]", desc: "detach back to sidebar" },
|
|
4877
|
+
{ type: "key", keys: "pgup / pgdn", desc: "scroll history (typing resumes live)" },
|
|
4878
|
+
{ type: "blank" },
|
|
4879
|
+
{ type: "section", label: "Global" },
|
|
4880
|
+
{ type: "key", keys: "g / G", desc: "sync focused pane / sync everything" },
|
|
4881
|
+
{ type: "key", keys: "r", desc: "refresh all panes" },
|
|
4882
|
+
{ type: "key", keys: "?", desc: "toggle this help" },
|
|
4883
|
+
{ type: "key", keys: "q or ctrl+c", desc: "quit" }
|
|
4884
|
+
];
|
|
4885
|
+
var HelpOverlay = React4.memo(function HelpOverlay2({ width, height }) {
|
|
4886
|
+
const innerWidth = width - 2;
|
|
4887
|
+
const contentHeight = height - 2;
|
|
4888
|
+
const title = "Help \u2014 press ? or esc to close";
|
|
4889
|
+
const topBorder = "\u250C\u2500 " + title + " " + "\u2500".repeat(Math.max(0, innerWidth - title.length - 3)) + "\u2510";
|
|
4890
|
+
const rows = [];
|
|
4891
|
+
for (let i = 0; i < contentHeight; i++) {
|
|
4892
|
+
const line = HELP[i];
|
|
4893
|
+
if (!line || line.type === "blank") {
|
|
4894
|
+
rows.push(/* @__PURE__ */ jsx4(Text4, { children: " ".repeat(innerWidth) }, i));
|
|
4895
|
+
continue;
|
|
4896
|
+
}
|
|
4897
|
+
if (line.type === "section") {
|
|
4898
|
+
rows.push(
|
|
4899
|
+
/* @__PURE__ */ jsx4(Box4, { width: innerWidth, children: /* @__PURE__ */ jsx4(Text4, { color: "yellow", bold: true, children: " " + line.label }) }, i)
|
|
4900
|
+
);
|
|
4901
|
+
continue;
|
|
4902
|
+
}
|
|
4903
|
+
rows.push(
|
|
4904
|
+
/* @__PURE__ */ jsxs4(Box4, { width: innerWidth, children: [
|
|
4905
|
+
/* @__PURE__ */ jsx4(Text4, { color: "cyan", children: " " + line.keys.padEnd(18) }),
|
|
4906
|
+
/* @__PURE__ */ jsx4(Text4, { children: line.desc })
|
|
4907
|
+
] }, i)
|
|
4908
|
+
);
|
|
4909
|
+
}
|
|
4910
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", width, children: [
|
|
4911
|
+
/* @__PURE__ */ jsx4(Text4, { color: "cyan", children: topBorder }),
|
|
4912
|
+
rows.map((row, i) => /* @__PURE__ */ jsxs4(Box4, { children: [
|
|
4913
|
+
/* @__PURE__ */ jsx4(Text4, { color: "cyan", children: "\u2502" }),
|
|
4914
|
+
row,
|
|
4915
|
+
/* @__PURE__ */ jsx4(Text4, { color: "cyan", children: "\u2502" })
|
|
4916
|
+
] }, i)),
|
|
4917
|
+
/* @__PURE__ */ jsx4(Text4, { color: "cyan", children: "\u2514" + "\u2500".repeat(innerWidth) + "\u2518" })
|
|
4918
|
+
] });
|
|
4919
|
+
});
|
|
4920
|
+
|
|
4921
|
+
// src/tui-ink/line-editor.ts
|
|
4922
|
+
var KEYS = {
|
|
4923
|
+
UP: "\x1B[A",
|
|
4924
|
+
DOWN: "\x1B[B",
|
|
4925
|
+
RIGHT: "\x1B[C",
|
|
4926
|
+
LEFT: "\x1B[D",
|
|
4927
|
+
HOME: "\x1B[H",
|
|
4928
|
+
END: "\x1B[F",
|
|
4929
|
+
HOME_ALT: "\x1B[1~",
|
|
4930
|
+
END_ALT: "\x1B[4~",
|
|
4931
|
+
PAGE_UP: "\x1B[5~",
|
|
4932
|
+
PAGE_DOWN: "\x1B[6~",
|
|
4933
|
+
DELETE: "\x1B[3~",
|
|
4934
|
+
ESC: "\x1B",
|
|
4935
|
+
ENTER: "\r",
|
|
4936
|
+
BACKSPACE: "\x7F",
|
|
4937
|
+
BACKSPACE_ALT: "\b",
|
|
4938
|
+
CTRL_C: "",
|
|
4939
|
+
CTRL_D: "",
|
|
4940
|
+
CTRL_U: "",
|
|
4941
|
+
TAB: " "
|
|
4942
|
+
};
|
|
4943
|
+
function splitInputChunks(data) {
|
|
4944
|
+
const tokens = [];
|
|
4945
|
+
let i = 0;
|
|
4946
|
+
let run2 = "";
|
|
4947
|
+
const flushRun = () => {
|
|
4948
|
+
if (run2) {
|
|
4949
|
+
tokens.push(run2);
|
|
4950
|
+
run2 = "";
|
|
4951
|
+
}
|
|
4952
|
+
};
|
|
4953
|
+
while (i < data.length) {
|
|
4954
|
+
const ch = data[i];
|
|
4955
|
+
if (ch === "\x1B") {
|
|
4956
|
+
flushRun();
|
|
4957
|
+
const next = data[i + 1];
|
|
4958
|
+
if (next === "[") {
|
|
4959
|
+
let j = i + 2;
|
|
4960
|
+
while (j < data.length) {
|
|
4961
|
+
const code2 = data.charCodeAt(j);
|
|
4962
|
+
if (code2 >= 64 && code2 <= 126) break;
|
|
4963
|
+
j++;
|
|
4964
|
+
}
|
|
4965
|
+
tokens.push(data.slice(i, Math.min(j + 1, data.length)));
|
|
4966
|
+
i = j + 1;
|
|
4967
|
+
continue;
|
|
4968
|
+
}
|
|
4969
|
+
if (next === "O" && i + 2 < data.length) {
|
|
4970
|
+
tokens.push(data.slice(i, i + 3));
|
|
4971
|
+
i += 3;
|
|
4972
|
+
continue;
|
|
4973
|
+
}
|
|
4974
|
+
tokens.push("\x1B");
|
|
4975
|
+
i++;
|
|
4976
|
+
continue;
|
|
4977
|
+
}
|
|
4978
|
+
const code = data.charCodeAt(i);
|
|
4979
|
+
if (code < 32 || code === 127) {
|
|
4980
|
+
flushRun();
|
|
4981
|
+
tokens.push(ch);
|
|
4982
|
+
i++;
|
|
4983
|
+
continue;
|
|
4984
|
+
}
|
|
4985
|
+
run2 += ch;
|
|
4986
|
+
i++;
|
|
4987
|
+
}
|
|
4988
|
+
flushRun();
|
|
4989
|
+
return tokens;
|
|
4990
|
+
}
|
|
4991
|
+
function sanitizePaste(text) {
|
|
4992
|
+
const firstLine = text.split(/\r|\n/, 1)[0] ?? "";
|
|
4993
|
+
return firstLine.replace(/[\u0000-\u001f\u007f]/g, "");
|
|
4994
|
+
}
|
|
4995
|
+
function editLine(state, token) {
|
|
4996
|
+
const { value, pos } = state;
|
|
4997
|
+
switch (token) {
|
|
4998
|
+
case KEYS.ESC:
|
|
4999
|
+
case KEYS.CTRL_C:
|
|
5000
|
+
return { state, action: "cancel" };
|
|
5001
|
+
case KEYS.ENTER:
|
|
5002
|
+
return { state, action: "submit" };
|
|
5003
|
+
case KEYS.BACKSPACE:
|
|
5004
|
+
case KEYS.BACKSPACE_ALT:
|
|
5005
|
+
if (pos === 0) return { state, action: null };
|
|
5006
|
+
return {
|
|
5007
|
+
state: { value: value.slice(0, pos - 1) + value.slice(pos), pos: pos - 1 },
|
|
5008
|
+
action: null
|
|
5009
|
+
};
|
|
5010
|
+
case KEYS.DELETE:
|
|
5011
|
+
if (pos >= value.length) return { state, action: null };
|
|
5012
|
+
return {
|
|
5013
|
+
state: { value: value.slice(0, pos) + value.slice(pos + 1), pos },
|
|
5014
|
+
action: null
|
|
5015
|
+
};
|
|
5016
|
+
case KEYS.LEFT:
|
|
5017
|
+
return { state: { value, pos: Math.max(0, pos - 1) }, action: null };
|
|
5018
|
+
case KEYS.RIGHT:
|
|
5019
|
+
return { state: { value, pos: Math.min(value.length, pos + 1) }, action: null };
|
|
5020
|
+
case KEYS.HOME:
|
|
5021
|
+
case KEYS.HOME_ALT:
|
|
5022
|
+
return { state: { value, pos: 0 }, action: null };
|
|
5023
|
+
case KEYS.END:
|
|
5024
|
+
case KEYS.END_ALT:
|
|
5025
|
+
return { state: { value, pos: value.length }, action: null };
|
|
5026
|
+
case KEYS.CTRL_U:
|
|
5027
|
+
return { state: { value: value.slice(pos), pos: 0 }, action: null };
|
|
5028
|
+
}
|
|
5029
|
+
if (token.startsWith("\x1B") || token.charCodeAt(0) < 32 || token === "\x7F") {
|
|
5030
|
+
return { state, action: null };
|
|
5031
|
+
}
|
|
5032
|
+
const insert = sanitizePaste(token);
|
|
5033
|
+
if (!insert) return { state, action: null };
|
|
5034
|
+
return {
|
|
5035
|
+
state: { value: value.slice(0, pos) + insert + value.slice(pos), pos: pos + insert.length },
|
|
5036
|
+
action: null
|
|
5037
|
+
};
|
|
4723
5038
|
}
|
|
4724
5039
|
|
|
4725
5040
|
// src/tui-ink/App.tsx
|
|
4726
|
-
import { jsx as
|
|
5041
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
4727
5042
|
var DETACH_KEY = "";
|
|
4728
5043
|
var TAB_KEY = " ";
|
|
4729
5044
|
var RENDER_INTERVAL_MS = 50;
|
|
@@ -4731,7 +5046,7 @@ var MOUSE_SGR_RE = /\x1b\[<(\d+);(\d+);(\d+)[Mm]/;
|
|
|
4731
5046
|
function hasClaudeConversation(dir) {
|
|
4732
5047
|
try {
|
|
4733
5048
|
const resolved = path20.resolve(dir);
|
|
4734
|
-
const projectDir = resolved.replace(/[
|
|
5049
|
+
const projectDir = resolved.replace(/[^a-zA-Z0-9-]/g, "-");
|
|
4735
5050
|
const claudeProjectPath = path20.join(os6.homedir(), ".claude", "projects", projectDir);
|
|
4736
5051
|
if (!fs23.existsSync(claudeProjectPath)) return false;
|
|
4737
5052
|
const files = fs23.readdirSync(claudeProjectPath);
|
|
@@ -4826,20 +5141,35 @@ function App({ unsafe, onExit }) {
|
|
|
4826
5141
|
const [pendingJiraIssue, setPendingJiraIssue] = useState(null);
|
|
4827
5142
|
const [pendingTask, setPendingTask] = useState(null);
|
|
4828
5143
|
const [savedSessionCursor, setSavedSessionCursor] = useState(0);
|
|
5144
|
+
const [showHelp2, setShowHelp] = useState(false);
|
|
5145
|
+
const [filter, setFilter] = useState(null);
|
|
5146
|
+
const [pendingRemoveKey, setPendingRemoveKey] = useState(null);
|
|
5147
|
+
const [termScroll, setTermScroll] = useState(0);
|
|
5148
|
+
const setScrollBack = useCallback((n) => {
|
|
5149
|
+
termScrollBack.current = n;
|
|
5150
|
+
setTermScroll(n);
|
|
5151
|
+
}, []);
|
|
4829
5152
|
const localBranches = useMemo(() => new Set(sessions.map((s) => s.branch)), [sessions]);
|
|
4830
5153
|
const projectRows = useMemo(() => buildProjectRows(projects), [projects]);
|
|
4831
5154
|
const prRows = useMemo(() => buildPrRows(prMap), [prMap]);
|
|
4832
5155
|
const jiraRows = useMemo(() => buildJiraRows(jiraIssues), [jiraIssues]);
|
|
4833
5156
|
const taskRows = useMemo(() => buildTaskRows(tasks), [tasks]);
|
|
5157
|
+
const filteredSessions = useMemo(() => {
|
|
5158
|
+
const q = filter?.value.trim().toLowerCase();
|
|
5159
|
+
if (!q) return sessions;
|
|
5160
|
+
return sessions.filter(
|
|
5161
|
+
(s) => s.branch.toLowerCase().includes(q) || s.target.toLowerCase().includes(q)
|
|
5162
|
+
);
|
|
5163
|
+
}, [sessions, filter]);
|
|
4834
5164
|
const ptySessions = useRef(/* @__PURE__ */ new Map());
|
|
4835
5165
|
const sessionRows = useMemo(() => {
|
|
4836
5166
|
const sMap = /* @__PURE__ */ new Map();
|
|
4837
5167
|
for (const [key, pty2] of ptySessions.current) {
|
|
4838
5168
|
if (pty2.exited) continue;
|
|
4839
|
-
sMap.set(key, pty2.
|
|
5169
|
+
sMap.set(key, pty2.status);
|
|
4840
5170
|
}
|
|
4841
|
-
return buildSessionRows(
|
|
4842
|
-
}, [
|
|
5171
|
+
return buildSessionRows(filteredSessions, sMap);
|
|
5172
|
+
}, [filteredSessions, statusVersion]);
|
|
4843
5173
|
const topRows = topPaneMode === 0 /* SESSIONS */ ? sessionRows : projectRows;
|
|
4844
5174
|
const renderPending = useRef(false);
|
|
4845
5175
|
const focusRef = useRef(focus);
|
|
@@ -4879,6 +5209,13 @@ function App({ unsafe, onExit }) {
|
|
|
4879
5209
|
prRowsRef.current = prRows;
|
|
4880
5210
|
const acliAvailableRef = useRef(acliAvailable);
|
|
4881
5211
|
acliAvailableRef.current = acliAvailable;
|
|
5212
|
+
const showHelpRef = useRef(showHelp2);
|
|
5213
|
+
showHelpRef.current = showHelp2;
|
|
5214
|
+
const filterRef = useRef(filter);
|
|
5215
|
+
filterRef.current = filter;
|
|
5216
|
+
const pendingRemoveRef = useRef(pendingRemoveKey);
|
|
5217
|
+
pendingRemoveRef.current = pendingRemoveKey;
|
|
5218
|
+
const rebasingRef = useRef(false);
|
|
4882
5219
|
const hookServerRef = useRef(null);
|
|
4883
5220
|
const notifiedSessionsRef = useRef(/* @__PURE__ */ new Set());
|
|
4884
5221
|
const [dims, setDims] = useState(() => ({
|
|
@@ -4895,16 +5232,21 @@ function App({ unsafe, onExit }) {
|
|
|
4895
5232
|
const taskPaneHeight = Math.max(5, Math.floor(contentHeight * 0.2));
|
|
4896
5233
|
const prPaneHeight = Math.max(5, Math.floor((contentHeight - jiraPaneHeight - taskPaneHeight) * 0.45));
|
|
4897
5234
|
const sessionPaneHeight = contentHeight - prPaneHeight - taskPaneHeight - jiraPaneHeight;
|
|
5235
|
+
const layoutRef = useRef({ sidebarWidth, termInner, contentHeight, sessionPaneHeight, prPaneHeight, jiraPaneHeight, taskPaneHeight });
|
|
5236
|
+
layoutRef.current = { sidebarWidth, termInner, contentHeight, sessionPaneHeight, prPaneHeight, jiraPaneHeight, taskPaneHeight };
|
|
4898
5237
|
useEffect(() => {
|
|
5238
|
+
let attentionCount = 0;
|
|
4899
5239
|
let idleCount = 0;
|
|
4900
5240
|
let runningCount = 0;
|
|
4901
5241
|
for (const pty2 of ptySessions.current.values()) {
|
|
4902
5242
|
if (pty2.exited) continue;
|
|
4903
|
-
if (pty2.
|
|
5243
|
+
if (pty2.status === "attention") attentionCount++;
|
|
5244
|
+
else if (pty2.status === "idle") idleCount++;
|
|
4904
5245
|
else runningCount++;
|
|
4905
5246
|
}
|
|
4906
5247
|
const parts = [];
|
|
4907
|
-
if (
|
|
5248
|
+
if (attentionCount > 0) parts.push(`\u{1F7E1} ${attentionCount}`);
|
|
5249
|
+
if (idleCount > 0) parts.push(`\u{1F535} ${idleCount}`);
|
|
4908
5250
|
if (runningCount > 0) parts.push(`\u{1F7E2} ${runningCount}`);
|
|
4909
5251
|
const title = parts.length > 0 ? parts.join(" ") : "work dash";
|
|
4910
5252
|
process.stdout.write(`\x1B]0;${title}\x07`);
|
|
@@ -4912,23 +5254,21 @@ function App({ unsafe, onExit }) {
|
|
|
4912
5254
|
const computeGeneration = useRef(0);
|
|
4913
5255
|
const computeConflictsAndMerged = useCallback((sessionList) => {
|
|
4914
5256
|
const generation = ++computeGeneration.current;
|
|
4915
|
-
const tick = () => new Promise((r) => setTimeout(r, 0));
|
|
4916
5257
|
(async () => {
|
|
4917
5258
|
const counts = /* @__PURE__ */ new Map();
|
|
4918
5259
|
const merged = /* @__PURE__ */ new Set();
|
|
4919
5260
|
for (const s of sessionList) {
|
|
4920
5261
|
if (computeGeneration.current !== generation) return;
|
|
4921
|
-
await tick();
|
|
4922
5262
|
const existing = s.paths.find((p) => fs23.existsSync(p));
|
|
4923
5263
|
if (!existing || !s.branch) continue;
|
|
4924
5264
|
const key = sessionKey2(s);
|
|
4925
5265
|
try {
|
|
4926
|
-
const c =
|
|
5266
|
+
const c = await countConflictsAsync(s.branch, existing);
|
|
4927
5267
|
if (c > 0) counts.set(key, c);
|
|
4928
5268
|
} catch {
|
|
4929
5269
|
}
|
|
4930
5270
|
try {
|
|
4931
|
-
const { merged: isMerged } =
|
|
5271
|
+
const { merged: isMerged } = await isBranchMergedAsync(s.branch, existing);
|
|
4932
5272
|
if (isMerged) merged.add(key);
|
|
4933
5273
|
} catch {
|
|
4934
5274
|
}
|
|
@@ -4940,10 +5280,10 @@ function App({ unsafe, onExit }) {
|
|
|
4940
5280
|
})();
|
|
4941
5281
|
}, []);
|
|
4942
5282
|
const refreshPrs = useCallback(() => {
|
|
4943
|
-
if (!ghAvailable || !config || prFetching.current) return;
|
|
5283
|
+
if (!ghAvailable || !config || prFetching.current) return Promise.resolve();
|
|
4944
5284
|
prFetching.current = true;
|
|
4945
5285
|
setMessage("Loading PRs...");
|
|
4946
|
-
fetchAllPullRequests(config.repos).then((prs) => {
|
|
5286
|
+
return fetchAllPullRequests(config.repos).then((prs) => {
|
|
4947
5287
|
setPrMap(prs);
|
|
4948
5288
|
setMessage("");
|
|
4949
5289
|
}).catch(() => {
|
|
@@ -4952,9 +5292,9 @@ function App({ unsafe, onExit }) {
|
|
|
4952
5292
|
});
|
|
4953
5293
|
}, [ghAvailable, config]);
|
|
4954
5294
|
const refreshJira = useCallback(() => {
|
|
4955
|
-
if (!acliAvailable || jiraFetching.current) return;
|
|
5295
|
+
if (!acliAvailable || jiraFetching.current) return Promise.resolve();
|
|
4956
5296
|
jiraFetching.current = true;
|
|
4957
|
-
fetchMyJiraIssues().then((issues) => setJiraIssues(issues)).catch(() => {
|
|
5297
|
+
return fetchMyJiraIssues().then((issues) => setJiraIssues(issues)).catch(() => {
|
|
4958
5298
|
}).finally(() => {
|
|
4959
5299
|
jiraFetching.current = false;
|
|
4960
5300
|
});
|
|
@@ -4967,11 +5307,11 @@ function App({ unsafe, onExit }) {
|
|
|
4967
5307
|
setSessions(updated);
|
|
4968
5308
|
computeConflictsAndMerged(updated);
|
|
4969
5309
|
}, [computeConflictsAndMerged]);
|
|
4970
|
-
const
|
|
5310
|
+
const statusMap = useMemo(() => {
|
|
4971
5311
|
const map = /* @__PURE__ */ new Map();
|
|
4972
5312
|
for (const [key, pty2] of ptySessions.current) {
|
|
4973
5313
|
if (pty2.exited) continue;
|
|
4974
|
-
map.set(key, pty2.
|
|
5314
|
+
map.set(key, pty2.status);
|
|
4975
5315
|
}
|
|
4976
5316
|
return map;
|
|
4977
5317
|
}, [statusVersion]);
|
|
@@ -4981,6 +5321,8 @@ function App({ unsafe, onExit }) {
|
|
|
4981
5321
|
setTimeout(() => {
|
|
4982
5322
|
renderPending.current = false;
|
|
4983
5323
|
try {
|
|
5324
|
+
const activeKey2 = activeKeyRef.current;
|
|
5325
|
+
if (!activeKey2 || ptySessions.current.get(activeKey2) !== pty2) return;
|
|
4984
5326
|
if (termScrollBack.current > 0) return;
|
|
4985
5327
|
const lines = renderBufferLines(pty2.terminal.buffer.active, termInner, contentHeight - 2);
|
|
4986
5328
|
setTermLines(lines);
|
|
@@ -4997,6 +5339,16 @@ function App({ unsafe, onExit }) {
|
|
|
4997
5339
|
} catch {
|
|
4998
5340
|
}
|
|
4999
5341
|
}, [termInner, contentHeight]);
|
|
5342
|
+
const scrollTerminal = useCallback((linesUp) => {
|
|
5343
|
+
const pty2 = activeKeyRef.current ? ptySessions.current.get(activeKeyRef.current) : void 0;
|
|
5344
|
+
if (!pty2 || pty2.exited) return;
|
|
5345
|
+
const maxScroll = pty2.terminal.buffer.active.baseY;
|
|
5346
|
+
const next = Math.max(0, Math.min(maxScroll, termScrollBack.current + linesUp));
|
|
5347
|
+
if (next !== termScrollBack.current) {
|
|
5348
|
+
setScrollBack(next);
|
|
5349
|
+
renderTermAtScroll();
|
|
5350
|
+
}
|
|
5351
|
+
}, [setScrollBack, renderTermAtScroll]);
|
|
5000
5352
|
const findPtyByCwd = useCallback((cwd) => {
|
|
5001
5353
|
const normalized = path20.resolve(cwd).toLowerCase();
|
|
5002
5354
|
for (const pty2 of ptySessions.current.values()) {
|
|
@@ -5063,10 +5415,12 @@ function App({ unsafe, onExit }) {
|
|
|
5063
5415
|
callback: (cwd, event) => {
|
|
5064
5416
|
const pty2 = findPtyByCwd(cwd);
|
|
5065
5417
|
if (!pty2) return;
|
|
5066
|
-
if (event === "
|
|
5067
|
-
pty2.
|
|
5418
|
+
if (event === "notification") {
|
|
5419
|
+
pty2.setStatus("attention");
|
|
5420
|
+
} else if (event === "stop") {
|
|
5421
|
+
pty2.setStatus("idle");
|
|
5068
5422
|
} else if (event === "prompt_submit") {
|
|
5069
|
-
pty2.
|
|
5423
|
+
pty2.setStatus("running");
|
|
5070
5424
|
}
|
|
5071
5425
|
const dedupKey = ptyDedupKey(pty2);
|
|
5072
5426
|
const kind = notifyKindForEvent(
|
|
@@ -5127,7 +5481,7 @@ function App({ unsafe, onExit }) {
|
|
|
5127
5481
|
const switchDisplay = useCallback((s) => {
|
|
5128
5482
|
const k = sessionKey2(s);
|
|
5129
5483
|
if (activeKeyRef.current === k) return;
|
|
5130
|
-
|
|
5484
|
+
setScrollBack(0);
|
|
5131
5485
|
if (activeKeyRef.current) {
|
|
5132
5486
|
ptySessions.current.get(activeKeyRef.current)?.setOutputHandler(void 0);
|
|
5133
5487
|
}
|
|
@@ -5178,6 +5532,7 @@ function App({ unsafe, onExit }) {
|
|
|
5178
5532
|
if (activeKeyRef.current && activeKeyRef.current !== key) {
|
|
5179
5533
|
ptySessions.current.get(activeKeyRef.current)?.setOutputHandler(void 0);
|
|
5180
5534
|
}
|
|
5535
|
+
setScrollBack(0);
|
|
5181
5536
|
setActiveKey(key);
|
|
5182
5537
|
setFocus(4 /* TERMINAL */);
|
|
5183
5538
|
pty2.resize(termInner, contentHeight - 2);
|
|
@@ -5368,8 +5723,8 @@ function App({ unsafe, onExit }) {
|
|
|
5368
5723
|
connectPty(key, setupPty);
|
|
5369
5724
|
}, [unsafe, termInner, contentHeight, refreshSessions, connectPty, registerPty, savedSessionCursor, config]);
|
|
5370
5725
|
useEffect(() => {
|
|
5371
|
-
const
|
|
5372
|
-
const
|
|
5726
|
+
const handleKey = (key) => {
|
|
5727
|
+
const layout = layoutRef.current;
|
|
5373
5728
|
const mouseMatch = MOUSE_SGR_RE.exec(key);
|
|
5374
5729
|
if (mouseMatch) {
|
|
5375
5730
|
const button = parseInt(mouseMatch[1], 10);
|
|
@@ -5377,48 +5732,52 @@ function App({ unsafe, onExit }) {
|
|
|
5377
5732
|
const row = parseInt(mouseMatch[3], 10);
|
|
5378
5733
|
if (button === 64 || button === 65) {
|
|
5379
5734
|
const delta = button === 64 ? -1 : 1;
|
|
5380
|
-
if (col <= sidebarWidth) {
|
|
5381
|
-
if (row <= sessionPaneHeight) {
|
|
5735
|
+
if (col <= layout.sidebarWidth) {
|
|
5736
|
+
if (row <= layout.sessionPaneHeight) {
|
|
5382
5737
|
moveSessionCursor(delta);
|
|
5383
|
-
} else if (row <= sessionPaneHeight + prPaneHeight) {
|
|
5738
|
+
} else if (row <= layout.sessionPaneHeight + layout.prPaneHeight) {
|
|
5384
5739
|
movePrCursor(delta);
|
|
5385
|
-
} else if (jiraPaneHeight > 0 && row <= sessionPaneHeight + prPaneHeight + jiraPaneHeight) {
|
|
5740
|
+
} else if (layout.jiraPaneHeight > 0 && row <= layout.sessionPaneHeight + layout.prPaneHeight + layout.jiraPaneHeight) {
|
|
5386
5741
|
moveJiraCursor(delta);
|
|
5387
5742
|
} else {
|
|
5388
5743
|
moveTaskCursor(delta);
|
|
5389
5744
|
}
|
|
5390
5745
|
} else {
|
|
5391
|
-
|
|
5392
|
-
if (pty2 && !pty2.exited) {
|
|
5393
|
-
const maxScroll = pty2.terminal.buffer.active.baseY;
|
|
5394
|
-
const newScroll = Math.max(0, Math.min(maxScroll, termScrollBack.current - delta * 3));
|
|
5395
|
-
if (newScroll !== termScrollBack.current) {
|
|
5396
|
-
termScrollBack.current = newScroll;
|
|
5397
|
-
renderTermAtScroll();
|
|
5398
|
-
}
|
|
5399
|
-
}
|
|
5746
|
+
scrollTerminal(-delta * 3);
|
|
5400
5747
|
}
|
|
5401
5748
|
return;
|
|
5402
5749
|
}
|
|
5403
5750
|
if (button === 0) {
|
|
5404
|
-
if (col <= sidebarWidth) {
|
|
5405
|
-
if (row <= sessionPaneHeight) {
|
|
5751
|
+
if (col <= layout.sidebarWidth) {
|
|
5752
|
+
if (row <= layout.sessionPaneHeight) {
|
|
5406
5753
|
setFocus(0 /* SESSIONS */);
|
|
5407
5754
|
const visualIdx = row - 2;
|
|
5408
|
-
if (visualIdx >= 0)
|
|
5409
|
-
|
|
5755
|
+
if (visualIdx >= 0) {
|
|
5756
|
+
const offset = computeScrollOffset(topRowsRef.current, sessionCursorRef.current, layout.sessionPaneHeight - 2);
|
|
5757
|
+
setSessionCursor(visualRowToCursor(topRowsRef.current, visualIdx + offset));
|
|
5758
|
+
}
|
|
5759
|
+
} else if (row <= layout.sessionPaneHeight + layout.prPaneHeight) {
|
|
5410
5760
|
setFocus(2 /* PRS */);
|
|
5411
|
-
const visualIdx = row - sessionPaneHeight - 2;
|
|
5412
|
-
if (visualIdx >= 0)
|
|
5413
|
-
|
|
5761
|
+
const visualIdx = row - layout.sessionPaneHeight - 2;
|
|
5762
|
+
if (visualIdx >= 0) {
|
|
5763
|
+
const offset = computeScrollOffset(prRowsRef.current, prCursorRef.current, layout.prPaneHeight - 2);
|
|
5764
|
+
setPrCursor(visualRowToCursor(prRowsRef.current, visualIdx + offset));
|
|
5765
|
+
}
|
|
5766
|
+
} else if (layout.jiraPaneHeight > 0 && row <= layout.sessionPaneHeight + layout.prPaneHeight + layout.jiraPaneHeight) {
|
|
5414
5767
|
setFocus(3 /* JIRA */);
|
|
5415
|
-
const visualIdx = row - sessionPaneHeight - prPaneHeight - 2;
|
|
5416
|
-
if (visualIdx >= 0)
|
|
5768
|
+
const visualIdx = row - layout.sessionPaneHeight - layout.prPaneHeight - 2;
|
|
5769
|
+
if (visualIdx >= 0) {
|
|
5770
|
+
const offset = computeScrollOffset(jiraRowsRef.current, jiraCursorRef.current, layout.jiraPaneHeight - 2);
|
|
5771
|
+
setJiraCursor(visualRowToCursor(jiraRowsRef.current, visualIdx + offset));
|
|
5772
|
+
}
|
|
5417
5773
|
} else {
|
|
5418
5774
|
setFocus(1 /* TASKS */);
|
|
5419
|
-
const taskStart = sessionPaneHeight + prPaneHeight + jiraPaneHeight;
|
|
5775
|
+
const taskStart = layout.sessionPaneHeight + layout.prPaneHeight + layout.jiraPaneHeight;
|
|
5420
5776
|
const visualIdx = row - taskStart - 2;
|
|
5421
|
-
if (visualIdx >= 0)
|
|
5777
|
+
if (visualIdx >= 0) {
|
|
5778
|
+
const offset = computeScrollOffset(taskRowsRef.current, taskCursorRef.current, layout.taskPaneHeight - 2);
|
|
5779
|
+
setTaskCursor(visualRowToCursor(taskRowsRef.current, visualIdx + offset));
|
|
5780
|
+
}
|
|
5422
5781
|
}
|
|
5423
5782
|
} else {
|
|
5424
5783
|
const activePty = activeKeyRef.current ? ptySessions.current.get(activeKeyRef.current) : void 0;
|
|
@@ -5429,18 +5788,25 @@ function App({ unsafe, onExit }) {
|
|
|
5429
5788
|
}
|
|
5430
5789
|
return;
|
|
5431
5790
|
}
|
|
5791
|
+
if (showHelpRef.current) {
|
|
5792
|
+
if (key === "?" || key === KEYS.ESC || key === "q" || key === KEYS.CTRL_C) {
|
|
5793
|
+
setShowHelp(false);
|
|
5794
|
+
}
|
|
5795
|
+
return;
|
|
5796
|
+
}
|
|
5432
5797
|
if (branchInputRef.current) {
|
|
5433
|
-
|
|
5798
|
+
const { projectName, isGroup, value, pos } = branchInputRef.current;
|
|
5799
|
+
const { state, action } = editLine({ value, pos }, key);
|
|
5800
|
+
if (action === "cancel") {
|
|
5434
5801
|
setBranchInput(null);
|
|
5435
5802
|
setTopPaneMode(1 /* PROJECTS */);
|
|
5436
5803
|
setMessage("Esc to go back");
|
|
5437
5804
|
return;
|
|
5438
5805
|
}
|
|
5439
|
-
if (
|
|
5440
|
-
const { projectName, value, isGroup } = branchInputRef.current;
|
|
5806
|
+
if (action === "submit") {
|
|
5441
5807
|
setBranchInput(null);
|
|
5442
|
-
if (value.trim()) {
|
|
5443
|
-
handleCreateWorktree(projectName, value.trim());
|
|
5808
|
+
if (state.value.trim()) {
|
|
5809
|
+
handleCreateWorktree(projectName, state.value.trim());
|
|
5444
5810
|
} else if (!isGroup) {
|
|
5445
5811
|
handleLaunchBaseRepo(projectName);
|
|
5446
5812
|
} else {
|
|
@@ -5448,12 +5814,36 @@ function App({ unsafe, onExit }) {
|
|
|
5448
5814
|
}
|
|
5449
5815
|
return;
|
|
5450
5816
|
}
|
|
5451
|
-
|
|
5452
|
-
|
|
5817
|
+
setBranchInput({ projectName, isGroup, ...state });
|
|
5818
|
+
return;
|
|
5819
|
+
}
|
|
5820
|
+
if (filterRef.current?.editing) {
|
|
5821
|
+
if (key === KEYS.UP) {
|
|
5822
|
+
moveSessionCursor(-1);
|
|
5823
|
+
return;
|
|
5824
|
+
}
|
|
5825
|
+
if (key === KEYS.DOWN) {
|
|
5826
|
+
moveSessionCursor(1);
|
|
5453
5827
|
return;
|
|
5454
5828
|
}
|
|
5455
|
-
|
|
5456
|
-
|
|
5829
|
+
const current = filterRef.current.value;
|
|
5830
|
+
const { state, action } = editLine({ value: current, pos: current.length }, key);
|
|
5831
|
+
if (action === "cancel") {
|
|
5832
|
+
setFilter(null);
|
|
5833
|
+
setSessionCursor(0);
|
|
5834
|
+
setMessage("");
|
|
5835
|
+
return;
|
|
5836
|
+
}
|
|
5837
|
+
if (action === "submit" || key === TAB_KEY) {
|
|
5838
|
+
const value = current.trim();
|
|
5839
|
+
setFilter(value ? { value, editing: false } : null);
|
|
5840
|
+
setMessage(value ? `Filtering: ${value} (esc clears)` : "");
|
|
5841
|
+
return;
|
|
5842
|
+
}
|
|
5843
|
+
if (state.value !== current) {
|
|
5844
|
+
setFilter({ value: state.value, editing: true });
|
|
5845
|
+
setSessionCursor(0);
|
|
5846
|
+
}
|
|
5457
5847
|
return;
|
|
5458
5848
|
}
|
|
5459
5849
|
if (key === TAB_KEY) {
|
|
@@ -5486,11 +5876,24 @@ function App({ unsafe, onExit }) {
|
|
|
5486
5876
|
setMessage("");
|
|
5487
5877
|
return;
|
|
5488
5878
|
}
|
|
5489
|
-
|
|
5879
|
+
if (key === KEYS.PAGE_UP) {
|
|
5880
|
+
scrollTerminal(Math.max(1, layout.contentHeight - 3));
|
|
5881
|
+
return;
|
|
5882
|
+
}
|
|
5883
|
+
if (key === KEYS.PAGE_DOWN) {
|
|
5884
|
+
scrollTerminal(-Math.max(1, layout.contentHeight - 3));
|
|
5885
|
+
return;
|
|
5886
|
+
}
|
|
5887
|
+
if (termScrollBack.current > 0) setScrollBack(0);
|
|
5490
5888
|
ptySessions.current.get(activeKeyRef.current)?.write(key);
|
|
5491
5889
|
return;
|
|
5492
5890
|
}
|
|
5493
5891
|
setMessage("");
|
|
5892
|
+
if (pendingRemoveRef.current && key !== "d") setPendingRemoveKey(null);
|
|
5893
|
+
if (key === "?") {
|
|
5894
|
+
setShowHelp(true);
|
|
5895
|
+
return;
|
|
5896
|
+
}
|
|
5494
5897
|
if (key === "G") {
|
|
5495
5898
|
if (syncing) return;
|
|
5496
5899
|
setSyncing(true);
|
|
@@ -5505,8 +5908,7 @@ function App({ unsafe, onExit }) {
|
|
|
5505
5908
|
);
|
|
5506
5909
|
}
|
|
5507
5910
|
refreshSessions();
|
|
5508
|
-
refreshPrs();
|
|
5509
|
-
refreshJira();
|
|
5911
|
+
await Promise.all([refreshPrs(), refreshJira()]);
|
|
5510
5912
|
refreshTasks();
|
|
5511
5913
|
computeConflictsAndMerged(sessionsRef.current);
|
|
5512
5914
|
setSyncing(false);
|
|
@@ -5514,6 +5916,33 @@ function App({ unsafe, onExit }) {
|
|
|
5514
5916
|
})();
|
|
5515
5917
|
return;
|
|
5516
5918
|
}
|
|
5919
|
+
if (taskInputRef.current === null) {
|
|
5920
|
+
const pageJump = (dir, full) => {
|
|
5921
|
+
const heightFor = focusRef.current === 2 /* PRS */ ? layout.prPaneHeight : focusRef.current === 3 /* JIRA */ ? layout.jiraPaneHeight : focusRef.current === 1 /* TASKS */ ? layout.taskPaneHeight : layout.sessionPaneHeight;
|
|
5922
|
+
const page = Math.max(1, full ? heightFor - 2 : Math.floor((heightFor - 2) / 2));
|
|
5923
|
+
const delta = page * dir;
|
|
5924
|
+
if (focusRef.current === 2 /* PRS */) movePrCursor(delta);
|
|
5925
|
+
else if (focusRef.current === 3 /* JIRA */) moveJiraCursor(delta);
|
|
5926
|
+
else if (focusRef.current === 1 /* TASKS */) moveTaskCursor(delta);
|
|
5927
|
+
else moveSessionCursor(delta);
|
|
5928
|
+
};
|
|
5929
|
+
if (key === KEYS.PAGE_UP) {
|
|
5930
|
+
pageJump(-1, true);
|
|
5931
|
+
return;
|
|
5932
|
+
}
|
|
5933
|
+
if (key === KEYS.PAGE_DOWN) {
|
|
5934
|
+
pageJump(1, true);
|
|
5935
|
+
return;
|
|
5936
|
+
}
|
|
5937
|
+
if (key === KEYS.CTRL_U) {
|
|
5938
|
+
pageJump(-1, false);
|
|
5939
|
+
return;
|
|
5940
|
+
}
|
|
5941
|
+
if (key === KEYS.CTRL_D) {
|
|
5942
|
+
pageJump(1, false);
|
|
5943
|
+
return;
|
|
5944
|
+
}
|
|
5945
|
+
}
|
|
5517
5946
|
if (topPaneModeRef.current === 1 /* PROJECTS */) {
|
|
5518
5947
|
if (key === "\x1B" || key === "" || key === "q") {
|
|
5519
5948
|
setTopPaneMode(0 /* SESSIONS */);
|
|
@@ -5558,7 +5987,7 @@ function App({ unsafe, onExit }) {
|
|
|
5558
5987
|
handleCreateWorktree(row.name, branch);
|
|
5559
5988
|
} else {
|
|
5560
5989
|
setTopPaneMode(2 /* BRANCH_INPUT */);
|
|
5561
|
-
setBranchInput({ projectName: row.name, value: "", isGroup: row.isGroup });
|
|
5990
|
+
setBranchInput({ projectName: row.name, value: "", pos: 0, isGroup: row.isGroup });
|
|
5562
5991
|
setMessage(row.isGroup ? "Type branch name, Enter to create, Esc to cancel" : "Type branch name (empty for base repo), Enter to create, Esc to cancel");
|
|
5563
5992
|
}
|
|
5564
5993
|
}
|
|
@@ -5568,14 +5997,15 @@ function App({ unsafe, onExit }) {
|
|
|
5568
5997
|
}
|
|
5569
5998
|
if (focusRef.current === 1 /* TASKS */) {
|
|
5570
5999
|
if (taskInputRef.current !== null) {
|
|
5571
|
-
|
|
6000
|
+
const { state, action } = editLine(taskInputRef.current, key);
|
|
6001
|
+
if (action === "cancel") {
|
|
5572
6002
|
setTaskInput(null);
|
|
5573
6003
|
setTaskEditId(null);
|
|
5574
6004
|
setMessage("");
|
|
5575
6005
|
return;
|
|
5576
6006
|
}
|
|
5577
|
-
if (
|
|
5578
|
-
const text = taskInputRef.current.trim();
|
|
6007
|
+
if (action === "submit") {
|
|
6008
|
+
const text = taskInputRef.current.value.trim();
|
|
5579
6009
|
const editId = taskEditIdRef.current;
|
|
5580
6010
|
setTaskInput(null);
|
|
5581
6011
|
setTaskEditId(null);
|
|
@@ -5590,12 +6020,7 @@ function App({ unsafe, onExit }) {
|
|
|
5590
6020
|
}
|
|
5591
6021
|
return;
|
|
5592
6022
|
}
|
|
5593
|
-
|
|
5594
|
-
setTaskInput((prev) => prev !== null ? prev.slice(0, -1) : null);
|
|
5595
|
-
return;
|
|
5596
|
-
}
|
|
5597
|
-
if (key.charCodeAt(0) < 32) return;
|
|
5598
|
-
setTaskInput((prev) => prev !== null ? prev + key : null);
|
|
6023
|
+
setTaskInput(state);
|
|
5599
6024
|
return;
|
|
5600
6025
|
}
|
|
5601
6026
|
if (key === "\x1B[A" || key === "k") {
|
|
@@ -5615,7 +6040,7 @@ function App({ unsafe, onExit }) {
|
|
|
5615
6040
|
return;
|
|
5616
6041
|
}
|
|
5617
6042
|
if (key === "a") {
|
|
5618
|
-
setTaskInput("");
|
|
6043
|
+
setTaskInput({ value: "", pos: 0 });
|
|
5619
6044
|
setMessage("Type task, Enter to add, Esc to cancel");
|
|
5620
6045
|
return;
|
|
5621
6046
|
}
|
|
@@ -5623,7 +6048,7 @@ function App({ unsafe, onExit }) {
|
|
|
5623
6048
|
const row = cursorToRow(taskRowsRef.current, taskCursorRef.current);
|
|
5624
6049
|
if (row?.type === "task") {
|
|
5625
6050
|
setTaskEditId(row.task.id);
|
|
5626
|
-
setTaskInput(row.task.text);
|
|
6051
|
+
setTaskInput({ value: row.task.text, pos: row.task.text.length });
|
|
5627
6052
|
setMessage("Edit task, Enter to save, Esc to cancel");
|
|
5628
6053
|
}
|
|
5629
6054
|
return;
|
|
@@ -5779,6 +6204,16 @@ function App({ unsafe, onExit }) {
|
|
|
5779
6204
|
onExit();
|
|
5780
6205
|
return;
|
|
5781
6206
|
}
|
|
6207
|
+
if (key === KEYS.ESC && filterRef.current) {
|
|
6208
|
+
setFilter(null);
|
|
6209
|
+
setSessionCursor(0);
|
|
6210
|
+
return;
|
|
6211
|
+
}
|
|
6212
|
+
if (key === "/" && topPaneModeRef.current === 0 /* SESSIONS */) {
|
|
6213
|
+
setFilter({ value: filterRef.current?.value ?? "", editing: true });
|
|
6214
|
+
setMessage("Type to filter, Enter to keep, Esc to clear");
|
|
6215
|
+
return;
|
|
6216
|
+
}
|
|
5782
6217
|
if (key === "\x1B[A" || key === "k") {
|
|
5783
6218
|
moveSessionCursor(-1);
|
|
5784
6219
|
return;
|
|
@@ -5799,6 +6234,12 @@ function App({ unsafe, onExit }) {
|
|
|
5799
6234
|
if (row?.type !== "session") return;
|
|
5800
6235
|
const s = row.session;
|
|
5801
6236
|
const k = sessionKey2(s);
|
|
6237
|
+
if (pendingRemoveRef.current !== k) {
|
|
6238
|
+
setPendingRemoveKey(k);
|
|
6239
|
+
setMessage(`Remove ${s.target}/${s.branch}? Press d again to confirm, any other key cancels`);
|
|
6240
|
+
return;
|
|
6241
|
+
}
|
|
6242
|
+
setPendingRemoveKey(null);
|
|
5802
6243
|
const pty2 = ptySessions.current.get(k);
|
|
5803
6244
|
if (pty2) {
|
|
5804
6245
|
notifiedSessionsRef.current.delete(ptyDedupKey(pty2));
|
|
@@ -5855,14 +6296,22 @@ function App({ unsafe, onExit }) {
|
|
|
5855
6296
|
setMessage("Session path no longer exists");
|
|
5856
6297
|
return;
|
|
5857
6298
|
}
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
setMessage(`Rebase failed: ${err}`);
|
|
5862
|
-
} else {
|
|
5863
|
-
setMessage(`Rebased ${s.branch} onto main`);
|
|
5864
|
-
computeConflictsAndMerged(sessionsRef.current);
|
|
6299
|
+
if (rebasingRef.current) {
|
|
6300
|
+
setMessage("A rebase is already running");
|
|
6301
|
+
return;
|
|
5865
6302
|
}
|
|
6303
|
+
rebasingRef.current = true;
|
|
6304
|
+
setMessage(`Rebasing ${s.branch}...`);
|
|
6305
|
+
void rebaseOntoMainAsync(s.branch, existing).then((err) => {
|
|
6306
|
+
if (err) {
|
|
6307
|
+
setMessage(`Rebase failed: ${err}`);
|
|
6308
|
+
} else {
|
|
6309
|
+
setMessage(`Rebased ${s.branch} onto main`);
|
|
6310
|
+
computeConflictsAndMerged(sessionsRef.current);
|
|
6311
|
+
}
|
|
6312
|
+
}).catch((e) => setMessage(`Rebase failed: ${e.message}`)).finally(() => {
|
|
6313
|
+
rebasingRef.current = false;
|
|
6314
|
+
});
|
|
5866
6315
|
return;
|
|
5867
6316
|
}
|
|
5868
6317
|
if (key === "g") {
|
|
@@ -5879,7 +6328,7 @@ function App({ unsafe, onExit }) {
|
|
|
5879
6328
|
);
|
|
5880
6329
|
}
|
|
5881
6330
|
refreshSessions();
|
|
5882
|
-
refreshPrs();
|
|
6331
|
+
await refreshPrs();
|
|
5883
6332
|
computeConflictsAndMerged(sessionsRef.current);
|
|
5884
6333
|
setSyncing(false);
|
|
5885
6334
|
setMessage("Sessions synced");
|
|
@@ -5888,18 +6337,23 @@ function App({ unsafe, onExit }) {
|
|
|
5888
6337
|
}
|
|
5889
6338
|
if (key === "r") {
|
|
5890
6339
|
refreshSessions();
|
|
5891
|
-
refreshPrs();
|
|
5892
|
-
refreshJira();
|
|
6340
|
+
void refreshPrs();
|
|
6341
|
+
void refreshJira();
|
|
5893
6342
|
refreshTasks();
|
|
5894
6343
|
if (!ghAvailable) setMessage("Refreshed");
|
|
5895
6344
|
return;
|
|
5896
6345
|
}
|
|
5897
6346
|
};
|
|
6347
|
+
const handler = (data) => {
|
|
6348
|
+
for (const key of splitInputChunks(data.toString("utf8"))) {
|
|
6349
|
+
handleKey(key);
|
|
6350
|
+
}
|
|
6351
|
+
};
|
|
5898
6352
|
process.stdin.on("data", handler);
|
|
5899
6353
|
return () => {
|
|
5900
6354
|
process.stdin.removeListener("data", handler);
|
|
5901
6355
|
};
|
|
5902
|
-
}, [onExit, activateSession, refreshSessions, refreshPrs, refreshJira, refreshTasks, moveSessionCursor, movePrCursor, moveJiraCursor, moveTaskCursor, syncSessionCursorToActive, handleCreateWorktree, savedSessionCursor, config, computeConflictsAndMerged, syncing, ghAvailable, prMap]);
|
|
6356
|
+
}, [onExit, activateSession, refreshSessions, refreshPrs, refreshJira, refreshTasks, moveSessionCursor, movePrCursor, moveJiraCursor, moveTaskCursor, syncSessionCursorToActive, handleCreateWorktree, handleLaunchBaseRepo, savedSessionCursor, config, computeConflictsAndMerged, syncing, ghAvailable, prMap, scrollTerminal, setScrollBack]);
|
|
5903
6357
|
useEffect(() => {
|
|
5904
6358
|
const handler = () => {
|
|
5905
6359
|
const newCols = process.stdout.columns || 80;
|
|
@@ -5911,6 +6365,10 @@ function App({ unsafe, onExit }) {
|
|
|
5911
6365
|
const newTermInner = newCols - Math.min(60, Math.floor(newCols * 0.525)) - 2;
|
|
5912
6366
|
const newContentHeight = newRows - 3;
|
|
5913
6367
|
pty2.resize(newTermInner, newContentHeight);
|
|
6368
|
+
try {
|
|
6369
|
+
setTermLines(renderBufferLines(pty2.terminal.buffer.active, newTermInner, newContentHeight, termScrollBack.current));
|
|
6370
|
+
} catch {
|
|
6371
|
+
}
|
|
5914
6372
|
}
|
|
5915
6373
|
}
|
|
5916
6374
|
};
|
|
@@ -5930,12 +6388,11 @@ function App({ unsafe, onExit }) {
|
|
|
5930
6388
|
}, 5 * 60 * 1e3);
|
|
5931
6389
|
return () => clearInterval(interval);
|
|
5932
6390
|
}, []);
|
|
5933
|
-
const statusMap = buildStatusMap();
|
|
5934
6391
|
const placeholder = !activeKey ? "Select a session and press Enter" : "Press Enter to start session";
|
|
5935
|
-
return /* @__PURE__ */
|
|
5936
|
-
/* @__PURE__ */
|
|
5937
|
-
/* @__PURE__ */
|
|
5938
|
-
/* @__PURE__ */
|
|
6392
|
+
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", width: cols, height: rows, children: [
|
|
6393
|
+
showHelp2 ? /* @__PURE__ */ jsx5(HelpOverlay, { width: cols, height: contentHeight }) : /* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", height: contentHeight, children: [
|
|
6394
|
+
/* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", width: sidebarWidth, children: [
|
|
6395
|
+
/* @__PURE__ */ jsx5(
|
|
5939
6396
|
Sidebar,
|
|
5940
6397
|
{
|
|
5941
6398
|
sidebarRows: topRows,
|
|
@@ -5948,10 +6405,11 @@ function App({ unsafe, onExit }) {
|
|
|
5948
6405
|
activeKey,
|
|
5949
6406
|
width: sidebarWidth,
|
|
5950
6407
|
height: sessionPaneHeight,
|
|
5951
|
-
branchInput
|
|
6408
|
+
branchInput,
|
|
6409
|
+
filter
|
|
5952
6410
|
}
|
|
5953
6411
|
),
|
|
5954
|
-
/* @__PURE__ */
|
|
6412
|
+
/* @__PURE__ */ jsx5(
|
|
5955
6413
|
PrPane,
|
|
5956
6414
|
{
|
|
5957
6415
|
prRows,
|
|
@@ -5962,7 +6420,7 @@ function App({ unsafe, onExit }) {
|
|
|
5962
6420
|
height: prPaneHeight
|
|
5963
6421
|
}
|
|
5964
6422
|
),
|
|
5965
|
-
jiraPaneHeight > 0 && /* @__PURE__ */
|
|
6423
|
+
jiraPaneHeight > 0 && /* @__PURE__ */ jsx5(
|
|
5966
6424
|
JiraPane,
|
|
5967
6425
|
{
|
|
5968
6426
|
jiraRows,
|
|
@@ -5972,7 +6430,7 @@ function App({ unsafe, onExit }) {
|
|
|
5972
6430
|
height: jiraPaneHeight
|
|
5973
6431
|
}
|
|
5974
6432
|
),
|
|
5975
|
-
/* @__PURE__ */
|
|
6433
|
+
/* @__PURE__ */ jsx5(
|
|
5976
6434
|
TaskPane,
|
|
5977
6435
|
{
|
|
5978
6436
|
taskRows,
|
|
@@ -5984,7 +6442,7 @@ function App({ unsafe, onExit }) {
|
|
|
5984
6442
|
}
|
|
5985
6443
|
)
|
|
5986
6444
|
] }),
|
|
5987
|
-
/* @__PURE__ */
|
|
6445
|
+
/* @__PURE__ */ jsx5(
|
|
5988
6446
|
TerminalPane,
|
|
5989
6447
|
{
|
|
5990
6448
|
lines: termLines,
|
|
@@ -5992,16 +6450,17 @@ function App({ unsafe, onExit }) {
|
|
|
5992
6450
|
height: contentHeight,
|
|
5993
6451
|
focused: focus === 4 /* TERMINAL */,
|
|
5994
6452
|
placeholder,
|
|
5995
|
-
title: "Terminal"
|
|
6453
|
+
title: "Terminal",
|
|
6454
|
+
scrollback: termScroll
|
|
5996
6455
|
}
|
|
5997
6456
|
)
|
|
5998
6457
|
] }),
|
|
5999
|
-
/* @__PURE__ */
|
|
6458
|
+
/* @__PURE__ */ jsx5(StatusBar, { message, pane: focus === 4 /* TERMINAL */ ? "terminal" : focus === 2 /* PRS */ ? "prs" : focus === 3 /* JIRA */ ? "jira" : focus === 1 /* TASKS */ ? "tasks" : "sessions", syncing })
|
|
6000
6459
|
] });
|
|
6001
6460
|
}
|
|
6002
6461
|
|
|
6003
6462
|
// src/tui-ink/index.tsx
|
|
6004
|
-
import { jsx as
|
|
6463
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
6005
6464
|
function crashLog(label2, err) {
|
|
6006
6465
|
try {
|
|
6007
6466
|
const msg = err instanceof Error ? err.stack || err.message : String(err);
|
|
@@ -6020,11 +6479,11 @@ async function startDashboard(unsafe) {
|
|
|
6020
6479
|
process.stdin.setRawMode(true);
|
|
6021
6480
|
process.stdin.resume();
|
|
6022
6481
|
const restore = () => {
|
|
6023
|
-
process.stdout.write("\x1B]0;\x07\x1B[?25h\x1B[?1049l");
|
|
6482
|
+
process.stdout.write("\x1B]0;\x07\x1B[?1000l\x1B[?1006l\x1B[?25h\x1B[?1049l");
|
|
6024
6483
|
};
|
|
6025
6484
|
try {
|
|
6026
6485
|
const { waitUntilExit, unmount } = render(
|
|
6027
|
-
/* @__PURE__ */
|
|
6486
|
+
/* @__PURE__ */ jsx6(App, { unsafe, onExit: () => {
|
|
6028
6487
|
unmount();
|
|
6029
6488
|
restore();
|
|
6030
6489
|
process.exit(0);
|
|
@@ -10624,7 +11083,7 @@ function completeGroupBranches(groupName, repoAliases, current, config, done) {
|
|
|
10624
11083
|
}
|
|
10625
11084
|
|
|
10626
11085
|
// src/version.ts
|
|
10627
|
-
var VERSION = true ? "1.
|
|
11086
|
+
var VERSION = true ? "1.8.0" : "dev";
|
|
10628
11087
|
|
|
10629
11088
|
// src/cli.ts
|
|
10630
11089
|
function showHelp() {
|