@moberg_hr/work-tree 1.7.0 → 1.8.5
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 +832 -319
- package/dist/bin.js.map +1 -1
- package/dist/wd-bin.js +829 -316
- package/dist/wd-bin.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/bin.ts
|
|
4
4
|
import fs45 from "fs";
|
|
5
|
-
import
|
|
5
|
+
import path42 from "path";
|
|
6
6
|
import chalk27 from "chalk";
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
@@ -323,26 +323,110 @@ async function fetchRemoteAsync(cwd) {
|
|
|
323
323
|
git(["remote", "set-head", "origin", "--auto"], cwd);
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
function
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
326
|
+
function gitAsync(args, cwd) {
|
|
327
|
+
debug("gitAsync", args.join(" "), `cwd=${cwd}`);
|
|
328
|
+
return new Promise((resolve) => {
|
|
329
|
+
execFile(
|
|
330
|
+
"git",
|
|
331
|
+
args,
|
|
332
|
+
{ cwd, encoding: "utf-8", timeout: 6e4, windowsHide: true },
|
|
333
|
+
(err, stdout, stderr) => {
|
|
334
|
+
const r = {
|
|
335
|
+
stdout: (stdout ?? "").toString().trim(),
|
|
336
|
+
stderr: (stderr ?? "").toString().trim(),
|
|
337
|
+
exitCode: err ? err.code ?? 1 : 0
|
|
338
|
+
};
|
|
339
|
+
if (typeof r.exitCode !== "number") r.exitCode = 1;
|
|
340
|
+
if (r.exitCode !== 0) {
|
|
341
|
+
debug("gitAsync failed", { args, exitCode: r.exitCode, stderr: r.stderr });
|
|
342
|
+
}
|
|
343
|
+
resolve(r);
|
|
344
|
+
}
|
|
345
|
+
);
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
async function getDefaultBranchAsync(cwd) {
|
|
349
|
+
const result = await gitAsync(["symbolic-ref", "refs/remotes/origin/HEAD"], cwd);
|
|
350
|
+
if (result.exitCode === 0 && result.stdout) {
|
|
351
|
+
return result.stdout.replace(/^refs\/remotes\/origin\//, "");
|
|
334
352
|
}
|
|
335
353
|
return null;
|
|
336
354
|
}
|
|
337
|
-
function
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
355
|
+
async function refExistsAsync(ref, cwd) {
|
|
356
|
+
return (await gitAsync(["rev-parse", "--verify", ref], cwd)).exitCode === 0;
|
|
357
|
+
}
|
|
358
|
+
async function checkSquashMergedAsync(branch, baseRef, cwd) {
|
|
359
|
+
const mb = await gitAsync(["merge-base", baseRef, branch], cwd);
|
|
360
|
+
if (mb.exitCode !== 0) return false;
|
|
361
|
+
const tree = await gitAsync(["rev-parse", `${branch}^{tree}`], cwd);
|
|
362
|
+
if (tree.exitCode !== 0) return false;
|
|
363
|
+
const dangling = await gitAsync(["commit-tree", tree.stdout, "-p", mb.stdout, "-m", ""], cwd);
|
|
364
|
+
if (dangling.exitCode !== 0) return false;
|
|
365
|
+
const cherry = await gitAsync(["cherry", baseRef, dangling.stdout], cwd);
|
|
366
|
+
if (cherry.exitCode !== 0) return false;
|
|
367
|
+
return cherry.stdout.startsWith("-");
|
|
368
|
+
}
|
|
369
|
+
async function checkMergeStatusAsync(branch, baseRef, cwd) {
|
|
370
|
+
const branchInBase = await gitAsync(["merge-base", "--is-ancestor", branch, baseRef], cwd);
|
|
371
|
+
if (branchInBase.exitCode !== 0) {
|
|
372
|
+
if (await checkSquashMergedAsync(branch, baseRef, cwd)) return "squash-merged";
|
|
373
|
+
return "unrelated";
|
|
374
|
+
}
|
|
375
|
+
const baseInBranch = await gitAsync(["merge-base", "--is-ancestor", baseRef, branch], cwd);
|
|
376
|
+
if (baseInBranch.exitCode === 0) return "merged";
|
|
377
|
+
const tip = await gitAsync(["rev-parse", branch], cwd);
|
|
378
|
+
if (tip.exitCode !== 0) return "unrelated";
|
|
379
|
+
const mainLine = await gitAsync(["rev-list", "--first-parent", "-n", "500", baseRef], cwd);
|
|
380
|
+
if (mainLine.exitCode === 0 && mainLine.stdout.includes(tip.stdout)) {
|
|
381
|
+
return "stale";
|
|
382
|
+
}
|
|
383
|
+
return "merged";
|
|
384
|
+
}
|
|
385
|
+
async function isBranchMergedAsync(branch, cwd, baseBranch) {
|
|
386
|
+
const defaultBranch = await getDefaultBranchAsync(cwd);
|
|
387
|
+
const bases = baseBranch ? [baseBranch] : [defaultBranch, "main", "master"].filter(
|
|
388
|
+
(b) => b !== null
|
|
389
|
+
);
|
|
390
|
+
const uniqueBases = [...new Set(bases)];
|
|
391
|
+
for (const base of uniqueBases) {
|
|
392
|
+
if (await refExistsAsync(`origin/${base}`, cwd)) {
|
|
393
|
+
const baseRef = `origin/${base}`;
|
|
394
|
+
const status = await checkMergeStatusAsync(branch, baseRef, cwd);
|
|
395
|
+
if (status === "merged") return { merged: true, into: baseRef, confidence: "merged" };
|
|
396
|
+
if (status === "squash-merged")
|
|
397
|
+
return { merged: true, into: baseRef, confidence: "squash-merged" };
|
|
398
|
+
if (status === "stale") return { merged: false, into: null, confidence: null };
|
|
399
|
+
}
|
|
400
|
+
if (await refExistsAsync(base, cwd)) {
|
|
401
|
+
const status = await checkMergeStatusAsync(branch, base, cwd);
|
|
402
|
+
if (status === "merged") return { merged: true, into: base, confidence: "merged" };
|
|
403
|
+
if (status === "squash-merged")
|
|
404
|
+
return { merged: true, into: base, confidence: "squash-merged" };
|
|
405
|
+
if (status === "stale") return { merged: false, into: null, confidence: null };
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return { merged: false, into: null, confidence: null };
|
|
409
|
+
}
|
|
410
|
+
async function countConflictsAsync(branch, cwd) {
|
|
411
|
+
const defaultBranch = await getDefaultBranchAsync(cwd) ?? "main";
|
|
412
|
+
const base = await refExistsAsync(`origin/${defaultBranch}`, cwd) ? `origin/${defaultBranch}` : defaultBranch;
|
|
413
|
+
const mergeBase = await gitAsync(["merge-base", base, branch], cwd);
|
|
341
414
|
if (mergeBase.exitCode !== 0) return 0;
|
|
342
|
-
const result =
|
|
415
|
+
const result = await gitAsync(["merge-tree", mergeBase.stdout, base, branch], cwd);
|
|
343
416
|
const conflicts = (result.stdout.match(/^<<<<<<< /gm) || []).length;
|
|
344
417
|
return conflicts;
|
|
345
418
|
}
|
|
419
|
+
async function rebaseOntoMainAsync(branch, cwd) {
|
|
420
|
+
const defaultBranch = await getDefaultBranchAsync(cwd) ?? "main";
|
|
421
|
+
await gitAsync(["fetch", "--quiet"], cwd);
|
|
422
|
+
const base = await refExistsAsync(`origin/${defaultBranch}`, cwd) ? `origin/${defaultBranch}` : defaultBranch;
|
|
423
|
+
const result = await gitAsync(["rebase", base, branch], cwd);
|
|
424
|
+
if (result.exitCode !== 0) {
|
|
425
|
+
await gitAsync(["rebase", "--abort"], cwd);
|
|
426
|
+
return result.stderr || "Rebase failed";
|
|
427
|
+
}
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
346
430
|
function getUnpushedCommits(cwd) {
|
|
347
431
|
const branch = getCurrentBranch(cwd);
|
|
348
432
|
if (!branch) return "";
|
|
@@ -1404,6 +1488,28 @@ function effectiveLastAccessedAt(session) {
|
|
|
1404
1488
|
}
|
|
1405
1489
|
return new Date(bestMs).toISOString();
|
|
1406
1490
|
}
|
|
1491
|
+
function resolveResumeLaunch(session) {
|
|
1492
|
+
const existing = session.paths.filter((p) => fs9.existsSync(p));
|
|
1493
|
+
const first = existing[0] ?? session.paths[0];
|
|
1494
|
+
const defaultPath = session.isGroup ? path9.dirname(first) : first;
|
|
1495
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
1496
|
+
if (session.isGroup) {
|
|
1497
|
+
for (const p of existing) candidates.add(path9.dirname(p));
|
|
1498
|
+
for (const p of existing) candidates.add(p);
|
|
1499
|
+
} else {
|
|
1500
|
+
for (const p of existing) candidates.add(p);
|
|
1501
|
+
}
|
|
1502
|
+
let launchPath = defaultPath;
|
|
1503
|
+
let bestMs = 0;
|
|
1504
|
+
for (const c of candidates) {
|
|
1505
|
+
const ms = getClaudeActivityMs(c);
|
|
1506
|
+
if (ms > bestMs) {
|
|
1507
|
+
bestMs = ms;
|
|
1508
|
+
launchPath = c;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
return { launchPath, hasConversation: bestMs > 0 };
|
|
1512
|
+
}
|
|
1407
1513
|
var ACTIVE_MS = 3e4;
|
|
1408
1514
|
var OPEN_MS = 5 * 6e4;
|
|
1409
1515
|
function readSessionActivity(session) {
|
|
@@ -2663,7 +2769,6 @@ function printSessionStatus(session) {
|
|
|
2663
2769
|
|
|
2664
2770
|
// src/commands/recent.ts
|
|
2665
2771
|
import fs17 from "fs";
|
|
2666
|
-
import path14 from "path";
|
|
2667
2772
|
import chalk10 from "chalk";
|
|
2668
2773
|
import { select as select2 } from "@inquirer/prompts";
|
|
2669
2774
|
var recentCommand = {
|
|
@@ -2721,12 +2826,19 @@ var recentCommand = {
|
|
|
2721
2826
|
process.exitCode = 1;
|
|
2722
2827
|
return;
|
|
2723
2828
|
}
|
|
2724
|
-
const launchPath
|
|
2829
|
+
const { launchPath, hasConversation } = resolveResumeLaunch(choice);
|
|
2725
2830
|
await upsertSession(choice.target, choice.isGroup, choice.branch, choice.paths);
|
|
2726
2831
|
const tool = getAiTool(config);
|
|
2727
2832
|
console.log(chalk10.cyan(`Resuming in: ${launchPath}`));
|
|
2833
|
+
if (!hasConversation) {
|
|
2834
|
+
console.log(
|
|
2835
|
+
chalk10.yellow(
|
|
2836
|
+
`No prior ${tool.cmd} conversation found for this worktree \u2014 starting a fresh session.`
|
|
2837
|
+
)
|
|
2838
|
+
);
|
|
2839
|
+
}
|
|
2728
2840
|
console.log(`Starting ${tool.cmd}...`);
|
|
2729
|
-
launchAi(launchPath, tool, { unsafe, resume:
|
|
2841
|
+
launchAi(launchPath, tool, { unsafe, resume: hasConversation }, choice.port);
|
|
2730
2842
|
return;
|
|
2731
2843
|
}
|
|
2732
2844
|
console.log("");
|
|
@@ -2753,7 +2865,6 @@ var recentCommand = {
|
|
|
2753
2865
|
|
|
2754
2866
|
// src/commands/resume.ts
|
|
2755
2867
|
import fs18 from "fs";
|
|
2756
|
-
import path15 from "path";
|
|
2757
2868
|
import chalk11 from "chalk";
|
|
2758
2869
|
import { select as select3 } from "@inquirer/prompts";
|
|
2759
2870
|
var resumeCommand = {
|
|
@@ -2796,12 +2907,19 @@ var resumeCommand = {
|
|
|
2796
2907
|
process.exitCode = 1;
|
|
2797
2908
|
return;
|
|
2798
2909
|
}
|
|
2799
|
-
const launchPath
|
|
2910
|
+
const { launchPath, hasConversation } = resolveResumeLaunch(choice);
|
|
2800
2911
|
await upsertSession(choice.target, choice.isGroup, choice.branch, choice.paths);
|
|
2801
2912
|
const tool = getAiTool(config);
|
|
2802
2913
|
console.log(chalk11.cyan(`Resuming in: ${launchPath}`));
|
|
2914
|
+
if (!hasConversation) {
|
|
2915
|
+
console.log(
|
|
2916
|
+
chalk11.yellow(
|
|
2917
|
+
`No prior ${tool.cmd} conversation found for this worktree \u2014 starting a fresh session.`
|
|
2918
|
+
)
|
|
2919
|
+
);
|
|
2920
|
+
}
|
|
2803
2921
|
console.log(`Starting ${tool.cmd}...`);
|
|
2804
|
-
launchAi(launchPath, tool, { unsafe, resume:
|
|
2922
|
+
launchAi(launchPath, tool, { unsafe, resume: hasConversation }, choice.port);
|
|
2805
2923
|
}
|
|
2806
2924
|
};
|
|
2807
2925
|
|
|
@@ -2811,7 +2929,7 @@ import { checkbox } from "@inquirer/prompts";
|
|
|
2811
2929
|
|
|
2812
2930
|
// src/core/prunable-scan.ts
|
|
2813
2931
|
import fs19 from "fs";
|
|
2814
|
-
import
|
|
2932
|
+
import path14 from "path";
|
|
2815
2933
|
import chalk12 from "chalk";
|
|
2816
2934
|
function collectPrunable(config, options = {}) {
|
|
2817
2935
|
const { fetch: fetch2 = true, print = true, includeSquash = false } = options;
|
|
@@ -2828,7 +2946,7 @@ function collectPrunable(config, options = {}) {
|
|
|
2828
2946
|
}
|
|
2829
2947
|
const groupCoveredKeys = /* @__PURE__ */ new Set();
|
|
2830
2948
|
for (const [groupName, aliases] of Object.entries(config.groups)) {
|
|
2831
|
-
const groupDir =
|
|
2949
|
+
const groupDir = path14.join(config.worktreesRoot, groupName);
|
|
2832
2950
|
if (!fs19.existsSync(groupDir)) continue;
|
|
2833
2951
|
let branchDirs;
|
|
2834
2952
|
try {
|
|
@@ -2837,7 +2955,7 @@ function collectPrunable(config, options = {}) {
|
|
|
2837
2955
|
continue;
|
|
2838
2956
|
}
|
|
2839
2957
|
for (const branchDir of branchDirs) {
|
|
2840
|
-
const branchDirPath =
|
|
2958
|
+
const branchDirPath = path14.join(groupDir, branchDir);
|
|
2841
2959
|
let branch;
|
|
2842
2960
|
let allMerged = true;
|
|
2843
2961
|
let groupHasChanges = false;
|
|
@@ -2851,8 +2969,8 @@ function collectPrunable(config, options = {}) {
|
|
|
2851
2969
|
skipped = true;
|
|
2852
2970
|
continue;
|
|
2853
2971
|
}
|
|
2854
|
-
const repoName =
|
|
2855
|
-
const subWorktreePath =
|
|
2972
|
+
const repoName = path14.basename(repoPath);
|
|
2973
|
+
const subWorktreePath = path14.join(branchDirPath, repoName);
|
|
2856
2974
|
if (!fs19.existsSync(subWorktreePath)) {
|
|
2857
2975
|
continue;
|
|
2858
2976
|
}
|
|
@@ -2969,7 +3087,7 @@ async function removeSingleEntry(entry, force = true) {
|
|
|
2969
3087
|
}
|
|
2970
3088
|
async function removeGroupEntry(entry, config, force = true) {
|
|
2971
3089
|
const workTreeDirName = entry.branch.replace(/\//g, "-");
|
|
2972
|
-
const groupWorktreePath =
|
|
3090
|
+
const groupWorktreePath = path14.join(
|
|
2973
3091
|
config.worktreesRoot,
|
|
2974
3092
|
entry.target,
|
|
2975
3093
|
workTreeDirName
|
|
@@ -2979,7 +3097,7 @@ async function removeGroupEntry(entry, config, force = true) {
|
|
|
2979
3097
|
);
|
|
2980
3098
|
let allRemoved = true;
|
|
2981
3099
|
for (const { alias, repoPath, worktreePath } of entry.repos) {
|
|
2982
|
-
const repoName =
|
|
3100
|
+
const repoName = path14.basename(repoPath);
|
|
2983
3101
|
console.log(chalk12.cyan(` [${alias}] (${repoName}):`));
|
|
2984
3102
|
const removed = removeSingleWorktree(repoPath, worktreePath, entry.branch, force);
|
|
2985
3103
|
if (!removed) {
|
|
@@ -2989,7 +3107,7 @@ async function removeGroupEntry(entry, config, force = true) {
|
|
|
2989
3107
|
if (allRemoved) {
|
|
2990
3108
|
await removeSession(entry.target, entry.branch);
|
|
2991
3109
|
}
|
|
2992
|
-
const claudeMdInWorktree =
|
|
3110
|
+
const claudeMdInWorktree = path14.join(groupWorktreePath, "CLAUDE.md");
|
|
2993
3111
|
if (fs19.existsSync(claudeMdInWorktree)) {
|
|
2994
3112
|
fs19.unlinkSync(claudeMdInWorktree);
|
|
2995
3113
|
}
|
|
@@ -3215,15 +3333,15 @@ var syncCommand = {
|
|
|
3215
3333
|
|
|
3216
3334
|
// src/tui-ink/index.tsx
|
|
3217
3335
|
import fs24 from "fs";
|
|
3218
|
-
import
|
|
3336
|
+
import path19 from "path";
|
|
3219
3337
|
import { render } from "ink";
|
|
3220
3338
|
|
|
3221
3339
|
// src/tui-ink/App.tsx
|
|
3222
3340
|
import { useState, useEffect, useRef, useCallback, useMemo } from "react";
|
|
3223
|
-
import { Box as
|
|
3341
|
+
import { Box as Box5 } from "ink";
|
|
3224
3342
|
import fs23 from "fs";
|
|
3225
3343
|
import os6 from "os";
|
|
3226
|
-
import
|
|
3344
|
+
import path18 from "path";
|
|
3227
3345
|
import { execFile as execFile4 } from "child_process";
|
|
3228
3346
|
import spawn7 from "cross-spawn";
|
|
3229
3347
|
|
|
@@ -3437,10 +3555,10 @@ async function fetchJiraPane() {
|
|
|
3437
3555
|
|
|
3438
3556
|
// src/core/tasks.ts
|
|
3439
3557
|
import fs21 from "fs";
|
|
3440
|
-
import
|
|
3558
|
+
import path15 from "path";
|
|
3441
3559
|
var EMPTY_STORE = { nextId: 1, tasks: [] };
|
|
3442
3560
|
function getTasksPath() {
|
|
3443
|
-
return
|
|
3561
|
+
return path15.join(getConfigDir(), "tasks.json");
|
|
3444
3562
|
}
|
|
3445
3563
|
function loadStore() {
|
|
3446
3564
|
const p = getTasksPath();
|
|
@@ -3537,7 +3655,7 @@ var PtySession = class {
|
|
|
3537
3655
|
cwd;
|
|
3538
3656
|
outputHandler;
|
|
3539
3657
|
_exited = false;
|
|
3540
|
-
|
|
3658
|
+
_status = "idle";
|
|
3541
3659
|
_outputBuffer = "";
|
|
3542
3660
|
_loggedOutput = false;
|
|
3543
3661
|
onExit;
|
|
@@ -3607,13 +3725,18 @@ var PtySession = class {
|
|
|
3607
3725
|
get exited() {
|
|
3608
3726
|
return this._exited;
|
|
3609
3727
|
}
|
|
3728
|
+
/** True when the session is not actively working (idle or needs input). */
|
|
3610
3729
|
get idle() {
|
|
3611
|
-
return this.
|
|
3730
|
+
return this._status !== "running";
|
|
3731
|
+
}
|
|
3732
|
+
/** Live status: 'running', 'idle' (turn finished) or 'attention' (needs input). */
|
|
3733
|
+
get status() {
|
|
3734
|
+
return this._status;
|
|
3612
3735
|
}
|
|
3613
|
-
/** Called by the dashboard when a hook event indicates
|
|
3614
|
-
|
|
3615
|
-
if (this._exited || this.
|
|
3616
|
-
this.
|
|
3736
|
+
/** Called by the dashboard when a hook event indicates a state change. */
|
|
3737
|
+
setStatus(status) {
|
|
3738
|
+
if (this._exited || this._status === status) return;
|
|
3739
|
+
this._status = status;
|
|
3617
3740
|
this.onStatusChange?.();
|
|
3618
3741
|
}
|
|
3619
3742
|
write(data) {
|
|
@@ -3684,13 +3807,13 @@ var PtySession = class {
|
|
|
3684
3807
|
|
|
3685
3808
|
// src/core/hook-server.ts
|
|
3686
3809
|
import http from "http";
|
|
3687
|
-
import
|
|
3810
|
+
import path17 from "path";
|
|
3688
3811
|
|
|
3689
3812
|
// src/core/settings-editor.ts
|
|
3690
3813
|
import fs22 from "fs";
|
|
3691
|
-
import
|
|
3814
|
+
import path16 from "path";
|
|
3692
3815
|
import os5 from "os";
|
|
3693
|
-
var SETTINGS_PATH =
|
|
3816
|
+
var SETTINGS_PATH = path16.join(os5.homedir(), ".claude", "settings.json");
|
|
3694
3817
|
var OWNER_TAG = "_workHookOwner";
|
|
3695
3818
|
var PID_TAG = "_workHookPid";
|
|
3696
3819
|
var LEGACY_TAGS = ["_workDash", "_work2Dash"];
|
|
@@ -3704,7 +3827,7 @@ function readSettings() {
|
|
|
3704
3827
|
}
|
|
3705
3828
|
function writeAtomic(s) {
|
|
3706
3829
|
try {
|
|
3707
|
-
fs22.mkdirSync(
|
|
3830
|
+
fs22.mkdirSync(path16.dirname(SETTINGS_PATH), { recursive: true });
|
|
3708
3831
|
const tmp = `${SETTINGS_PATH}.tmp-${process.pid}-${Date.now()}`;
|
|
3709
3832
|
fs22.writeFileSync(tmp, JSON.stringify(s, null, 2), "utf-8");
|
|
3710
3833
|
fs22.renameSync(tmp, SETTINGS_PATH);
|
|
@@ -3879,7 +4002,7 @@ function removeHttpHooksSync(owner) {
|
|
|
3879
4002
|
editSettingsSync(mutateRemove(owner));
|
|
3880
4003
|
}
|
|
3881
4004
|
function normalizePath(p) {
|
|
3882
|
-
return
|
|
4005
|
+
return path17.resolve(p).toLowerCase();
|
|
3883
4006
|
}
|
|
3884
4007
|
|
|
3885
4008
|
// src/core/notifier.ts
|
|
@@ -4080,7 +4203,7 @@ function renderBufferLines(buffer, cols, rows, scrollBack = 0) {
|
|
|
4080
4203
|
// src/tui-ink/Sidebar.tsx
|
|
4081
4204
|
import React from "react";
|
|
4082
4205
|
import { Box, Text } from "ink";
|
|
4083
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4206
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4084
4207
|
function buildSessionRows(sessions, statusMap) {
|
|
4085
4208
|
if (sessions.length === 0) return [];
|
|
4086
4209
|
const rows = [];
|
|
@@ -4089,7 +4212,7 @@ function buildSessionRows(sessions, statusMap) {
|
|
|
4089
4212
|
for (const s of sessions) {
|
|
4090
4213
|
const key = `${s.target}:${s.branch}`;
|
|
4091
4214
|
const status = statusMap?.get(key);
|
|
4092
|
-
if (status
|
|
4215
|
+
if (status !== void 0 && status !== "stopped") {
|
|
4093
4216
|
active.push(s);
|
|
4094
4217
|
} else {
|
|
4095
4218
|
inactive.push(s);
|
|
@@ -4213,6 +4336,47 @@ function cursorToRow(rows, cursor) {
|
|
|
4213
4336
|
function sessionKey2(s) {
|
|
4214
4337
|
return `${s.target}:${s.branch}`;
|
|
4215
4338
|
}
|
|
4339
|
+
function computeScrollOffset(rows, cursor, contentHeight) {
|
|
4340
|
+
let cursorRowIdx = 0;
|
|
4341
|
+
let selectableCount = 0;
|
|
4342
|
+
for (let i = 0; i < rows.length; i++) {
|
|
4343
|
+
if (rows[i].type !== "header") {
|
|
4344
|
+
if (selectableCount === cursor) {
|
|
4345
|
+
cursorRowIdx = i;
|
|
4346
|
+
break;
|
|
4347
|
+
}
|
|
4348
|
+
selectableCount++;
|
|
4349
|
+
}
|
|
4350
|
+
}
|
|
4351
|
+
if (rows.length > contentHeight && cursorRowIdx >= contentHeight - 1) {
|
|
4352
|
+
return Math.min(
|
|
4353
|
+
cursorRowIdx - contentHeight + 2,
|
|
4354
|
+
rows.length - contentHeight
|
|
4355
|
+
);
|
|
4356
|
+
}
|
|
4357
|
+
return 0;
|
|
4358
|
+
}
|
|
4359
|
+
function InputText({ value, pos, budget }) {
|
|
4360
|
+
let v = value;
|
|
4361
|
+
let p = pos;
|
|
4362
|
+
if (budget !== void 0 && value.length + 1 > budget) {
|
|
4363
|
+
const windowLen = Math.max(1, budget - 1);
|
|
4364
|
+
const start = Math.max(0, p - windowLen);
|
|
4365
|
+
v = value.slice(start, start + windowLen);
|
|
4366
|
+
p = pos - start;
|
|
4367
|
+
}
|
|
4368
|
+
if (p >= v.length) {
|
|
4369
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4370
|
+
/* @__PURE__ */ jsx(Text, { children: v }),
|
|
4371
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2588" })
|
|
4372
|
+
] });
|
|
4373
|
+
}
|
|
4374
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4375
|
+
/* @__PURE__ */ jsx(Text, { children: v.slice(0, p) }),
|
|
4376
|
+
/* @__PURE__ */ jsx(Text, { inverse: true, children: v[p] }),
|
|
4377
|
+
/* @__PURE__ */ jsx(Text, { children: v.slice(p + 1) })
|
|
4378
|
+
] });
|
|
4379
|
+
}
|
|
4216
4380
|
function truncate(str, max) {
|
|
4217
4381
|
if (max <= 1) return "";
|
|
4218
4382
|
return str.length > max ? str.slice(0, max - 1) + "\u2026" : str;
|
|
@@ -4257,8 +4421,8 @@ function SessionRow({
|
|
|
4257
4421
|
active,
|
|
4258
4422
|
width
|
|
4259
4423
|
}) {
|
|
4260
|
-
const dotChar = status === "
|
|
4261
|
-
const dotColor = status === "
|
|
4424
|
+
const dotChar = status === "attention" ? "\u25C6" : status === "idle" ? "\u25C7" : status === "running" ? "\u25CF" : "\u25CB";
|
|
4425
|
+
const dotColor = status === "attention" ? "yellow" : status === "idle" ? "cyan" : status === "running" ? "green" : "gray";
|
|
4262
4426
|
const agoStr = timeAgo(effectiveLastAccessedAt(s));
|
|
4263
4427
|
const mergedLen = merged ? 8 : 0;
|
|
4264
4428
|
const conflictLen = conflicts > 0 ? 2 + String(conflicts).length : 0;
|
|
@@ -4303,11 +4467,8 @@ function ProjectRow({
|
|
|
4303
4467
|
/* @__PURE__ */ jsx(Text, { color: "magenta", children: truncate(name, width - 15) }),
|
|
4304
4468
|
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
4305
4469
|
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "branch:" }),
|
|
4306
|
-
/* @__PURE__ */
|
|
4307
|
-
|
|
4308
|
-
branchInput.value
|
|
4309
|
-
] }),
|
|
4310
|
-
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2588" })
|
|
4470
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
4471
|
+
/* @__PURE__ */ jsx(InputText, { value: branchInput.value, pos: branchInput.pos })
|
|
4311
4472
|
] });
|
|
4312
4473
|
}
|
|
4313
4474
|
return /* @__PURE__ */ jsxs(Box, { width, children: [
|
|
@@ -4365,26 +4526,7 @@ function BorderedPane({
|
|
|
4365
4526
|
}) {
|
|
4366
4527
|
const innerWidth = width - 2;
|
|
4367
4528
|
const contentHeight = height - 2;
|
|
4368
|
-
|
|
4369
|
-
let selectableCount = 0;
|
|
4370
|
-
for (let i = 0; i < sidebarRows.length; i++) {
|
|
4371
|
-
if (sidebarRows[i].type !== "header") {
|
|
4372
|
-
if (selectableCount === cursor) {
|
|
4373
|
-
cursorRowIdx = i;
|
|
4374
|
-
break;
|
|
4375
|
-
}
|
|
4376
|
-
selectableCount++;
|
|
4377
|
-
}
|
|
4378
|
-
}
|
|
4379
|
-
let scrollOffset = 0;
|
|
4380
|
-
if (sidebarRows.length > contentHeight) {
|
|
4381
|
-
if (cursorRowIdx >= contentHeight - 1) {
|
|
4382
|
-
scrollOffset = Math.min(
|
|
4383
|
-
cursorRowIdx - contentHeight + 2,
|
|
4384
|
-
sidebarRows.length - contentHeight
|
|
4385
|
-
);
|
|
4386
|
-
}
|
|
4387
|
-
}
|
|
4529
|
+
const scrollOffset = computeScrollOffset(sidebarRows, cursor, contentHeight);
|
|
4388
4530
|
const rendered = [];
|
|
4389
4531
|
let selectableIdx = 0;
|
|
4390
4532
|
for (let i = 0; i < scrollOffset; i++) {
|
|
@@ -4405,7 +4547,14 @@ function BorderedPane({
|
|
|
4405
4547
|
rendered.push(renderRow(row, rowIdx, sel));
|
|
4406
4548
|
}
|
|
4407
4549
|
}
|
|
4408
|
-
const
|
|
4550
|
+
const hiddenAbove = scrollOffset;
|
|
4551
|
+
const hiddenBelow = Math.max(0, sidebarRows.length - (scrollOffset + contentHeight));
|
|
4552
|
+
const upText = hiddenAbove > 0 ? ` \u2191${hiddenAbove} ` : "";
|
|
4553
|
+
const downText = hiddenBelow > 0 ? ` \u2193${hiddenBelow} ` : "";
|
|
4554
|
+
const titlePart = title ? "\u2500 " + title + " " : "";
|
|
4555
|
+
const topFill = Math.max(0, innerWidth - titlePart.length - upText.length);
|
|
4556
|
+
const topBorder = "\u250C" + titlePart + "\u2500".repeat(topFill) + upText + "\u2510";
|
|
4557
|
+
const bottomBorder = "\u2514" + "\u2500".repeat(Math.max(0, innerWidth - downText.length)) + downText + "\u2518";
|
|
4409
4558
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", width, children: [
|
|
4410
4559
|
/* @__PURE__ */ jsx(Text, { color: borderColor, children: topBorder }),
|
|
4411
4560
|
rendered.map((row, i) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
@@ -4413,12 +4562,13 @@ function BorderedPane({
|
|
|
4413
4562
|
row,
|
|
4414
4563
|
/* @__PURE__ */ jsx(Text, { color: borderColor, children: "\u2502" })
|
|
4415
4564
|
] }, i)),
|
|
4416
|
-
/* @__PURE__ */ jsx(Text, { color: borderColor, children:
|
|
4565
|
+
/* @__PURE__ */ jsx(Text, { color: borderColor, children: bottomBorder })
|
|
4417
4566
|
] });
|
|
4418
4567
|
}
|
|
4419
|
-
|
|
4568
|
+
var Sidebar = React.memo(function Sidebar2({ sidebarRows, cursor, focused, statusMap, conflictCounts, mergedSet, prMap, activeKey, width, height, branchInput, filter }) {
|
|
4420
4569
|
const borderColor = focused ? "cyan" : "gray";
|
|
4421
4570
|
const innerWidth = width - 2;
|
|
4571
|
+
const title = filter ? `Worktrees /${filter.value}${filter.editing ? "\u2588" : ""}` : "Worktrees";
|
|
4422
4572
|
return /* @__PURE__ */ jsx(
|
|
4423
4573
|
BorderedPane,
|
|
4424
4574
|
{
|
|
@@ -4426,7 +4576,7 @@ function Sidebar({ sidebarRows, cursor, focused, statusMap, conflictCounts, merg
|
|
|
4426
4576
|
cursor,
|
|
4427
4577
|
focused,
|
|
4428
4578
|
borderColor,
|
|
4429
|
-
title
|
|
4579
|
+
title,
|
|
4430
4580
|
width,
|
|
4431
4581
|
height,
|
|
4432
4582
|
renderRow: (row, i, sel) => {
|
|
@@ -4467,7 +4617,7 @@ function Sidebar({ sidebarRows, cursor, focused, statusMap, conflictCounts, merg
|
|
|
4467
4617
|
}
|
|
4468
4618
|
}
|
|
4469
4619
|
);
|
|
4470
|
-
}
|
|
4620
|
+
});
|
|
4471
4621
|
function statusColor(status) {
|
|
4472
4622
|
const lower = status.toLowerCase();
|
|
4473
4623
|
if (lower.includes("progress") || lower.includes("review")) return "cyan";
|
|
@@ -4492,7 +4642,7 @@ function JiraListRow({
|
|
|
4492
4642
|
/* @__PURE__ */ jsx(Text, { children: truncate(issue.summary, summaryBudget) })
|
|
4493
4643
|
] });
|
|
4494
4644
|
}
|
|
4495
|
-
|
|
4645
|
+
var PrPane = React.memo(function PrPane2({ prRows, cursor, focused, localBranches, width, height }) {
|
|
4496
4646
|
const borderColor = focused ? "cyan" : "gray";
|
|
4497
4647
|
const innerWidth = width - 2;
|
|
4498
4648
|
return /* @__PURE__ */ jsx(
|
|
@@ -4523,7 +4673,7 @@ function PrPane({ prRows, cursor, focused, localBranches, width, height }) {
|
|
|
4523
4673
|
}
|
|
4524
4674
|
}
|
|
4525
4675
|
);
|
|
4526
|
-
}
|
|
4676
|
+
});
|
|
4527
4677
|
function TaskListRow({
|
|
4528
4678
|
task,
|
|
4529
4679
|
selected,
|
|
@@ -4545,22 +4695,21 @@ function TaskListRow({
|
|
|
4545
4695
|
/* @__PURE__ */ jsx(Text, { dimColor: true, children: idStr })
|
|
4546
4696
|
] });
|
|
4547
4697
|
}
|
|
4548
|
-
function TaskInputRow({ value, width }) {
|
|
4698
|
+
function TaskInputRow({ value, pos, width }) {
|
|
4549
4699
|
const budget = Math.max(4, width - 8);
|
|
4550
4700
|
return /* @__PURE__ */ jsxs(Box, { width, children: [
|
|
4551
4701
|
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
4552
4702
|
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "+ " }),
|
|
4553
|
-
/* @__PURE__ */ jsx(
|
|
4554
|
-
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2588" })
|
|
4703
|
+
/* @__PURE__ */ jsx(InputText, { value, pos, budget })
|
|
4555
4704
|
] });
|
|
4556
4705
|
}
|
|
4557
|
-
|
|
4706
|
+
var TaskPane = React.memo(function TaskPane2({ taskRows, cursor, focused, width, height, taskInput }) {
|
|
4558
4707
|
const borderColor = focused ? "cyan" : "gray";
|
|
4559
4708
|
const innerWidth = width - 2;
|
|
4560
4709
|
const contentHeight = height - 2;
|
|
4561
4710
|
if (taskInput !== null && taskInput !== void 0) {
|
|
4562
4711
|
const rendered = [];
|
|
4563
|
-
rendered.push(/* @__PURE__ */ jsx(TaskInputRow, { value: taskInput, width: innerWidth }, "input"));
|
|
4712
|
+
rendered.push(/* @__PURE__ */ jsx(TaskInputRow, { value: taskInput.value, pos: taskInput.pos, width: innerWidth }, "input"));
|
|
4564
4713
|
let selectableIdx = 0;
|
|
4565
4714
|
for (let i = 0; i < contentHeight - 1 && i < taskRows.length; i++) {
|
|
4566
4715
|
const row = taskRows[i];
|
|
@@ -4615,8 +4764,8 @@ function TaskPane({ taskRows, cursor, focused, width, height, taskInput }) {
|
|
|
4615
4764
|
}
|
|
4616
4765
|
}
|
|
4617
4766
|
);
|
|
4618
|
-
}
|
|
4619
|
-
|
|
4767
|
+
});
|
|
4768
|
+
var JiraPane = React.memo(function JiraPane2({ jiraRows, cursor, focused, width, height }) {
|
|
4620
4769
|
const borderColor = focused ? "cyan" : "gray";
|
|
4621
4770
|
const innerWidth = width - 2;
|
|
4622
4771
|
return /* @__PURE__ */ jsx(
|
|
@@ -4646,12 +4795,13 @@ function JiraPane({ jiraRows, cursor, focused, width, height }) {
|
|
|
4646
4795
|
}
|
|
4647
4796
|
}
|
|
4648
4797
|
);
|
|
4649
|
-
}
|
|
4798
|
+
});
|
|
4650
4799
|
|
|
4651
4800
|
// src/tui-ink/TerminalPane.tsx
|
|
4801
|
+
import React2 from "react";
|
|
4652
4802
|
import { Box as Box2, Text as Text2 } from "ink";
|
|
4653
4803
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
4654
|
-
|
|
4804
|
+
var TerminalPane = React2.memo(function TerminalPane2({ lines, width, height, focused, placeholder, title, scrollback }) {
|
|
4655
4805
|
const borderColor = focused ? "cyan" : "gray";
|
|
4656
4806
|
const innerWidth = width - 2;
|
|
4657
4807
|
const contentHeight = height - 2;
|
|
@@ -4677,8 +4827,10 @@ function TerminalPane({ lines, width, height, focused, placeholder, title }) {
|
|
|
4677
4827
|
}
|
|
4678
4828
|
}
|
|
4679
4829
|
}
|
|
4830
|
+
const scrolledTitle = scrollback && scrollback > 0 ? `${title ?? "Terminal"} \u2500 \u2191${scrollback} paused (pgdn/type to resume)` : title;
|
|
4831
|
+
const topBorder = scrolledTitle ? "\u250C\u2500 " + scrolledTitle + " " + "\u2500".repeat(Math.max(0, innerWidth - scrolledTitle.length - 3)) + "\u2510" : "\u250C" + "\u2500".repeat(innerWidth) + "\u2510";
|
|
4680
4832
|
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", width, children: [
|
|
4681
|
-
/* @__PURE__ */ jsx2(Text2, { color:
|
|
4833
|
+
/* @__PURE__ */ jsx2(Text2, { color: scrollback && scrollback > 0 ? "yellow" : borderColor, children: topBorder }),
|
|
4682
4834
|
content.map((row, i) => /* @__PURE__ */ jsxs2(Box2, { children: [
|
|
4683
4835
|
/* @__PURE__ */ jsx2(Text2, { color: borderColor, children: "\u2502" }),
|
|
4684
4836
|
/* @__PURE__ */ jsx2(Box2, { width: innerWidth, children: row }),
|
|
@@ -4686,19 +4838,20 @@ function TerminalPane({ lines, width, height, focused, placeholder, title }) {
|
|
|
4686
4838
|
] }, i)),
|
|
4687
4839
|
/* @__PURE__ */ jsx2(Text2, { color: borderColor, children: "\u2514" + "\u2500".repeat(innerWidth) + "\u2518" })
|
|
4688
4840
|
] });
|
|
4689
|
-
}
|
|
4841
|
+
});
|
|
4690
4842
|
|
|
4691
4843
|
// src/tui-ink/StatusBar.tsx
|
|
4844
|
+
import React3 from "react";
|
|
4692
4845
|
import { Box as Box3, Text as Text3 } from "ink";
|
|
4693
|
-
import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
4846
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
4694
4847
|
var PANE_HINTS = {
|
|
4695
|
-
sessions: " tab pane j/k nav enter start n new d remove
|
|
4696
|
-
tasks: " tab pane j/k nav enter toggle a add e edit w worktree d remove
|
|
4697
|
-
prs: " tab pane j/k nav enter checkout g sync
|
|
4698
|
-
jira: " tab pane j/k nav enter worktree o open g sync
|
|
4699
|
-
terminal: " tab pane ctrl+] detach "
|
|
4848
|
+
sessions: " tab pane j/k nav / filter enter start n new d remove u rebase g sync ? help q quit ",
|
|
4849
|
+
tasks: " tab pane j/k nav enter toggle a add e edit w worktree d remove ? help q quit ",
|
|
4850
|
+
prs: " tab pane j/k nav enter checkout o open g sync ? help q quit ",
|
|
4851
|
+
jira: " tab pane j/k nav enter worktree o open g sync ? help q quit ",
|
|
4852
|
+
terminal: " tab pane ctrl+] detach pgup/pgdn scroll "
|
|
4700
4853
|
};
|
|
4701
|
-
|
|
4854
|
+
var StatusBar = React3.memo(function StatusBar2({ message, pane, syncing }) {
|
|
4702
4855
|
if (message) {
|
|
4703
4856
|
return /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
4704
4857
|
/* @__PURE__ */ jsxs3(Text3, { color: "yellow", children: [
|
|
@@ -4711,30 +4864,226 @@ function StatusBar({ message, pane, syncing }) {
|
|
|
4711
4864
|
}
|
|
4712
4865
|
return /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
4713
4866
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: PANE_HINTS[pane] }),
|
|
4714
|
-
pane === "sessions" && /* @__PURE__ */ jsxs3(
|
|
4867
|
+
pane === "sessions" && /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
4715
4868
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "[" }),
|
|
4716
4869
|
/* @__PURE__ */ jsx3(Text3, { color: "green", children: "\u25CF" }),
|
|
4717
4870
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " working " }),
|
|
4718
4871
|
/* @__PURE__ */ jsx3(Text3, { color: "yellow", children: "\u25C6" }),
|
|
4719
4872
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " needs input " }),
|
|
4873
|
+
/* @__PURE__ */ jsx3(Text3, { color: "cyan", children: "\u25C7" }),
|
|
4874
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " done " }),
|
|
4720
4875
|
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "\u25CB stopped]" })
|
|
4721
4876
|
] }),
|
|
4722
4877
|
syncing && /* @__PURE__ */ jsx3(Box3, { flexGrow: 1 }),
|
|
4723
4878
|
syncing && /* @__PURE__ */ jsx3(Text3, { color: "cyan", children: " syncing" })
|
|
4724
4879
|
] });
|
|
4880
|
+
});
|
|
4881
|
+
|
|
4882
|
+
// src/tui-ink/HelpOverlay.tsx
|
|
4883
|
+
import React4 from "react";
|
|
4884
|
+
import { Box as Box4, Text as Text4 } from "ink";
|
|
4885
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
4886
|
+
var HELP = [
|
|
4887
|
+
{ type: "section", label: "Navigation" },
|
|
4888
|
+
{ type: "key", keys: "tab", desc: "cycle pane focus" },
|
|
4889
|
+
{ type: "key", keys: "j/k or \u2191/\u2193", desc: "move cursor" },
|
|
4890
|
+
{ type: "key", keys: "ctrl+d / ctrl+u", desc: "half-page down / up" },
|
|
4891
|
+
{ type: "key", keys: "pgup / pgdn", desc: "page up / down" },
|
|
4892
|
+
{ type: "key", keys: "mouse", desc: "wheel scrolls, click focuses + selects" },
|
|
4893
|
+
{ type: "blank" },
|
|
4894
|
+
{ type: "section", label: "Worktrees pane" },
|
|
4895
|
+
{ type: "key", keys: "enter", desc: "start / show session" },
|
|
4896
|
+
{ type: "key", keys: "/", desc: "filter sessions (enter keeps, esc clears)" },
|
|
4897
|
+
{ type: "key", keys: "n", desc: "new worktree" },
|
|
4898
|
+
{ type: "key", keys: "d", desc: "remove worktree (press d again to confirm)" },
|
|
4899
|
+
{ type: "key", keys: ".", desc: "open in editor" },
|
|
4900
|
+
{ type: "key", keys: "u", desc: "rebase onto main" },
|
|
4901
|
+
{ type: "blank" },
|
|
4902
|
+
{ type: "section", label: "Pull Requests / Jira panes" },
|
|
4903
|
+
{ type: "key", keys: "enter", desc: "checkout PR / create worktree for issue" },
|
|
4904
|
+
{ type: "key", keys: "o", desc: "open in browser" },
|
|
4905
|
+
{ type: "blank" },
|
|
4906
|
+
{ type: "section", label: "Tasks pane" },
|
|
4907
|
+
{ type: "key", keys: "enter or x", desc: "toggle done" },
|
|
4908
|
+
{ type: "key", keys: "a / e / d", desc: "add / edit / remove task" },
|
|
4909
|
+
{ type: "key", keys: "w", desc: "create worktree from task" },
|
|
4910
|
+
{ type: "blank" },
|
|
4911
|
+
{ type: "section", label: "Terminal" },
|
|
4912
|
+
{ type: "key", keys: "ctrl+]", desc: "detach back to sidebar" },
|
|
4913
|
+
{ type: "key", keys: "pgup / pgdn", desc: "scroll history (typing resumes live)" },
|
|
4914
|
+
{ type: "blank" },
|
|
4915
|
+
{ type: "section", label: "Global" },
|
|
4916
|
+
{ type: "key", keys: "g / G", desc: "sync focused pane / sync everything" },
|
|
4917
|
+
{ type: "key", keys: "r", desc: "refresh all panes" },
|
|
4918
|
+
{ type: "key", keys: "?", desc: "toggle this help" },
|
|
4919
|
+
{ type: "key", keys: "q or ctrl+c", desc: "quit" }
|
|
4920
|
+
];
|
|
4921
|
+
var HelpOverlay = React4.memo(function HelpOverlay2({ width, height }) {
|
|
4922
|
+
const innerWidth = width - 2;
|
|
4923
|
+
const contentHeight = height - 2;
|
|
4924
|
+
const title = "Help \u2014 press ? or esc to close";
|
|
4925
|
+
const topBorder = "\u250C\u2500 " + title + " " + "\u2500".repeat(Math.max(0, innerWidth - title.length - 3)) + "\u2510";
|
|
4926
|
+
const rows = [];
|
|
4927
|
+
for (let i = 0; i < contentHeight; i++) {
|
|
4928
|
+
const line = HELP[i];
|
|
4929
|
+
if (!line || line.type === "blank") {
|
|
4930
|
+
rows.push(/* @__PURE__ */ jsx4(Text4, { children: " ".repeat(innerWidth) }, i));
|
|
4931
|
+
continue;
|
|
4932
|
+
}
|
|
4933
|
+
if (line.type === "section") {
|
|
4934
|
+
rows.push(
|
|
4935
|
+
/* @__PURE__ */ jsx4(Box4, { width: innerWidth, children: /* @__PURE__ */ jsx4(Text4, { color: "yellow", bold: true, children: " " + line.label }) }, i)
|
|
4936
|
+
);
|
|
4937
|
+
continue;
|
|
4938
|
+
}
|
|
4939
|
+
rows.push(
|
|
4940
|
+
/* @__PURE__ */ jsxs4(Box4, { width: innerWidth, children: [
|
|
4941
|
+
/* @__PURE__ */ jsx4(Text4, { color: "cyan", children: " " + line.keys.padEnd(18) }),
|
|
4942
|
+
/* @__PURE__ */ jsx4(Text4, { children: line.desc })
|
|
4943
|
+
] }, i)
|
|
4944
|
+
);
|
|
4945
|
+
}
|
|
4946
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", width, children: [
|
|
4947
|
+
/* @__PURE__ */ jsx4(Text4, { color: "cyan", children: topBorder }),
|
|
4948
|
+
rows.map((row, i) => /* @__PURE__ */ jsxs4(Box4, { children: [
|
|
4949
|
+
/* @__PURE__ */ jsx4(Text4, { color: "cyan", children: "\u2502" }),
|
|
4950
|
+
row,
|
|
4951
|
+
/* @__PURE__ */ jsx4(Text4, { color: "cyan", children: "\u2502" })
|
|
4952
|
+
] }, i)),
|
|
4953
|
+
/* @__PURE__ */ jsx4(Text4, { color: "cyan", children: "\u2514" + "\u2500".repeat(innerWidth) + "\u2518" })
|
|
4954
|
+
] });
|
|
4955
|
+
});
|
|
4956
|
+
|
|
4957
|
+
// src/tui-ink/line-editor.ts
|
|
4958
|
+
var KEYS = {
|
|
4959
|
+
UP: "\x1B[A",
|
|
4960
|
+
DOWN: "\x1B[B",
|
|
4961
|
+
RIGHT: "\x1B[C",
|
|
4962
|
+
LEFT: "\x1B[D",
|
|
4963
|
+
HOME: "\x1B[H",
|
|
4964
|
+
END: "\x1B[F",
|
|
4965
|
+
HOME_ALT: "\x1B[1~",
|
|
4966
|
+
END_ALT: "\x1B[4~",
|
|
4967
|
+
PAGE_UP: "\x1B[5~",
|
|
4968
|
+
PAGE_DOWN: "\x1B[6~",
|
|
4969
|
+
DELETE: "\x1B[3~",
|
|
4970
|
+
ESC: "\x1B",
|
|
4971
|
+
ENTER: "\r",
|
|
4972
|
+
BACKSPACE: "\x7F",
|
|
4973
|
+
BACKSPACE_ALT: "\b",
|
|
4974
|
+
CTRL_C: "",
|
|
4975
|
+
CTRL_D: "",
|
|
4976
|
+
CTRL_U: "",
|
|
4977
|
+
TAB: " "
|
|
4978
|
+
};
|
|
4979
|
+
function splitInputChunks(data) {
|
|
4980
|
+
const tokens = [];
|
|
4981
|
+
let i = 0;
|
|
4982
|
+
let run2 = "";
|
|
4983
|
+
const flushRun = () => {
|
|
4984
|
+
if (run2) {
|
|
4985
|
+
tokens.push(run2);
|
|
4986
|
+
run2 = "";
|
|
4987
|
+
}
|
|
4988
|
+
};
|
|
4989
|
+
while (i < data.length) {
|
|
4990
|
+
const ch = data[i];
|
|
4991
|
+
if (ch === "\x1B") {
|
|
4992
|
+
flushRun();
|
|
4993
|
+
const next = data[i + 1];
|
|
4994
|
+
if (next === "[") {
|
|
4995
|
+
let j = i + 2;
|
|
4996
|
+
while (j < data.length) {
|
|
4997
|
+
const code2 = data.charCodeAt(j);
|
|
4998
|
+
if (code2 >= 64 && code2 <= 126) break;
|
|
4999
|
+
j++;
|
|
5000
|
+
}
|
|
5001
|
+
tokens.push(data.slice(i, Math.min(j + 1, data.length)));
|
|
5002
|
+
i = j + 1;
|
|
5003
|
+
continue;
|
|
5004
|
+
}
|
|
5005
|
+
if (next === "O" && i + 2 < data.length) {
|
|
5006
|
+
tokens.push(data.slice(i, i + 3));
|
|
5007
|
+
i += 3;
|
|
5008
|
+
continue;
|
|
5009
|
+
}
|
|
5010
|
+
tokens.push("\x1B");
|
|
5011
|
+
i++;
|
|
5012
|
+
continue;
|
|
5013
|
+
}
|
|
5014
|
+
const code = data.charCodeAt(i);
|
|
5015
|
+
if (code < 32 || code === 127) {
|
|
5016
|
+
flushRun();
|
|
5017
|
+
tokens.push(ch);
|
|
5018
|
+
i++;
|
|
5019
|
+
continue;
|
|
5020
|
+
}
|
|
5021
|
+
run2 += ch;
|
|
5022
|
+
i++;
|
|
5023
|
+
}
|
|
5024
|
+
flushRun();
|
|
5025
|
+
return tokens;
|
|
5026
|
+
}
|
|
5027
|
+
function sanitizePaste(text) {
|
|
5028
|
+
const firstLine = text.split(/\r|\n/, 1)[0] ?? "";
|
|
5029
|
+
return firstLine.replace(/[\u0000-\u001f\u007f]/g, "");
|
|
5030
|
+
}
|
|
5031
|
+
function editLine(state, token) {
|
|
5032
|
+
const { value, pos } = state;
|
|
5033
|
+
switch (token) {
|
|
5034
|
+
case KEYS.ESC:
|
|
5035
|
+
case KEYS.CTRL_C:
|
|
5036
|
+
return { state, action: "cancel" };
|
|
5037
|
+
case KEYS.ENTER:
|
|
5038
|
+
return { state, action: "submit" };
|
|
5039
|
+
case KEYS.BACKSPACE:
|
|
5040
|
+
case KEYS.BACKSPACE_ALT:
|
|
5041
|
+
if (pos === 0) return { state, action: null };
|
|
5042
|
+
return {
|
|
5043
|
+
state: { value: value.slice(0, pos - 1) + value.slice(pos), pos: pos - 1 },
|
|
5044
|
+
action: null
|
|
5045
|
+
};
|
|
5046
|
+
case KEYS.DELETE:
|
|
5047
|
+
if (pos >= value.length) return { state, action: null };
|
|
5048
|
+
return {
|
|
5049
|
+
state: { value: value.slice(0, pos) + value.slice(pos + 1), pos },
|
|
5050
|
+
action: null
|
|
5051
|
+
};
|
|
5052
|
+
case KEYS.LEFT:
|
|
5053
|
+
return { state: { value, pos: Math.max(0, pos - 1) }, action: null };
|
|
5054
|
+
case KEYS.RIGHT:
|
|
5055
|
+
return { state: { value, pos: Math.min(value.length, pos + 1) }, action: null };
|
|
5056
|
+
case KEYS.HOME:
|
|
5057
|
+
case KEYS.HOME_ALT:
|
|
5058
|
+
return { state: { value, pos: 0 }, action: null };
|
|
5059
|
+
case KEYS.END:
|
|
5060
|
+
case KEYS.END_ALT:
|
|
5061
|
+
return { state: { value, pos: value.length }, action: null };
|
|
5062
|
+
case KEYS.CTRL_U:
|
|
5063
|
+
return { state: { value: value.slice(pos), pos: 0 }, action: null };
|
|
5064
|
+
}
|
|
5065
|
+
if (token.startsWith("\x1B") || token.charCodeAt(0) < 32 || token === "\x7F") {
|
|
5066
|
+
return { state, action: null };
|
|
5067
|
+
}
|
|
5068
|
+
const insert = sanitizePaste(token);
|
|
5069
|
+
if (!insert) return { state, action: null };
|
|
5070
|
+
return {
|
|
5071
|
+
state: { value: value.slice(0, pos) + insert + value.slice(pos), pos: pos + insert.length },
|
|
5072
|
+
action: null
|
|
5073
|
+
};
|
|
4725
5074
|
}
|
|
4726
5075
|
|
|
4727
5076
|
// src/tui-ink/App.tsx
|
|
4728
|
-
import { jsx as
|
|
5077
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
4729
5078
|
var DETACH_KEY = "";
|
|
4730
5079
|
var TAB_KEY = " ";
|
|
4731
5080
|
var RENDER_INTERVAL_MS = 50;
|
|
4732
5081
|
var MOUSE_SGR_RE = /\x1b\[<(\d+);(\d+);(\d+)[Mm]/;
|
|
4733
5082
|
function hasClaudeConversation(dir) {
|
|
4734
5083
|
try {
|
|
4735
|
-
const resolved =
|
|
4736
|
-
const projectDir = resolved.replace(/[
|
|
4737
|
-
const claudeProjectPath =
|
|
5084
|
+
const resolved = path18.resolve(dir);
|
|
5085
|
+
const projectDir = resolved.replace(/[^a-zA-Z0-9-]/g, "-");
|
|
5086
|
+
const claudeProjectPath = path18.join(os6.homedir(), ".claude", "projects", projectDir);
|
|
4738
5087
|
if (!fs23.existsSync(claudeProjectPath)) return false;
|
|
4739
5088
|
const files = fs23.readdirSync(claudeProjectPath);
|
|
4740
5089
|
return files.some((f) => f.endsWith(".jsonl"));
|
|
@@ -4743,7 +5092,7 @@ function hasClaudeConversation(dir) {
|
|
|
4743
5092
|
}
|
|
4744
5093
|
}
|
|
4745
5094
|
function ptyDedupKey(pty2) {
|
|
4746
|
-
return
|
|
5095
|
+
return path18.resolve(pty2.cwd).toLowerCase();
|
|
4747
5096
|
}
|
|
4748
5097
|
function loadSessions() {
|
|
4749
5098
|
const all = loadHistory();
|
|
@@ -4828,20 +5177,35 @@ function App({ unsafe, onExit }) {
|
|
|
4828
5177
|
const [pendingJiraIssue, setPendingJiraIssue] = useState(null);
|
|
4829
5178
|
const [pendingTask, setPendingTask] = useState(null);
|
|
4830
5179
|
const [savedSessionCursor, setSavedSessionCursor] = useState(0);
|
|
5180
|
+
const [showHelp2, setShowHelp] = useState(false);
|
|
5181
|
+
const [filter, setFilter] = useState(null);
|
|
5182
|
+
const [pendingRemoveKey, setPendingRemoveKey] = useState(null);
|
|
5183
|
+
const [termScroll, setTermScroll] = useState(0);
|
|
5184
|
+
const setScrollBack = useCallback((n) => {
|
|
5185
|
+
termScrollBack.current = n;
|
|
5186
|
+
setTermScroll(n);
|
|
5187
|
+
}, []);
|
|
4831
5188
|
const localBranches = useMemo(() => new Set(sessions.map((s) => s.branch)), [sessions]);
|
|
4832
5189
|
const projectRows = useMemo(() => buildProjectRows(projects), [projects]);
|
|
4833
5190
|
const prRows = useMemo(() => buildPrRows(prMap), [prMap]);
|
|
4834
5191
|
const jiraRows = useMemo(() => buildJiraRows(jiraIssues), [jiraIssues]);
|
|
4835
5192
|
const taskRows = useMemo(() => buildTaskRows(tasks), [tasks]);
|
|
5193
|
+
const filteredSessions = useMemo(() => {
|
|
5194
|
+
const q = filter?.value.trim().toLowerCase();
|
|
5195
|
+
if (!q) return sessions;
|
|
5196
|
+
return sessions.filter(
|
|
5197
|
+
(s) => s.branch.toLowerCase().includes(q) || s.target.toLowerCase().includes(q)
|
|
5198
|
+
);
|
|
5199
|
+
}, [sessions, filter]);
|
|
4836
5200
|
const ptySessions = useRef(/* @__PURE__ */ new Map());
|
|
4837
5201
|
const sessionRows = useMemo(() => {
|
|
4838
5202
|
const sMap = /* @__PURE__ */ new Map();
|
|
4839
5203
|
for (const [key, pty2] of ptySessions.current) {
|
|
4840
5204
|
if (pty2.exited) continue;
|
|
4841
|
-
sMap.set(key, pty2.
|
|
5205
|
+
sMap.set(key, pty2.status);
|
|
4842
5206
|
}
|
|
4843
|
-
return buildSessionRows(
|
|
4844
|
-
}, [
|
|
5207
|
+
return buildSessionRows(filteredSessions, sMap);
|
|
5208
|
+
}, [filteredSessions, statusVersion]);
|
|
4845
5209
|
const topRows = topPaneMode === 0 /* SESSIONS */ ? sessionRows : projectRows;
|
|
4846
5210
|
const renderPending = useRef(false);
|
|
4847
5211
|
const focusRef = useRef(focus);
|
|
@@ -4881,6 +5245,13 @@ function App({ unsafe, onExit }) {
|
|
|
4881
5245
|
prRowsRef.current = prRows;
|
|
4882
5246
|
const acliAvailableRef = useRef(acliAvailable);
|
|
4883
5247
|
acliAvailableRef.current = acliAvailable;
|
|
5248
|
+
const showHelpRef = useRef(showHelp2);
|
|
5249
|
+
showHelpRef.current = showHelp2;
|
|
5250
|
+
const filterRef = useRef(filter);
|
|
5251
|
+
filterRef.current = filter;
|
|
5252
|
+
const pendingRemoveRef = useRef(pendingRemoveKey);
|
|
5253
|
+
pendingRemoveRef.current = pendingRemoveKey;
|
|
5254
|
+
const rebasingRef = useRef(false);
|
|
4884
5255
|
const hookServerRef = useRef(null);
|
|
4885
5256
|
const notifiedSessionsRef = useRef(/* @__PURE__ */ new Set());
|
|
4886
5257
|
const [dims, setDims] = useState(() => ({
|
|
@@ -4897,16 +5268,21 @@ function App({ unsafe, onExit }) {
|
|
|
4897
5268
|
const taskPaneHeight = Math.max(5, Math.floor(contentHeight * 0.2));
|
|
4898
5269
|
const prPaneHeight = Math.max(5, Math.floor((contentHeight - jiraPaneHeight - taskPaneHeight) * 0.45));
|
|
4899
5270
|
const sessionPaneHeight = contentHeight - prPaneHeight - taskPaneHeight - jiraPaneHeight;
|
|
5271
|
+
const layoutRef = useRef({ sidebarWidth, termInner, contentHeight, sessionPaneHeight, prPaneHeight, jiraPaneHeight, taskPaneHeight });
|
|
5272
|
+
layoutRef.current = { sidebarWidth, termInner, contentHeight, sessionPaneHeight, prPaneHeight, jiraPaneHeight, taskPaneHeight };
|
|
4900
5273
|
useEffect(() => {
|
|
5274
|
+
let attentionCount = 0;
|
|
4901
5275
|
let idleCount = 0;
|
|
4902
5276
|
let runningCount = 0;
|
|
4903
5277
|
for (const pty2 of ptySessions.current.values()) {
|
|
4904
5278
|
if (pty2.exited) continue;
|
|
4905
|
-
if (pty2.
|
|
5279
|
+
if (pty2.status === "attention") attentionCount++;
|
|
5280
|
+
else if (pty2.status === "idle") idleCount++;
|
|
4906
5281
|
else runningCount++;
|
|
4907
5282
|
}
|
|
4908
5283
|
const parts = [];
|
|
4909
|
-
if (
|
|
5284
|
+
if (attentionCount > 0) parts.push(`\u{1F7E1} ${attentionCount}`);
|
|
5285
|
+
if (idleCount > 0) parts.push(`\u{1F535} ${idleCount}`);
|
|
4910
5286
|
if (runningCount > 0) parts.push(`\u{1F7E2} ${runningCount}`);
|
|
4911
5287
|
const title = parts.length > 0 ? parts.join(" ") : "work dash";
|
|
4912
5288
|
process.stdout.write(`\x1B]0;${title}\x07`);
|
|
@@ -4914,23 +5290,21 @@ function App({ unsafe, onExit }) {
|
|
|
4914
5290
|
const computeGeneration = useRef(0);
|
|
4915
5291
|
const computeConflictsAndMerged = useCallback((sessionList) => {
|
|
4916
5292
|
const generation = ++computeGeneration.current;
|
|
4917
|
-
const tick = () => new Promise((r) => setTimeout(r, 0));
|
|
4918
5293
|
(async () => {
|
|
4919
5294
|
const counts = /* @__PURE__ */ new Map();
|
|
4920
5295
|
const merged = /* @__PURE__ */ new Set();
|
|
4921
5296
|
for (const s of sessionList) {
|
|
4922
5297
|
if (computeGeneration.current !== generation) return;
|
|
4923
|
-
await tick();
|
|
4924
5298
|
const existing = s.paths.find((p) => fs23.existsSync(p));
|
|
4925
5299
|
if (!existing || !s.branch) continue;
|
|
4926
5300
|
const key = sessionKey2(s);
|
|
4927
5301
|
try {
|
|
4928
|
-
const c =
|
|
5302
|
+
const c = await countConflictsAsync(s.branch, existing);
|
|
4929
5303
|
if (c > 0) counts.set(key, c);
|
|
4930
5304
|
} catch {
|
|
4931
5305
|
}
|
|
4932
5306
|
try {
|
|
4933
|
-
const { merged: isMerged } =
|
|
5307
|
+
const { merged: isMerged } = await isBranchMergedAsync(s.branch, existing);
|
|
4934
5308
|
if (isMerged) merged.add(key);
|
|
4935
5309
|
} catch {
|
|
4936
5310
|
}
|
|
@@ -4942,10 +5316,10 @@ function App({ unsafe, onExit }) {
|
|
|
4942
5316
|
})();
|
|
4943
5317
|
}, []);
|
|
4944
5318
|
const refreshPrs = useCallback(() => {
|
|
4945
|
-
if (!ghAvailable || !config || prFetching.current) return;
|
|
5319
|
+
if (!ghAvailable || !config || prFetching.current) return Promise.resolve();
|
|
4946
5320
|
prFetching.current = true;
|
|
4947
5321
|
setMessage("Loading PRs...");
|
|
4948
|
-
fetchAllPullRequests(config.repos).then((prs) => {
|
|
5322
|
+
return fetchAllPullRequests(config.repos).then((prs) => {
|
|
4949
5323
|
setPrMap(prs);
|
|
4950
5324
|
setMessage("");
|
|
4951
5325
|
}).catch(() => {
|
|
@@ -4954,9 +5328,9 @@ function App({ unsafe, onExit }) {
|
|
|
4954
5328
|
});
|
|
4955
5329
|
}, [ghAvailable, config]);
|
|
4956
5330
|
const refreshJira = useCallback(() => {
|
|
4957
|
-
if (!acliAvailable || jiraFetching.current) return;
|
|
5331
|
+
if (!acliAvailable || jiraFetching.current) return Promise.resolve();
|
|
4958
5332
|
jiraFetching.current = true;
|
|
4959
|
-
fetchMyJiraIssues().then((issues) => setJiraIssues(issues)).catch(() => {
|
|
5333
|
+
return fetchMyJiraIssues().then((issues) => setJiraIssues(issues)).catch(() => {
|
|
4960
5334
|
}).finally(() => {
|
|
4961
5335
|
jiraFetching.current = false;
|
|
4962
5336
|
});
|
|
@@ -4969,11 +5343,11 @@ function App({ unsafe, onExit }) {
|
|
|
4969
5343
|
setSessions(updated);
|
|
4970
5344
|
computeConflictsAndMerged(updated);
|
|
4971
5345
|
}, [computeConflictsAndMerged]);
|
|
4972
|
-
const
|
|
5346
|
+
const statusMap = useMemo(() => {
|
|
4973
5347
|
const map = /* @__PURE__ */ new Map();
|
|
4974
5348
|
for (const [key, pty2] of ptySessions.current) {
|
|
4975
5349
|
if (pty2.exited) continue;
|
|
4976
|
-
map.set(key, pty2.
|
|
5350
|
+
map.set(key, pty2.status);
|
|
4977
5351
|
}
|
|
4978
5352
|
return map;
|
|
4979
5353
|
}, [statusVersion]);
|
|
@@ -4983,6 +5357,8 @@ function App({ unsafe, onExit }) {
|
|
|
4983
5357
|
setTimeout(() => {
|
|
4984
5358
|
renderPending.current = false;
|
|
4985
5359
|
try {
|
|
5360
|
+
const activeKey2 = activeKeyRef.current;
|
|
5361
|
+
if (!activeKey2 || ptySessions.current.get(activeKey2) !== pty2) return;
|
|
4986
5362
|
if (termScrollBack.current > 0) return;
|
|
4987
5363
|
const lines = renderBufferLines(pty2.terminal.buffer.active, termInner, contentHeight - 2);
|
|
4988
5364
|
setTermLines(lines);
|
|
@@ -4999,11 +5375,21 @@ function App({ unsafe, onExit }) {
|
|
|
4999
5375
|
} catch {
|
|
5000
5376
|
}
|
|
5001
5377
|
}, [termInner, contentHeight]);
|
|
5378
|
+
const scrollTerminal = useCallback((linesUp) => {
|
|
5379
|
+
const pty2 = activeKeyRef.current ? ptySessions.current.get(activeKeyRef.current) : void 0;
|
|
5380
|
+
if (!pty2 || pty2.exited) return;
|
|
5381
|
+
const maxScroll = pty2.terminal.buffer.active.baseY;
|
|
5382
|
+
const next = Math.max(0, Math.min(maxScroll, termScrollBack.current + linesUp));
|
|
5383
|
+
if (next !== termScrollBack.current) {
|
|
5384
|
+
setScrollBack(next);
|
|
5385
|
+
renderTermAtScroll();
|
|
5386
|
+
}
|
|
5387
|
+
}, [setScrollBack, renderTermAtScroll]);
|
|
5002
5388
|
const findPtyByCwd = useCallback((cwd) => {
|
|
5003
|
-
const normalized =
|
|
5389
|
+
const normalized = path18.resolve(cwd).toLowerCase();
|
|
5004
5390
|
for (const pty2 of ptySessions.current.values()) {
|
|
5005
5391
|
if (pty2.exited) continue;
|
|
5006
|
-
if (normalized.startsWith(
|
|
5392
|
+
if (normalized.startsWith(path18.resolve(pty2.cwd).toLowerCase())) return pty2;
|
|
5007
5393
|
}
|
|
5008
5394
|
return void 0;
|
|
5009
5395
|
}, []);
|
|
@@ -5065,10 +5451,12 @@ function App({ unsafe, onExit }) {
|
|
|
5065
5451
|
callback: (cwd, event) => {
|
|
5066
5452
|
const pty2 = findPtyByCwd(cwd);
|
|
5067
5453
|
if (!pty2) return;
|
|
5068
|
-
if (event === "
|
|
5069
|
-
pty2.
|
|
5454
|
+
if (event === "notification") {
|
|
5455
|
+
pty2.setStatus("attention");
|
|
5456
|
+
} else if (event === "stop") {
|
|
5457
|
+
pty2.setStatus("idle");
|
|
5070
5458
|
} else if (event === "prompt_submit") {
|
|
5071
|
-
pty2.
|
|
5459
|
+
pty2.setStatus("running");
|
|
5072
5460
|
}
|
|
5073
5461
|
const dedupKey = ptyDedupKey(pty2);
|
|
5074
5462
|
const kind = notifyKindForEvent(
|
|
@@ -5077,13 +5465,13 @@ function App({ unsafe, onExit }) {
|
|
|
5077
5465
|
notifiedSessionsRef.current
|
|
5078
5466
|
);
|
|
5079
5467
|
if (kind) {
|
|
5080
|
-
notifyDesktop(
|
|
5468
|
+
notifyDesktop(path18.basename(pty2.cwd), kind, {
|
|
5081
5469
|
enabled: config?.notifications === true
|
|
5082
5470
|
});
|
|
5083
5471
|
runStatusHooks(
|
|
5084
5472
|
kind,
|
|
5085
5473
|
pty2.cwd,
|
|
5086
|
-
|
|
5474
|
+
path18.basename(pty2.cwd),
|
|
5087
5475
|
config?.statusHooks
|
|
5088
5476
|
);
|
|
5089
5477
|
}
|
|
@@ -5129,7 +5517,7 @@ function App({ unsafe, onExit }) {
|
|
|
5129
5517
|
const switchDisplay = useCallback((s) => {
|
|
5130
5518
|
const k = sessionKey2(s);
|
|
5131
5519
|
if (activeKeyRef.current === k) return;
|
|
5132
|
-
|
|
5520
|
+
setScrollBack(0);
|
|
5133
5521
|
if (activeKeyRef.current) {
|
|
5134
5522
|
ptySessions.current.get(activeKeyRef.current)?.setOutputHandler(void 0);
|
|
5135
5523
|
}
|
|
@@ -5180,6 +5568,7 @@ function App({ unsafe, onExit }) {
|
|
|
5180
5568
|
if (activeKeyRef.current && activeKeyRef.current !== key) {
|
|
5181
5569
|
ptySessions.current.get(activeKeyRef.current)?.setOutputHandler(void 0);
|
|
5182
5570
|
}
|
|
5571
|
+
setScrollBack(0);
|
|
5183
5572
|
setActiveKey(key);
|
|
5184
5573
|
setFocus(4 /* TERMINAL */);
|
|
5185
5574
|
pty2.resize(termInner, contentHeight - 2);
|
|
@@ -5215,7 +5604,7 @@ function App({ unsafe, onExit }) {
|
|
|
5215
5604
|
refreshSessions();
|
|
5216
5605
|
return;
|
|
5217
5606
|
}
|
|
5218
|
-
const dir = s.isGroup ?
|
|
5607
|
+
const dir = s.isGroup ? path18.dirname(existing) : existing;
|
|
5219
5608
|
const resume = hasClaudeConversation(dir);
|
|
5220
5609
|
const tool = getAiTool(config ?? {});
|
|
5221
5610
|
const pty2 = new PtySession(dir, termInner, contentHeight - 2, void 0, { tool, unsafe, resume, port: s.port });
|
|
@@ -5313,7 +5702,7 @@ function App({ unsafe, onExit }) {
|
|
|
5313
5702
|
"",
|
|
5314
5703
|
" - Ask if I want to proceed with the recommended approach, choose a different one, get more details, or make adjustments."
|
|
5315
5704
|
].join("\n");
|
|
5316
|
-
promptFile =
|
|
5705
|
+
promptFile = path18.join(os6.tmpdir(), `work-prompt-${Date.now()}.txt`);
|
|
5317
5706
|
fs23.writeFileSync(promptFile, prompt, "utf-8");
|
|
5318
5707
|
}
|
|
5319
5708
|
const setupArgs = ["tree", projectName, branchName, "--setup-only"];
|
|
@@ -5353,7 +5742,7 @@ function App({ unsafe, onExit }) {
|
|
|
5353
5742
|
setStatusVersion((v) => v + 1);
|
|
5354
5743
|
return;
|
|
5355
5744
|
}
|
|
5356
|
-
const launchDir = session.isGroup ?
|
|
5745
|
+
const launchDir = session.isGroup ? path18.dirname(existing) : existing;
|
|
5357
5746
|
const tool = getAiTool(config);
|
|
5358
5747
|
const aiPty = new PtySession(
|
|
5359
5748
|
launchDir,
|
|
@@ -5370,8 +5759,8 @@ function App({ unsafe, onExit }) {
|
|
|
5370
5759
|
connectPty(key, setupPty);
|
|
5371
5760
|
}, [unsafe, termInner, contentHeight, refreshSessions, connectPty, registerPty, savedSessionCursor, config]);
|
|
5372
5761
|
useEffect(() => {
|
|
5373
|
-
const
|
|
5374
|
-
const
|
|
5762
|
+
const handleKey = (key) => {
|
|
5763
|
+
const layout = layoutRef.current;
|
|
5375
5764
|
const mouseMatch = MOUSE_SGR_RE.exec(key);
|
|
5376
5765
|
if (mouseMatch) {
|
|
5377
5766
|
const button = parseInt(mouseMatch[1], 10);
|
|
@@ -5379,48 +5768,52 @@ function App({ unsafe, onExit }) {
|
|
|
5379
5768
|
const row = parseInt(mouseMatch[3], 10);
|
|
5380
5769
|
if (button === 64 || button === 65) {
|
|
5381
5770
|
const delta = button === 64 ? -1 : 1;
|
|
5382
|
-
if (col <= sidebarWidth) {
|
|
5383
|
-
if (row <= sessionPaneHeight) {
|
|
5771
|
+
if (col <= layout.sidebarWidth) {
|
|
5772
|
+
if (row <= layout.sessionPaneHeight) {
|
|
5384
5773
|
moveSessionCursor(delta);
|
|
5385
|
-
} else if (row <= sessionPaneHeight + prPaneHeight) {
|
|
5774
|
+
} else if (row <= layout.sessionPaneHeight + layout.prPaneHeight) {
|
|
5386
5775
|
movePrCursor(delta);
|
|
5387
|
-
} else if (jiraPaneHeight > 0 && row <= sessionPaneHeight + prPaneHeight + jiraPaneHeight) {
|
|
5776
|
+
} else if (layout.jiraPaneHeight > 0 && row <= layout.sessionPaneHeight + layout.prPaneHeight + layout.jiraPaneHeight) {
|
|
5388
5777
|
moveJiraCursor(delta);
|
|
5389
5778
|
} else {
|
|
5390
5779
|
moveTaskCursor(delta);
|
|
5391
5780
|
}
|
|
5392
5781
|
} else {
|
|
5393
|
-
|
|
5394
|
-
if (pty2 && !pty2.exited) {
|
|
5395
|
-
const maxScroll = pty2.terminal.buffer.active.baseY;
|
|
5396
|
-
const newScroll = Math.max(0, Math.min(maxScroll, termScrollBack.current - delta * 3));
|
|
5397
|
-
if (newScroll !== termScrollBack.current) {
|
|
5398
|
-
termScrollBack.current = newScroll;
|
|
5399
|
-
renderTermAtScroll();
|
|
5400
|
-
}
|
|
5401
|
-
}
|
|
5782
|
+
scrollTerminal(-delta * 3);
|
|
5402
5783
|
}
|
|
5403
5784
|
return;
|
|
5404
5785
|
}
|
|
5405
5786
|
if (button === 0) {
|
|
5406
|
-
if (col <= sidebarWidth) {
|
|
5407
|
-
if (row <= sessionPaneHeight) {
|
|
5787
|
+
if (col <= layout.sidebarWidth) {
|
|
5788
|
+
if (row <= layout.sessionPaneHeight) {
|
|
5408
5789
|
setFocus(0 /* SESSIONS */);
|
|
5409
5790
|
const visualIdx = row - 2;
|
|
5410
|
-
if (visualIdx >= 0)
|
|
5411
|
-
|
|
5791
|
+
if (visualIdx >= 0) {
|
|
5792
|
+
const offset = computeScrollOffset(topRowsRef.current, sessionCursorRef.current, layout.sessionPaneHeight - 2);
|
|
5793
|
+
setSessionCursor(visualRowToCursor(topRowsRef.current, visualIdx + offset));
|
|
5794
|
+
}
|
|
5795
|
+
} else if (row <= layout.sessionPaneHeight + layout.prPaneHeight) {
|
|
5412
5796
|
setFocus(2 /* PRS */);
|
|
5413
|
-
const visualIdx = row - sessionPaneHeight - 2;
|
|
5414
|
-
if (visualIdx >= 0)
|
|
5415
|
-
|
|
5797
|
+
const visualIdx = row - layout.sessionPaneHeight - 2;
|
|
5798
|
+
if (visualIdx >= 0) {
|
|
5799
|
+
const offset = computeScrollOffset(prRowsRef.current, prCursorRef.current, layout.prPaneHeight - 2);
|
|
5800
|
+
setPrCursor(visualRowToCursor(prRowsRef.current, visualIdx + offset));
|
|
5801
|
+
}
|
|
5802
|
+
} else if (layout.jiraPaneHeight > 0 && row <= layout.sessionPaneHeight + layout.prPaneHeight + layout.jiraPaneHeight) {
|
|
5416
5803
|
setFocus(3 /* JIRA */);
|
|
5417
|
-
const visualIdx = row - sessionPaneHeight - prPaneHeight - 2;
|
|
5418
|
-
if (visualIdx >= 0)
|
|
5804
|
+
const visualIdx = row - layout.sessionPaneHeight - layout.prPaneHeight - 2;
|
|
5805
|
+
if (visualIdx >= 0) {
|
|
5806
|
+
const offset = computeScrollOffset(jiraRowsRef.current, jiraCursorRef.current, layout.jiraPaneHeight - 2);
|
|
5807
|
+
setJiraCursor(visualRowToCursor(jiraRowsRef.current, visualIdx + offset));
|
|
5808
|
+
}
|
|
5419
5809
|
} else {
|
|
5420
5810
|
setFocus(1 /* TASKS */);
|
|
5421
|
-
const taskStart = sessionPaneHeight + prPaneHeight + jiraPaneHeight;
|
|
5811
|
+
const taskStart = layout.sessionPaneHeight + layout.prPaneHeight + layout.jiraPaneHeight;
|
|
5422
5812
|
const visualIdx = row - taskStart - 2;
|
|
5423
|
-
if (visualIdx >= 0)
|
|
5813
|
+
if (visualIdx >= 0) {
|
|
5814
|
+
const offset = computeScrollOffset(taskRowsRef.current, taskCursorRef.current, layout.taskPaneHeight - 2);
|
|
5815
|
+
setTaskCursor(visualRowToCursor(taskRowsRef.current, visualIdx + offset));
|
|
5816
|
+
}
|
|
5424
5817
|
}
|
|
5425
5818
|
} else {
|
|
5426
5819
|
const activePty = activeKeyRef.current ? ptySessions.current.get(activeKeyRef.current) : void 0;
|
|
@@ -5431,18 +5824,25 @@ function App({ unsafe, onExit }) {
|
|
|
5431
5824
|
}
|
|
5432
5825
|
return;
|
|
5433
5826
|
}
|
|
5827
|
+
if (showHelpRef.current) {
|
|
5828
|
+
if (key === "?" || key === KEYS.ESC || key === "q" || key === KEYS.CTRL_C) {
|
|
5829
|
+
setShowHelp(false);
|
|
5830
|
+
}
|
|
5831
|
+
return;
|
|
5832
|
+
}
|
|
5434
5833
|
if (branchInputRef.current) {
|
|
5435
|
-
|
|
5834
|
+
const { projectName, isGroup, value, pos } = branchInputRef.current;
|
|
5835
|
+
const { state, action } = editLine({ value, pos }, key);
|
|
5836
|
+
if (action === "cancel") {
|
|
5436
5837
|
setBranchInput(null);
|
|
5437
5838
|
setTopPaneMode(1 /* PROJECTS */);
|
|
5438
5839
|
setMessage("Esc to go back");
|
|
5439
5840
|
return;
|
|
5440
5841
|
}
|
|
5441
|
-
if (
|
|
5442
|
-
const { projectName, value, isGroup } = branchInputRef.current;
|
|
5842
|
+
if (action === "submit") {
|
|
5443
5843
|
setBranchInput(null);
|
|
5444
|
-
if (value.trim()) {
|
|
5445
|
-
handleCreateWorktree(projectName, value.trim());
|
|
5844
|
+
if (state.value.trim()) {
|
|
5845
|
+
handleCreateWorktree(projectName, state.value.trim());
|
|
5446
5846
|
} else if (!isGroup) {
|
|
5447
5847
|
handleLaunchBaseRepo(projectName);
|
|
5448
5848
|
} else {
|
|
@@ -5450,12 +5850,36 @@ function App({ unsafe, onExit }) {
|
|
|
5450
5850
|
}
|
|
5451
5851
|
return;
|
|
5452
5852
|
}
|
|
5453
|
-
|
|
5454
|
-
|
|
5853
|
+
setBranchInput({ projectName, isGroup, ...state });
|
|
5854
|
+
return;
|
|
5855
|
+
}
|
|
5856
|
+
if (filterRef.current?.editing) {
|
|
5857
|
+
if (key === KEYS.UP) {
|
|
5858
|
+
moveSessionCursor(-1);
|
|
5859
|
+
return;
|
|
5860
|
+
}
|
|
5861
|
+
if (key === KEYS.DOWN) {
|
|
5862
|
+
moveSessionCursor(1);
|
|
5863
|
+
return;
|
|
5864
|
+
}
|
|
5865
|
+
const current = filterRef.current.value;
|
|
5866
|
+
const { state, action } = editLine({ value: current, pos: current.length }, key);
|
|
5867
|
+
if (action === "cancel") {
|
|
5868
|
+
setFilter(null);
|
|
5869
|
+
setSessionCursor(0);
|
|
5870
|
+
setMessage("");
|
|
5455
5871
|
return;
|
|
5456
5872
|
}
|
|
5457
|
-
if (key
|
|
5458
|
-
|
|
5873
|
+
if (action === "submit" || key === TAB_KEY) {
|
|
5874
|
+
const value = current.trim();
|
|
5875
|
+
setFilter(value ? { value, editing: false } : null);
|
|
5876
|
+
setMessage(value ? `Filtering: ${value} (esc clears)` : "");
|
|
5877
|
+
return;
|
|
5878
|
+
}
|
|
5879
|
+
if (state.value !== current) {
|
|
5880
|
+
setFilter({ value: state.value, editing: true });
|
|
5881
|
+
setSessionCursor(0);
|
|
5882
|
+
}
|
|
5459
5883
|
return;
|
|
5460
5884
|
}
|
|
5461
5885
|
if (key === TAB_KEY) {
|
|
@@ -5488,11 +5912,24 @@ function App({ unsafe, onExit }) {
|
|
|
5488
5912
|
setMessage("");
|
|
5489
5913
|
return;
|
|
5490
5914
|
}
|
|
5491
|
-
|
|
5915
|
+
if (key === KEYS.PAGE_UP) {
|
|
5916
|
+
scrollTerminal(Math.max(1, layout.contentHeight - 3));
|
|
5917
|
+
return;
|
|
5918
|
+
}
|
|
5919
|
+
if (key === KEYS.PAGE_DOWN) {
|
|
5920
|
+
scrollTerminal(-Math.max(1, layout.contentHeight - 3));
|
|
5921
|
+
return;
|
|
5922
|
+
}
|
|
5923
|
+
if (termScrollBack.current > 0) setScrollBack(0);
|
|
5492
5924
|
ptySessions.current.get(activeKeyRef.current)?.write(key);
|
|
5493
5925
|
return;
|
|
5494
5926
|
}
|
|
5495
5927
|
setMessage("");
|
|
5928
|
+
if (pendingRemoveRef.current && key !== "d") setPendingRemoveKey(null);
|
|
5929
|
+
if (key === "?") {
|
|
5930
|
+
setShowHelp(true);
|
|
5931
|
+
return;
|
|
5932
|
+
}
|
|
5496
5933
|
if (key === "G") {
|
|
5497
5934
|
if (syncing) return;
|
|
5498
5935
|
setSyncing(true);
|
|
@@ -5507,8 +5944,7 @@ function App({ unsafe, onExit }) {
|
|
|
5507
5944
|
);
|
|
5508
5945
|
}
|
|
5509
5946
|
refreshSessions();
|
|
5510
|
-
refreshPrs();
|
|
5511
|
-
refreshJira();
|
|
5947
|
+
await Promise.all([refreshPrs(), refreshJira()]);
|
|
5512
5948
|
refreshTasks();
|
|
5513
5949
|
computeConflictsAndMerged(sessionsRef.current);
|
|
5514
5950
|
setSyncing(false);
|
|
@@ -5516,6 +5952,33 @@ function App({ unsafe, onExit }) {
|
|
|
5516
5952
|
})();
|
|
5517
5953
|
return;
|
|
5518
5954
|
}
|
|
5955
|
+
if (taskInputRef.current === null) {
|
|
5956
|
+
const pageJump = (dir, full) => {
|
|
5957
|
+
const heightFor = focusRef.current === 2 /* PRS */ ? layout.prPaneHeight : focusRef.current === 3 /* JIRA */ ? layout.jiraPaneHeight : focusRef.current === 1 /* TASKS */ ? layout.taskPaneHeight : layout.sessionPaneHeight;
|
|
5958
|
+
const page = Math.max(1, full ? heightFor - 2 : Math.floor((heightFor - 2) / 2));
|
|
5959
|
+
const delta = page * dir;
|
|
5960
|
+
if (focusRef.current === 2 /* PRS */) movePrCursor(delta);
|
|
5961
|
+
else if (focusRef.current === 3 /* JIRA */) moveJiraCursor(delta);
|
|
5962
|
+
else if (focusRef.current === 1 /* TASKS */) moveTaskCursor(delta);
|
|
5963
|
+
else moveSessionCursor(delta);
|
|
5964
|
+
};
|
|
5965
|
+
if (key === KEYS.PAGE_UP) {
|
|
5966
|
+
pageJump(-1, true);
|
|
5967
|
+
return;
|
|
5968
|
+
}
|
|
5969
|
+
if (key === KEYS.PAGE_DOWN) {
|
|
5970
|
+
pageJump(1, true);
|
|
5971
|
+
return;
|
|
5972
|
+
}
|
|
5973
|
+
if (key === KEYS.CTRL_U) {
|
|
5974
|
+
pageJump(-1, false);
|
|
5975
|
+
return;
|
|
5976
|
+
}
|
|
5977
|
+
if (key === KEYS.CTRL_D) {
|
|
5978
|
+
pageJump(1, false);
|
|
5979
|
+
return;
|
|
5980
|
+
}
|
|
5981
|
+
}
|
|
5519
5982
|
if (topPaneModeRef.current === 1 /* PROJECTS */) {
|
|
5520
5983
|
if (key === "\x1B" || key === "" || key === "q") {
|
|
5521
5984
|
setTopPaneMode(0 /* SESSIONS */);
|
|
@@ -5560,7 +6023,7 @@ function App({ unsafe, onExit }) {
|
|
|
5560
6023
|
handleCreateWorktree(row.name, branch);
|
|
5561
6024
|
} else {
|
|
5562
6025
|
setTopPaneMode(2 /* BRANCH_INPUT */);
|
|
5563
|
-
setBranchInput({ projectName: row.name, value: "", isGroup: row.isGroup });
|
|
6026
|
+
setBranchInput({ projectName: row.name, value: "", pos: 0, isGroup: row.isGroup });
|
|
5564
6027
|
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");
|
|
5565
6028
|
}
|
|
5566
6029
|
}
|
|
@@ -5570,14 +6033,15 @@ function App({ unsafe, onExit }) {
|
|
|
5570
6033
|
}
|
|
5571
6034
|
if (focusRef.current === 1 /* TASKS */) {
|
|
5572
6035
|
if (taskInputRef.current !== null) {
|
|
5573
|
-
|
|
6036
|
+
const { state, action } = editLine(taskInputRef.current, key);
|
|
6037
|
+
if (action === "cancel") {
|
|
5574
6038
|
setTaskInput(null);
|
|
5575
6039
|
setTaskEditId(null);
|
|
5576
6040
|
setMessage("");
|
|
5577
6041
|
return;
|
|
5578
6042
|
}
|
|
5579
|
-
if (
|
|
5580
|
-
const text = taskInputRef.current.trim();
|
|
6043
|
+
if (action === "submit") {
|
|
6044
|
+
const text = taskInputRef.current.value.trim();
|
|
5581
6045
|
const editId = taskEditIdRef.current;
|
|
5582
6046
|
setTaskInput(null);
|
|
5583
6047
|
setTaskEditId(null);
|
|
@@ -5592,12 +6056,7 @@ function App({ unsafe, onExit }) {
|
|
|
5592
6056
|
}
|
|
5593
6057
|
return;
|
|
5594
6058
|
}
|
|
5595
|
-
|
|
5596
|
-
setTaskInput((prev) => prev !== null ? prev.slice(0, -1) : null);
|
|
5597
|
-
return;
|
|
5598
|
-
}
|
|
5599
|
-
if (key.charCodeAt(0) < 32) return;
|
|
5600
|
-
setTaskInput((prev) => prev !== null ? prev + key : null);
|
|
6059
|
+
setTaskInput(state);
|
|
5601
6060
|
return;
|
|
5602
6061
|
}
|
|
5603
6062
|
if (key === "\x1B[A" || key === "k") {
|
|
@@ -5617,7 +6076,7 @@ function App({ unsafe, onExit }) {
|
|
|
5617
6076
|
return;
|
|
5618
6077
|
}
|
|
5619
6078
|
if (key === "a") {
|
|
5620
|
-
setTaskInput("");
|
|
6079
|
+
setTaskInput({ value: "", pos: 0 });
|
|
5621
6080
|
setMessage("Type task, Enter to add, Esc to cancel");
|
|
5622
6081
|
return;
|
|
5623
6082
|
}
|
|
@@ -5625,7 +6084,7 @@ function App({ unsafe, onExit }) {
|
|
|
5625
6084
|
const row = cursorToRow(taskRowsRef.current, taskCursorRef.current);
|
|
5626
6085
|
if (row?.type === "task") {
|
|
5627
6086
|
setTaskEditId(row.task.id);
|
|
5628
|
-
setTaskInput(row.task.text);
|
|
6087
|
+
setTaskInput({ value: row.task.text, pos: row.task.text.length });
|
|
5629
6088
|
setMessage("Edit task, Enter to save, Esc to cancel");
|
|
5630
6089
|
}
|
|
5631
6090
|
return;
|
|
@@ -5781,6 +6240,16 @@ function App({ unsafe, onExit }) {
|
|
|
5781
6240
|
onExit();
|
|
5782
6241
|
return;
|
|
5783
6242
|
}
|
|
6243
|
+
if (key === KEYS.ESC && filterRef.current) {
|
|
6244
|
+
setFilter(null);
|
|
6245
|
+
setSessionCursor(0);
|
|
6246
|
+
return;
|
|
6247
|
+
}
|
|
6248
|
+
if (key === "/" && topPaneModeRef.current === 0 /* SESSIONS */) {
|
|
6249
|
+
setFilter({ value: filterRef.current?.value ?? "", editing: true });
|
|
6250
|
+
setMessage("Type to filter, Enter to keep, Esc to clear");
|
|
6251
|
+
return;
|
|
6252
|
+
}
|
|
5784
6253
|
if (key === "\x1B[A" || key === "k") {
|
|
5785
6254
|
moveSessionCursor(-1);
|
|
5786
6255
|
return;
|
|
@@ -5801,6 +6270,12 @@ function App({ unsafe, onExit }) {
|
|
|
5801
6270
|
if (row?.type !== "session") return;
|
|
5802
6271
|
const s = row.session;
|
|
5803
6272
|
const k = sessionKey2(s);
|
|
6273
|
+
if (pendingRemoveRef.current !== k) {
|
|
6274
|
+
setPendingRemoveKey(k);
|
|
6275
|
+
setMessage(`Remove ${s.target}/${s.branch}? Press d again to confirm, any other key cancels`);
|
|
6276
|
+
return;
|
|
6277
|
+
}
|
|
6278
|
+
setPendingRemoveKey(null);
|
|
5804
6279
|
const pty2 = ptySessions.current.get(k);
|
|
5805
6280
|
if (pty2) {
|
|
5806
6281
|
notifiedSessionsRef.current.delete(ptyDedupKey(pty2));
|
|
@@ -5842,7 +6317,7 @@ function App({ unsafe, onExit }) {
|
|
|
5842
6317
|
setMessage("Session path no longer exists");
|
|
5843
6318
|
return;
|
|
5844
6319
|
}
|
|
5845
|
-
const dir = s.isGroup ?
|
|
6320
|
+
const dir = s.isGroup ? path18.dirname(existing) : existing;
|
|
5846
6321
|
const editor = config?.editor ?? "code";
|
|
5847
6322
|
spawn7(editor, [dir], { detached: true, stdio: "ignore" }).unref();
|
|
5848
6323
|
setMessage(`Opened in ${editor}: ${s.branch}`);
|
|
@@ -5857,14 +6332,22 @@ function App({ unsafe, onExit }) {
|
|
|
5857
6332
|
setMessage("Session path no longer exists");
|
|
5858
6333
|
return;
|
|
5859
6334
|
}
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
setMessage(`Rebase failed: ${err}`);
|
|
5864
|
-
} else {
|
|
5865
|
-
setMessage(`Rebased ${s.branch} onto main`);
|
|
5866
|
-
computeConflictsAndMerged(sessionsRef.current);
|
|
6335
|
+
if (rebasingRef.current) {
|
|
6336
|
+
setMessage("A rebase is already running");
|
|
6337
|
+
return;
|
|
5867
6338
|
}
|
|
6339
|
+
rebasingRef.current = true;
|
|
6340
|
+
setMessage(`Rebasing ${s.branch}...`);
|
|
6341
|
+
void rebaseOntoMainAsync(s.branch, existing).then((err) => {
|
|
6342
|
+
if (err) {
|
|
6343
|
+
setMessage(`Rebase failed: ${err}`);
|
|
6344
|
+
} else {
|
|
6345
|
+
setMessage(`Rebased ${s.branch} onto main`);
|
|
6346
|
+
computeConflictsAndMerged(sessionsRef.current);
|
|
6347
|
+
}
|
|
6348
|
+
}).catch((e) => setMessage(`Rebase failed: ${e.message}`)).finally(() => {
|
|
6349
|
+
rebasingRef.current = false;
|
|
6350
|
+
});
|
|
5868
6351
|
return;
|
|
5869
6352
|
}
|
|
5870
6353
|
if (key === "g") {
|
|
@@ -5881,7 +6364,7 @@ function App({ unsafe, onExit }) {
|
|
|
5881
6364
|
);
|
|
5882
6365
|
}
|
|
5883
6366
|
refreshSessions();
|
|
5884
|
-
refreshPrs();
|
|
6367
|
+
await refreshPrs();
|
|
5885
6368
|
computeConflictsAndMerged(sessionsRef.current);
|
|
5886
6369
|
setSyncing(false);
|
|
5887
6370
|
setMessage("Sessions synced");
|
|
@@ -5890,18 +6373,23 @@ function App({ unsafe, onExit }) {
|
|
|
5890
6373
|
}
|
|
5891
6374
|
if (key === "r") {
|
|
5892
6375
|
refreshSessions();
|
|
5893
|
-
refreshPrs();
|
|
5894
|
-
refreshJira();
|
|
6376
|
+
void refreshPrs();
|
|
6377
|
+
void refreshJira();
|
|
5895
6378
|
refreshTasks();
|
|
5896
6379
|
if (!ghAvailable) setMessage("Refreshed");
|
|
5897
6380
|
return;
|
|
5898
6381
|
}
|
|
5899
6382
|
};
|
|
6383
|
+
const handler = (data) => {
|
|
6384
|
+
for (const key of splitInputChunks(data.toString("utf8"))) {
|
|
6385
|
+
handleKey(key);
|
|
6386
|
+
}
|
|
6387
|
+
};
|
|
5900
6388
|
process.stdin.on("data", handler);
|
|
5901
6389
|
return () => {
|
|
5902
6390
|
process.stdin.removeListener("data", handler);
|
|
5903
6391
|
};
|
|
5904
|
-
}, [onExit, activateSession, refreshSessions, refreshPrs, refreshJira, refreshTasks, moveSessionCursor, movePrCursor, moveJiraCursor, moveTaskCursor, syncSessionCursorToActive, handleCreateWorktree, savedSessionCursor, config, computeConflictsAndMerged, syncing, ghAvailable, prMap]);
|
|
6392
|
+
}, [onExit, activateSession, refreshSessions, refreshPrs, refreshJira, refreshTasks, moveSessionCursor, movePrCursor, moveJiraCursor, moveTaskCursor, syncSessionCursorToActive, handleCreateWorktree, handleLaunchBaseRepo, savedSessionCursor, config, computeConflictsAndMerged, syncing, ghAvailable, prMap, scrollTerminal, setScrollBack]);
|
|
5905
6393
|
useEffect(() => {
|
|
5906
6394
|
const handler = () => {
|
|
5907
6395
|
const newCols = process.stdout.columns || 80;
|
|
@@ -5913,6 +6401,10 @@ function App({ unsafe, onExit }) {
|
|
|
5913
6401
|
const newTermInner = newCols - Math.min(60, Math.floor(newCols * 0.525)) - 2;
|
|
5914
6402
|
const newContentHeight = newRows - 3;
|
|
5915
6403
|
pty2.resize(newTermInner, newContentHeight);
|
|
6404
|
+
try {
|
|
6405
|
+
setTermLines(renderBufferLines(pty2.terminal.buffer.active, newTermInner, newContentHeight, termScrollBack.current));
|
|
6406
|
+
} catch {
|
|
6407
|
+
}
|
|
5916
6408
|
}
|
|
5917
6409
|
}
|
|
5918
6410
|
};
|
|
@@ -5932,12 +6424,11 @@ function App({ unsafe, onExit }) {
|
|
|
5932
6424
|
}, 5 * 60 * 1e3);
|
|
5933
6425
|
return () => clearInterval(interval);
|
|
5934
6426
|
}, []);
|
|
5935
|
-
const statusMap = buildStatusMap();
|
|
5936
6427
|
const placeholder = !activeKey ? "Select a session and press Enter" : "Press Enter to start session";
|
|
5937
|
-
return /* @__PURE__ */
|
|
5938
|
-
/* @__PURE__ */
|
|
5939
|
-
/* @__PURE__ */
|
|
5940
|
-
/* @__PURE__ */
|
|
6428
|
+
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", width: cols, height: rows, children: [
|
|
6429
|
+
showHelp2 ? /* @__PURE__ */ jsx5(HelpOverlay, { width: cols, height: contentHeight }) : /* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", height: contentHeight, children: [
|
|
6430
|
+
/* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", width: sidebarWidth, children: [
|
|
6431
|
+
/* @__PURE__ */ jsx5(
|
|
5941
6432
|
Sidebar,
|
|
5942
6433
|
{
|
|
5943
6434
|
sidebarRows: topRows,
|
|
@@ -5950,10 +6441,11 @@ function App({ unsafe, onExit }) {
|
|
|
5950
6441
|
activeKey,
|
|
5951
6442
|
width: sidebarWidth,
|
|
5952
6443
|
height: sessionPaneHeight,
|
|
5953
|
-
branchInput
|
|
6444
|
+
branchInput,
|
|
6445
|
+
filter
|
|
5954
6446
|
}
|
|
5955
6447
|
),
|
|
5956
|
-
/* @__PURE__ */
|
|
6448
|
+
/* @__PURE__ */ jsx5(
|
|
5957
6449
|
PrPane,
|
|
5958
6450
|
{
|
|
5959
6451
|
prRows,
|
|
@@ -5964,7 +6456,7 @@ function App({ unsafe, onExit }) {
|
|
|
5964
6456
|
height: prPaneHeight
|
|
5965
6457
|
}
|
|
5966
6458
|
),
|
|
5967
|
-
jiraPaneHeight > 0 && /* @__PURE__ */
|
|
6459
|
+
jiraPaneHeight > 0 && /* @__PURE__ */ jsx5(
|
|
5968
6460
|
JiraPane,
|
|
5969
6461
|
{
|
|
5970
6462
|
jiraRows,
|
|
@@ -5974,7 +6466,7 @@ function App({ unsafe, onExit }) {
|
|
|
5974
6466
|
height: jiraPaneHeight
|
|
5975
6467
|
}
|
|
5976
6468
|
),
|
|
5977
|
-
/* @__PURE__ */
|
|
6469
|
+
/* @__PURE__ */ jsx5(
|
|
5978
6470
|
TaskPane,
|
|
5979
6471
|
{
|
|
5980
6472
|
taskRows,
|
|
@@ -5986,7 +6478,7 @@ function App({ unsafe, onExit }) {
|
|
|
5986
6478
|
}
|
|
5987
6479
|
)
|
|
5988
6480
|
] }),
|
|
5989
|
-
/* @__PURE__ */
|
|
6481
|
+
/* @__PURE__ */ jsx5(
|
|
5990
6482
|
TerminalPane,
|
|
5991
6483
|
{
|
|
5992
6484
|
lines: termLines,
|
|
@@ -5994,22 +6486,23 @@ function App({ unsafe, onExit }) {
|
|
|
5994
6486
|
height: contentHeight,
|
|
5995
6487
|
focused: focus === 4 /* TERMINAL */,
|
|
5996
6488
|
placeholder,
|
|
5997
|
-
title: "Terminal"
|
|
6489
|
+
title: "Terminal",
|
|
6490
|
+
scrollback: termScroll
|
|
5998
6491
|
}
|
|
5999
6492
|
)
|
|
6000
6493
|
] }),
|
|
6001
|
-
/* @__PURE__ */
|
|
6494
|
+
/* @__PURE__ */ jsx5(StatusBar, { message, pane: focus === 4 /* TERMINAL */ ? "terminal" : focus === 2 /* PRS */ ? "prs" : focus === 3 /* JIRA */ ? "jira" : focus === 1 /* TASKS */ ? "tasks" : "sessions", syncing })
|
|
6002
6495
|
] });
|
|
6003
6496
|
}
|
|
6004
6497
|
|
|
6005
6498
|
// src/tui-ink/index.tsx
|
|
6006
|
-
import { jsx as
|
|
6499
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
6007
6500
|
function crashLog(label2, err) {
|
|
6008
6501
|
try {
|
|
6009
6502
|
const msg = err instanceof Error ? err.stack || err.message : String(err);
|
|
6010
6503
|
const line = `${(/* @__PURE__ */ new Date()).toISOString()} [CRASH] ${label2}: ${msg}
|
|
6011
6504
|
`;
|
|
6012
|
-
fs24.appendFileSync(
|
|
6505
|
+
fs24.appendFileSync(path19.join(getConfigDir(), "debug.log"), line);
|
|
6013
6506
|
} catch {
|
|
6014
6507
|
}
|
|
6015
6508
|
}
|
|
@@ -6022,11 +6515,11 @@ async function startDashboard(unsafe) {
|
|
|
6022
6515
|
process.stdin.setRawMode(true);
|
|
6023
6516
|
process.stdin.resume();
|
|
6024
6517
|
const restore = () => {
|
|
6025
|
-
process.stdout.write("\x1B]0;\x07\x1B[?25h\x1B[?1049l");
|
|
6518
|
+
process.stdout.write("\x1B]0;\x07\x1B[?1000l\x1B[?1006l\x1B[?25h\x1B[?1049l");
|
|
6026
6519
|
};
|
|
6027
6520
|
try {
|
|
6028
6521
|
const { waitUntilExit, unmount } = render(
|
|
6029
|
-
/* @__PURE__ */
|
|
6522
|
+
/* @__PURE__ */ jsx6(App, { unsafe, onExit: () => {
|
|
6030
6523
|
unmount();
|
|
6031
6524
|
restore();
|
|
6032
6525
|
process.exit(0);
|
|
@@ -6333,22 +6826,22 @@ import chalk17 from "chalk";
|
|
|
6333
6826
|
|
|
6334
6827
|
// src/core/hydrate.ts
|
|
6335
6828
|
import fs25 from "fs";
|
|
6336
|
-
import
|
|
6829
|
+
import path20 from "path";
|
|
6337
6830
|
async function hydrateHistoryFromDisk(config) {
|
|
6338
|
-
const worktreesRoot =
|
|
6831
|
+
const worktreesRoot = path20.resolve(config.worktreesRoot);
|
|
6339
6832
|
const folderNameToAlias = /* @__PURE__ */ new Map();
|
|
6340
6833
|
for (const [alias, repoPath] of Object.entries(config.repos)) {
|
|
6341
|
-
folderNameToAlias.set(
|
|
6834
|
+
folderNameToAlias.set(path20.basename(repoPath), alias);
|
|
6342
6835
|
}
|
|
6343
6836
|
const discovered = /* @__PURE__ */ new Map();
|
|
6344
6837
|
for (const [alias, repoPath] of Object.entries(config.repos)) {
|
|
6345
6838
|
if (!fs25.existsSync(repoPath)) continue;
|
|
6346
6839
|
for (const entry of parseWorktreeList(repoPath)) {
|
|
6347
6840
|
if (!entry.branch) continue;
|
|
6348
|
-
if (
|
|
6349
|
-
const rel =
|
|
6350
|
-
if (!rel || rel.startsWith("..") ||
|
|
6351
|
-
const parts = rel.split(
|
|
6841
|
+
if (path20.resolve(entry.path) === path20.resolve(repoPath)) continue;
|
|
6842
|
+
const rel = path20.relative(worktreesRoot, entry.path);
|
|
6843
|
+
if (!rel || rel.startsWith("..") || path20.isAbsolute(rel)) continue;
|
|
6844
|
+
const parts = rel.split(path20.sep).filter(Boolean);
|
|
6352
6845
|
if (parts.length < 2) continue;
|
|
6353
6846
|
const [first, second] = parts;
|
|
6354
6847
|
const isGroup = Object.prototype.hasOwnProperty.call(config.groups, first);
|
|
@@ -6433,13 +6926,13 @@ var hydrateCommand = {
|
|
|
6433
6926
|
// src/commands/diff.ts
|
|
6434
6927
|
import fs36 from "fs";
|
|
6435
6928
|
import os9 from "os";
|
|
6436
|
-
import
|
|
6929
|
+
import path31 from "path";
|
|
6437
6930
|
import { spawn as childSpawn } from "child_process";
|
|
6438
6931
|
import chalk21 from "chalk";
|
|
6439
6932
|
|
|
6440
6933
|
// src/core/diff-pipeline.ts
|
|
6441
6934
|
import fs28 from "fs";
|
|
6442
|
-
import
|
|
6935
|
+
import path23 from "path";
|
|
6443
6936
|
import spawn9 from "cross-spawn";
|
|
6444
6937
|
|
|
6445
6938
|
// src/core/diff-parse.ts
|
|
@@ -6588,7 +7081,7 @@ function stripPathPrefix(p) {
|
|
|
6588
7081
|
|
|
6589
7082
|
// src/core/lcov.ts
|
|
6590
7083
|
import fs26 from "fs";
|
|
6591
|
-
import
|
|
7084
|
+
import path21 from "path";
|
|
6592
7085
|
function parseLcov(content) {
|
|
6593
7086
|
const result = /* @__PURE__ */ new Map();
|
|
6594
7087
|
let sf = null;
|
|
@@ -6647,8 +7140,8 @@ function parseLcov(content) {
|
|
|
6647
7140
|
}
|
|
6648
7141
|
function findLcov(root) {
|
|
6649
7142
|
const candidates = [
|
|
6650
|
-
|
|
6651
|
-
|
|
7143
|
+
path21.join(root, "coverage", "lcov.info"),
|
|
7144
|
+
path21.join(root, "lcov.info")
|
|
6652
7145
|
];
|
|
6653
7146
|
for (const c of candidates) {
|
|
6654
7147
|
try {
|
|
@@ -6683,33 +7176,33 @@ function readParsedLcov(lcovPath) {
|
|
|
6683
7176
|
return { parsed, mtimeMs };
|
|
6684
7177
|
}
|
|
6685
7178
|
function normRel(p) {
|
|
6686
|
-
return
|
|
7179
|
+
return path21.normalize(p).replace(/\\/g, "/").replace(/^\.\//, "");
|
|
6687
7180
|
}
|
|
6688
7181
|
function realRoot(root) {
|
|
6689
7182
|
try {
|
|
6690
|
-
return fs26.realpathSync(
|
|
7183
|
+
return fs26.realpathSync(path21.resolve(root));
|
|
6691
7184
|
} catch {
|
|
6692
|
-
return
|
|
7185
|
+
return path21.resolve(root);
|
|
6693
7186
|
}
|
|
6694
7187
|
}
|
|
6695
7188
|
function canonicalize(absPath) {
|
|
6696
|
-
const resolved =
|
|
7189
|
+
const resolved = path21.resolve(absPath);
|
|
6697
7190
|
let dir = resolved;
|
|
6698
7191
|
const tail = [];
|
|
6699
7192
|
for (; ; ) {
|
|
6700
7193
|
try {
|
|
6701
7194
|
const realDir = fs26.realpathSync(dir);
|
|
6702
|
-
return tail.length ?
|
|
7195
|
+
return tail.length ? path21.join(realDir, ...tail.reverse()) : realDir;
|
|
6703
7196
|
} catch {
|
|
6704
|
-
const parent =
|
|
7197
|
+
const parent = path21.dirname(dir);
|
|
6705
7198
|
if (parent === dir) return resolved;
|
|
6706
|
-
tail.push(
|
|
7199
|
+
tail.push(path21.basename(dir));
|
|
6707
7200
|
dir = parent;
|
|
6708
7201
|
}
|
|
6709
7202
|
}
|
|
6710
7203
|
}
|
|
6711
7204
|
function relForAbsSf(absSf, canonRoot) {
|
|
6712
|
-
return
|
|
7205
|
+
return path21.relative(canonRoot, canonicalize(absSf));
|
|
6713
7206
|
}
|
|
6714
7207
|
function coverageLookup(root, relPaths) {
|
|
6715
7208
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -6722,7 +7215,7 @@ function coverageLookup(root, relPaths) {
|
|
|
6722
7215
|
const canonRoot = realRoot(root);
|
|
6723
7216
|
const byRel = /* @__PURE__ */ new Map();
|
|
6724
7217
|
for (const [sf, pct] of read.parsed) {
|
|
6725
|
-
const rel =
|
|
7218
|
+
const rel = path21.isAbsolute(sf) ? relForAbsSf(sf, canonRoot) : sf;
|
|
6726
7219
|
byRel.set(normRel(rel), pct);
|
|
6727
7220
|
}
|
|
6728
7221
|
for (const rp of relPaths) {
|
|
@@ -6735,12 +7228,12 @@ function coverageLookup(root, relPaths) {
|
|
|
6735
7228
|
// src/core/git-tree-snapshot.ts
|
|
6736
7229
|
import fs27 from "fs";
|
|
6737
7230
|
import os7 from "os";
|
|
6738
|
-
import
|
|
7231
|
+
import path22 from "path";
|
|
6739
7232
|
import crypto from "crypto";
|
|
6740
7233
|
import spawn8 from "cross-spawn";
|
|
6741
7234
|
function writeTempTree(repoRoot, opts = {}) {
|
|
6742
7235
|
const includeWorkingTree = opts.includeWorkingTree ?? true;
|
|
6743
|
-
const tmpIndex =
|
|
7236
|
+
const tmpIndex = path22.join(
|
|
6744
7237
|
os7.tmpdir(),
|
|
6745
7238
|
`wd-tree-${process.pid}-${crypto.randomBytes(6).toString("hex")}.idx`
|
|
6746
7239
|
);
|
|
@@ -6785,12 +7278,12 @@ function isMarkdownPath(p) {
|
|
|
6785
7278
|
return p !== "/dev/null" && MARKDOWN_EXT_RE.test(p);
|
|
6786
7279
|
}
|
|
6787
7280
|
function isInsideRoot(root, rel) {
|
|
6788
|
-
const resolvedRoot =
|
|
6789
|
-
const resolvedTarget =
|
|
6790
|
-
const r =
|
|
7281
|
+
const resolvedRoot = path23.resolve(root);
|
|
7282
|
+
const resolvedTarget = path23.resolve(resolvedRoot, rel);
|
|
7283
|
+
const r = path23.relative(resolvedRoot, resolvedTarget);
|
|
6791
7284
|
if (r === "") return true;
|
|
6792
7285
|
if (r.startsWith("..")) return false;
|
|
6793
|
-
if (
|
|
7286
|
+
if (path23.isAbsolute(r)) return false;
|
|
6794
7287
|
return true;
|
|
6795
7288
|
}
|
|
6796
7289
|
function readMarkdownContent(root, file, fromRef, toRef) {
|
|
@@ -6815,10 +7308,10 @@ function readMarkdownContent(root, file, fromRef, toRef) {
|
|
|
6815
7308
|
if (file.status !== "deleted" && isMarkdownPath(file.newPath) && isInsideRoot(root, file.newPath)) {
|
|
6816
7309
|
if (toRef === "working") {
|
|
6817
7310
|
try {
|
|
6818
|
-
const absPath =
|
|
6819
|
-
const realRoot2 = fs28.realpathSync(
|
|
7311
|
+
const absPath = path23.join(root, file.newPath);
|
|
7312
|
+
const realRoot2 = fs28.realpathSync(path23.resolve(root));
|
|
6820
7313
|
const realPath = fs28.realpathSync(absPath);
|
|
6821
|
-
const sep =
|
|
7314
|
+
const sep = path23.sep;
|
|
6822
7315
|
if (realPath === realRoot2 || realPath.startsWith(realRoot2 + sep)) {
|
|
6823
7316
|
result.after = fs28.readFileSync(absPath, "utf-8");
|
|
6824
7317
|
}
|
|
@@ -6848,7 +7341,7 @@ function isBinaryContent(buffer) {
|
|
|
6848
7341
|
return false;
|
|
6849
7342
|
}
|
|
6850
7343
|
function synthesizeUntrackedDiff(root, relPath) {
|
|
6851
|
-
const absPath =
|
|
7344
|
+
const absPath = path23.join(root, relPath);
|
|
6852
7345
|
let buffer;
|
|
6853
7346
|
try {
|
|
6854
7347
|
buffer = fs28.readFileSync(absPath);
|
|
@@ -6939,7 +7432,7 @@ function attachCoverage(root, files) {
|
|
|
6939
7432
|
f.coverageMtimeMs = lcovMtimeMs;
|
|
6940
7433
|
let srcMtimeMs = null;
|
|
6941
7434
|
try {
|
|
6942
|
-
srcMtimeMs = fs28.statSync(
|
|
7435
|
+
srcMtimeMs = fs28.statSync(path23.join(root, f.path)).mtimeMs;
|
|
6943
7436
|
} catch {
|
|
6944
7437
|
srcMtimeMs = null;
|
|
6945
7438
|
}
|
|
@@ -7007,7 +7500,7 @@ function computeRangeDiff(opts) {
|
|
|
7007
7500
|
|
|
7008
7501
|
// src/core/repo-spec.ts
|
|
7009
7502
|
import fs29 from "fs";
|
|
7010
|
-
import
|
|
7503
|
+
import path24 from "path";
|
|
7011
7504
|
import os8 from "os";
|
|
7012
7505
|
import crypto2 from "crypto";
|
|
7013
7506
|
function scopeHashFor(keyPaths) {
|
|
@@ -7015,21 +7508,21 @@ function scopeHashFor(keyPaths) {
|
|
|
7015
7508
|
return crypto2.createHash("sha1").update(key).digest("hex").slice(0, 12);
|
|
7016
7509
|
}
|
|
7017
7510
|
function stableDiffPath(keyPaths) {
|
|
7018
|
-
const dir =
|
|
7511
|
+
const dir = path24.join(os8.homedir(), ".work", "diffs");
|
|
7019
7512
|
fs29.mkdirSync(dir, { recursive: true });
|
|
7020
|
-
return
|
|
7513
|
+
return path24.join(dir, scopeHashFor(keyPaths));
|
|
7021
7514
|
}
|
|
7022
7515
|
|
|
7023
7516
|
// src/core/diff-scope.ts
|
|
7024
7517
|
import fs30 from "fs";
|
|
7025
|
-
import
|
|
7518
|
+
import path25 from "path";
|
|
7026
7519
|
import chalk18 from "chalk";
|
|
7027
7520
|
function normPath(p) {
|
|
7028
|
-
return
|
|
7521
|
+
return path25.resolve(p).replace(/\\/g, "/").toLowerCase();
|
|
7029
7522
|
}
|
|
7030
7523
|
function realNorm(p) {
|
|
7031
7524
|
try {
|
|
7032
|
-
return normPath(fs30.realpathSync(p));
|
|
7525
|
+
return normPath(fs30.realpathSync.native(p));
|
|
7033
7526
|
} catch {
|
|
7034
7527
|
return normPath(p);
|
|
7035
7528
|
}
|
|
@@ -7049,29 +7542,29 @@ function resolveScope(cwd) {
|
|
|
7049
7542
|
return {
|
|
7050
7543
|
isGroup: true,
|
|
7051
7544
|
session: s,
|
|
7052
|
-
repos: s.paths.map((rp) => ({ name:
|
|
7053
|
-
activeRepoName:
|
|
7545
|
+
repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
|
|
7546
|
+
activeRepoName: path25.basename(p)
|
|
7054
7547
|
};
|
|
7055
7548
|
}
|
|
7056
7549
|
return {
|
|
7057
7550
|
isGroup: false,
|
|
7058
7551
|
session: s,
|
|
7059
|
-
repos: [{ name:
|
|
7060
|
-
activeRepoName:
|
|
7552
|
+
repos: [{ name: path25.basename(p), root: p }],
|
|
7553
|
+
activeRepoName: path25.basename(p)
|
|
7061
7554
|
};
|
|
7062
7555
|
}
|
|
7063
7556
|
}
|
|
7064
7557
|
}
|
|
7065
7558
|
for (const s of sessions) {
|
|
7066
7559
|
if (!s.isGroup || s.paths.length === 0) continue;
|
|
7067
|
-
const parents = s.paths.map((p) => normPath(
|
|
7560
|
+
const parents = s.paths.map((p) => normPath(path25.dirname(p)));
|
|
7068
7561
|
const groupRoot = parents[0];
|
|
7069
7562
|
if (!parents.every((par) => par === groupRoot)) continue;
|
|
7070
7563
|
if (normCwd === groupRoot || normCwd.startsWith(groupRoot + "/")) {
|
|
7071
7564
|
return {
|
|
7072
7565
|
isGroup: true,
|
|
7073
7566
|
session: s,
|
|
7074
|
-
repos: s.paths.map((rp) => ({ name:
|
|
7567
|
+
repos: s.paths.map((rp) => ({ name: path25.basename(rp), root: rp })),
|
|
7075
7568
|
activeRepoName: null
|
|
7076
7569
|
};
|
|
7077
7570
|
}
|
|
@@ -7080,8 +7573,8 @@ function resolveScope(cwd) {
|
|
|
7080
7573
|
return {
|
|
7081
7574
|
isGroup: false,
|
|
7082
7575
|
session: null,
|
|
7083
|
-
repos: [{ name:
|
|
7084
|
-
activeRepoName:
|
|
7576
|
+
repos: [{ name: path25.basename(toplevel), root: toplevel }],
|
|
7577
|
+
activeRepoName: path25.basename(toplevel)
|
|
7085
7578
|
};
|
|
7086
7579
|
}
|
|
7087
7580
|
function findAnyParentBranch(cwd) {
|
|
@@ -7257,7 +7750,7 @@ import { streamSSE } from "hono/streaming";
|
|
|
7257
7750
|
|
|
7258
7751
|
// src/core/file-context.ts
|
|
7259
7752
|
import fs31 from "fs";
|
|
7260
|
-
import
|
|
7753
|
+
import path26 from "path";
|
|
7261
7754
|
import spawn10 from "cross-spawn";
|
|
7262
7755
|
function readContextLines(opts) {
|
|
7263
7756
|
const { root, relPath, ref } = opts;
|
|
@@ -7279,10 +7772,10 @@ function readContextLines(opts) {
|
|
|
7279
7772
|
}
|
|
7280
7773
|
function readWorkingTree(root, relPath) {
|
|
7281
7774
|
try {
|
|
7282
|
-
const absPath =
|
|
7283
|
-
const realRoot2 = fs31.realpathSync(
|
|
7775
|
+
const absPath = path26.join(root, relPath);
|
|
7776
|
+
const realRoot2 = fs31.realpathSync(path26.resolve(root));
|
|
7284
7777
|
const realPath = fs31.realpathSync(absPath);
|
|
7285
|
-
const sep =
|
|
7778
|
+
const sep = path26.sep;
|
|
7286
7779
|
if (realPath !== realRoot2 && !realPath.startsWith(realRoot2 + sep)) {
|
|
7287
7780
|
return null;
|
|
7288
7781
|
}
|
|
@@ -7304,7 +7797,7 @@ function readAtRef(root, ref, relPath) {
|
|
|
7304
7797
|
|
|
7305
7798
|
// src/core/fs-watcher.ts
|
|
7306
7799
|
import fs32 from "fs";
|
|
7307
|
-
import
|
|
7800
|
+
import path27 from "path";
|
|
7308
7801
|
import chalk19 from "chalk";
|
|
7309
7802
|
import chokidar from "chokidar";
|
|
7310
7803
|
var IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
@@ -7330,7 +7823,7 @@ var IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
|
7330
7823
|
]);
|
|
7331
7824
|
function isIgnoredWatchPath(roots, filePath) {
|
|
7332
7825
|
for (const root of roots) {
|
|
7333
|
-
const rel =
|
|
7826
|
+
const rel = path27.relative(root, filePath).replace(/\\/g, "/");
|
|
7334
7827
|
if (rel === "" || rel.startsWith("../")) continue;
|
|
7335
7828
|
if (rel.split("/").some((seg) => IGNORED_DIRS.has(seg))) return true;
|
|
7336
7829
|
}
|
|
@@ -7355,7 +7848,7 @@ function createFsWatcher(opts) {
|
|
|
7355
7848
|
if (SUPPORTS_RECURSIVE_WATCH) {
|
|
7356
7849
|
const watchers = opts.roots.map((root) => {
|
|
7357
7850
|
const w = fs32.watch(root, { recursive: true }, (_event, filename) => {
|
|
7358
|
-
if (filename && isIgnoredWatchPath([root],
|
|
7851
|
+
if (filename && isIgnoredWatchPath([root], path27.join(root, filename.toString()))) {
|
|
7359
7852
|
return;
|
|
7360
7853
|
}
|
|
7361
7854
|
fire();
|
|
@@ -7394,29 +7887,29 @@ function createFsWatcher(opts) {
|
|
|
7394
7887
|
|
|
7395
7888
|
// src/core/web-static.ts
|
|
7396
7889
|
import fs33 from "fs";
|
|
7397
|
-
import
|
|
7890
|
+
import path28 from "path";
|
|
7398
7891
|
import { fileURLToPath } from "url";
|
|
7399
7892
|
function resolveWebRoot() {
|
|
7400
|
-
const entryDir =
|
|
7401
|
-
const moduleDir =
|
|
7893
|
+
const entryDir = path28.dirname(process.argv[1] ?? "");
|
|
7894
|
+
const moduleDir = path28.dirname(fileURLToPath(import.meta.url));
|
|
7402
7895
|
const candidates = [
|
|
7403
|
-
|
|
7896
|
+
path28.join(entryDir, "web"),
|
|
7404
7897
|
// bundled: this module is inlined into dist/<bin>.js, so dist/web is a
|
|
7405
7898
|
// sibling of the bundle. Works even when argv[1] is an npm bin symlink
|
|
7406
7899
|
// (which is not realpath'd, so the entryDir candidate above misses).
|
|
7407
|
-
|
|
7900
|
+
path28.join(moduleDir, "web"),
|
|
7408
7901
|
// dev/tsx fallback: walk up from src/core to repo root then into dist/web.
|
|
7409
|
-
|
|
7902
|
+
path28.resolve(moduleDir, "../../dist/web")
|
|
7410
7903
|
];
|
|
7411
7904
|
for (const c of candidates) {
|
|
7412
|
-
if (fs33.existsSync(
|
|
7905
|
+
if (fs33.existsSync(path28.join(c, "index.html"))) return c;
|
|
7413
7906
|
}
|
|
7414
7907
|
return null;
|
|
7415
7908
|
}
|
|
7416
7909
|
|
|
7417
7910
|
// src/core/spa-handler.ts
|
|
7418
7911
|
import fs34 from "fs";
|
|
7419
|
-
import
|
|
7912
|
+
import path29 from "path";
|
|
7420
7913
|
var MIME = {
|
|
7421
7914
|
".html": "text/html; charset=utf-8",
|
|
7422
7915
|
".js": "application/javascript; charset=utf-8",
|
|
@@ -7430,9 +7923,9 @@ var MIME = {
|
|
|
7430
7923
|
function readFile(root, relPath) {
|
|
7431
7924
|
const clean = relPath.split("?")[0];
|
|
7432
7925
|
const requested = clean === "/" ? "/index.html" : clean;
|
|
7433
|
-
const filePath =
|
|
7434
|
-
const norm =
|
|
7435
|
-
if (!norm.startsWith(
|
|
7926
|
+
const filePath = path29.join(root, requested);
|
|
7927
|
+
const norm = path29.normalize(filePath);
|
|
7928
|
+
if (!norm.startsWith(path29.normalize(root))) return null;
|
|
7436
7929
|
let stat;
|
|
7437
7930
|
try {
|
|
7438
7931
|
stat = fs34.statSync(norm);
|
|
@@ -7440,7 +7933,7 @@ function readFile(root, relPath) {
|
|
|
7440
7933
|
return null;
|
|
7441
7934
|
}
|
|
7442
7935
|
if (!stat.isFile()) return null;
|
|
7443
|
-
const ext =
|
|
7936
|
+
const ext = path29.extname(norm).toLowerCase();
|
|
7444
7937
|
return { body: fs34.readFileSync(norm), ext };
|
|
7445
7938
|
}
|
|
7446
7939
|
function serveSpa(c, webRoot) {
|
|
@@ -7735,7 +8228,7 @@ function diffReviewSnapshot(snapshot, seen) {
|
|
|
7735
8228
|
|
|
7736
8229
|
// src/core/static-renderer.ts
|
|
7737
8230
|
import fs35 from "fs";
|
|
7738
|
-
import
|
|
8231
|
+
import path30 from "path";
|
|
7739
8232
|
function buildDiff(specs, resolvedBase) {
|
|
7740
8233
|
return {
|
|
7741
8234
|
repos: specs.map((r) => ({
|
|
@@ -7751,7 +8244,7 @@ function renderStatic(opts) {
|
|
|
7751
8244
|
if (!webRoot) {
|
|
7752
8245
|
throw new Error("Could not find dist/web/. Run `npm run build` first.");
|
|
7753
8246
|
}
|
|
7754
|
-
const shellPath =
|
|
8247
|
+
const shellPath = path30.join(webRoot, "index.html");
|
|
7755
8248
|
let shell = fs35.readFileSync(shellPath, "utf-8");
|
|
7756
8249
|
const uncommitted = buildDiff(opts.uncommitted, "HEAD");
|
|
7757
8250
|
const branch = opts.branch ? buildDiff(opts.branch.specs, opts.branch.resolvedBase) : void 0;
|
|
@@ -7801,8 +8294,8 @@ function escapeForScriptTag(json) {
|
|
|
7801
8294
|
}
|
|
7802
8295
|
function readAsset(webRoot, urlPath) {
|
|
7803
8296
|
const clean = urlPath.split("?")[0].replace(/^\//, "");
|
|
7804
|
-
const full =
|
|
7805
|
-
if (!
|
|
8297
|
+
const full = path30.join(webRoot, clean);
|
|
8298
|
+
if (!path30.normalize(full).startsWith(path30.normalize(webRoot))) return null;
|
|
7806
8299
|
try {
|
|
7807
8300
|
return fs35.readFileSync(full, "utf-8");
|
|
7808
8301
|
} catch {
|
|
@@ -7845,7 +8338,7 @@ async function runStop(repoSpecs) {
|
|
|
7845
8338
|
}
|
|
7846
8339
|
}
|
|
7847
8340
|
function webUrlFilePath() {
|
|
7848
|
-
return
|
|
8341
|
+
return path31.join(os9.homedir(), ".work", "web.url");
|
|
7849
8342
|
}
|
|
7850
8343
|
function resolveWorkBinPath(selfArgv1) {
|
|
7851
8344
|
let real = selfArgv1;
|
|
@@ -7854,7 +8347,7 @@ function resolveWorkBinPath(selfArgv1) {
|
|
|
7854
8347
|
} catch {
|
|
7855
8348
|
}
|
|
7856
8349
|
if (real.endsWith("wd-bin.js")) {
|
|
7857
|
-
return
|
|
8350
|
+
return path31.join(path31.dirname(real), "bin.js");
|
|
7858
8351
|
}
|
|
7859
8352
|
return real;
|
|
7860
8353
|
}
|
|
@@ -7866,12 +8359,32 @@ function readWebUrl() {
|
|
|
7866
8359
|
return null;
|
|
7867
8360
|
}
|
|
7868
8361
|
}
|
|
8362
|
+
async function webServerResponds(url, timeoutMs = 1500) {
|
|
8363
|
+
try {
|
|
8364
|
+
const ctrl = new AbortController();
|
|
8365
|
+
const timer = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
8366
|
+
try {
|
|
8367
|
+
const res = await fetch(`${url}api/context`, { signal: ctrl.signal });
|
|
8368
|
+
return res.ok;
|
|
8369
|
+
} finally {
|
|
8370
|
+
clearTimeout(timer);
|
|
8371
|
+
}
|
|
8372
|
+
} catch {
|
|
8373
|
+
return false;
|
|
8374
|
+
}
|
|
8375
|
+
}
|
|
7869
8376
|
async function ensureWorkWebRunning() {
|
|
7870
8377
|
const existing = readWebUrl();
|
|
7871
|
-
if (existing)
|
|
8378
|
+
if (existing) {
|
|
8379
|
+
if (await webServerResponds(existing)) return existing;
|
|
8380
|
+
try {
|
|
8381
|
+
fs36.unlinkSync(webUrlFilePath());
|
|
8382
|
+
} catch {
|
|
8383
|
+
}
|
|
8384
|
+
}
|
|
7872
8385
|
const workBin = resolveWorkBinPath(process.argv[1]);
|
|
7873
8386
|
const out = fs36.openSync(
|
|
7874
|
-
|
|
8387
|
+
path31.join(os9.homedir(), ".work", "web-autostart.log"),
|
|
7875
8388
|
"a"
|
|
7876
8389
|
);
|
|
7877
8390
|
const child = childSpawn(
|
|
@@ -8213,19 +8726,19 @@ var diffCommand = {
|
|
|
8213
8726
|
// src/commands/web.ts
|
|
8214
8727
|
import fs41 from "fs";
|
|
8215
8728
|
import os13 from "os";
|
|
8216
|
-
import
|
|
8729
|
+
import path40 from "path";
|
|
8217
8730
|
import chalk23 from "chalk";
|
|
8218
8731
|
|
|
8219
8732
|
// src/core/web-server.ts
|
|
8220
8733
|
import fs40 from "fs";
|
|
8221
8734
|
import os12 from "os";
|
|
8222
|
-
import
|
|
8735
|
+
import path39 from "path";
|
|
8223
8736
|
import chalk22 from "chalk";
|
|
8224
8737
|
import { Hono as Hono3 } from "hono";
|
|
8225
8738
|
import { streamSSE as streamSSE3 } from "hono/streaming";
|
|
8226
8739
|
|
|
8227
8740
|
// src/core/web-state.ts
|
|
8228
|
-
import
|
|
8741
|
+
import path32 from "path";
|
|
8229
8742
|
import crypto4 from "crypto";
|
|
8230
8743
|
import chokidar2 from "chokidar";
|
|
8231
8744
|
function sessionIdFor(s) {
|
|
@@ -8246,7 +8759,7 @@ function subscribeSession(sessionId, onChange) {
|
|
|
8246
8759
|
const watcher = chokidar2.watch(roots, {
|
|
8247
8760
|
ignored: (filePath) => {
|
|
8248
8761
|
for (const r of roots) {
|
|
8249
|
-
const rel =
|
|
8762
|
+
const rel = path32.relative(r, filePath).replace(/\\/g, "/");
|
|
8250
8763
|
if (rel === ".git" || rel.startsWith(".git/")) return true;
|
|
8251
8764
|
}
|
|
8252
8765
|
return false;
|
|
@@ -8361,16 +8874,16 @@ function disposeAllPtys() {
|
|
|
8361
8874
|
|
|
8362
8875
|
// src/core/comment-file-store.ts
|
|
8363
8876
|
import fs37 from "fs";
|
|
8364
|
-
import
|
|
8877
|
+
import path33 from "path";
|
|
8365
8878
|
import os10 from "os";
|
|
8366
8879
|
function commentsDir() {
|
|
8367
|
-
return
|
|
8880
|
+
return path33.join(os10.homedir(), ".work", "comments");
|
|
8368
8881
|
}
|
|
8369
8882
|
function ensureDir() {
|
|
8370
8883
|
fs37.mkdirSync(commentsDir(), { recursive: true });
|
|
8371
8884
|
}
|
|
8372
8885
|
function commentsFileFor(sessionId) {
|
|
8373
|
-
return
|
|
8886
|
+
return path33.join(commentsDir(), `${sessionId}.json`);
|
|
8374
8887
|
}
|
|
8375
8888
|
function pathFor(sessionId) {
|
|
8376
8889
|
return commentsFileFor(sessionId);
|
|
@@ -8450,11 +8963,11 @@ function clearCommentStoreCache() {
|
|
|
8450
8963
|
|
|
8451
8964
|
// src/core/pending-delivery.ts
|
|
8452
8965
|
import fs38 from "fs";
|
|
8453
|
-
import
|
|
8966
|
+
import path34 from "path";
|
|
8454
8967
|
function pathFor2(sessionId) {
|
|
8455
8968
|
return {
|
|
8456
8969
|
comments: commentsFileFor(sessionId),
|
|
8457
|
-
delivered:
|
|
8970
|
+
delivered: path34.join(commentsDir(), `${sessionId}.delivered.json`)
|
|
8458
8971
|
};
|
|
8459
8972
|
}
|
|
8460
8973
|
function readJson(filePath, fallback) {
|
|
@@ -8465,13 +8978,13 @@ function readJson(filePath, fallback) {
|
|
|
8465
8978
|
}
|
|
8466
8979
|
}
|
|
8467
8980
|
function writeAtomic2(filePath, content) {
|
|
8468
|
-
fs38.mkdirSync(
|
|
8981
|
+
fs38.mkdirSync(path34.dirname(filePath), { recursive: true });
|
|
8469
8982
|
const tmp = `${filePath}.tmp-${process.pid}-${Date.now()}`;
|
|
8470
8983
|
fs38.writeFileSync(tmp, content, "utf-8");
|
|
8471
8984
|
fs38.renameSync(tmp, filePath);
|
|
8472
8985
|
}
|
|
8473
8986
|
function normalize(p) {
|
|
8474
|
-
return
|
|
8987
|
+
return path34.resolve(p).replace(/\\/g, "/").toLowerCase();
|
|
8475
8988
|
}
|
|
8476
8989
|
function findSessionForCwd(cwd) {
|
|
8477
8990
|
const norm = normalize(cwd);
|
|
@@ -8502,7 +9015,7 @@ function readPendingForSession(sessionId) {
|
|
|
8502
9015
|
return comments.filter(isPendingFor(delivered));
|
|
8503
9016
|
}
|
|
8504
9017
|
function scopeStoreIdsForPaths(paths) {
|
|
8505
|
-
const resolved = paths.map((p) =>
|
|
9018
|
+
const resolved = paths.map((p) => path34.resolve(p));
|
|
8506
9019
|
const ids = /* @__PURE__ */ new Set();
|
|
8507
9020
|
ids.add(`scope-${scopeHashFor(resolved)}`);
|
|
8508
9021
|
for (const p of resolved) ids.add(`scope-${scopeHashFor([p])}`);
|
|
@@ -8825,7 +9338,7 @@ function mountPanesRoutes(app, opts) {
|
|
|
8825
9338
|
}
|
|
8826
9339
|
|
|
8827
9340
|
// src/core/worktree-routes.ts
|
|
8828
|
-
import
|
|
9341
|
+
import path35 from "path";
|
|
8829
9342
|
import { spawn as spawn11 } from "child_process";
|
|
8830
9343
|
import { zValidator as zValidator4 } from "@hono/zod-validator";
|
|
8831
9344
|
import { z as z3 } from "zod";
|
|
@@ -8949,7 +9462,7 @@ function mountWorktreeRoutes(app, opts) {
|
|
|
8949
9462
|
const id = c.req.param("id");
|
|
8950
9463
|
const session = findSession2(id);
|
|
8951
9464
|
if (!session) return c.json({ error: "unknown session" }, 404);
|
|
8952
|
-
const target = session.isGroup ?
|
|
9465
|
+
const target = session.isGroup ? path35.dirname(session.paths[0]) : session.paths[0];
|
|
8953
9466
|
try {
|
|
8954
9467
|
const cmd = process.platform === "win32" ? "code.cmd" : "code";
|
|
8955
9468
|
const child = spawn11(cmd, [target], {
|
|
@@ -8969,18 +9482,18 @@ function mountWorktreeRoutes(app, opts) {
|
|
|
8969
9482
|
import { zValidator as zValidator5 } from "@hono/zod-validator";
|
|
8970
9483
|
import { z as z4 } from "zod";
|
|
8971
9484
|
import { EventEmitter } from "events";
|
|
8972
|
-
import
|
|
9485
|
+
import path38 from "path";
|
|
8973
9486
|
import spawn13 from "cross-spawn";
|
|
8974
9487
|
|
|
8975
9488
|
// src/core/checkpoint.ts
|
|
8976
9489
|
import fs39 from "fs";
|
|
8977
9490
|
import os11 from "os";
|
|
8978
|
-
import
|
|
9491
|
+
import path36 from "path";
|
|
8979
9492
|
import spawn12 from "cross-spawn";
|
|
8980
9493
|
function manifestPath(scopeHash) {
|
|
8981
|
-
const dir =
|
|
9494
|
+
const dir = path36.join(os11.homedir(), ".work", "diffs");
|
|
8982
9495
|
fs39.mkdirSync(dir, { recursive: true });
|
|
8983
|
-
return
|
|
9496
|
+
return path36.join(dir, `${scopeHash}.checkpoints.json`);
|
|
8984
9497
|
}
|
|
8985
9498
|
function emptyManifest(scopeHash) {
|
|
8986
9499
|
return { version: 1, scopeHash, entries: [] };
|
|
@@ -9121,7 +9634,7 @@ function clearCheckpoints(scopeHash, repoRoots) {
|
|
|
9121
9634
|
}
|
|
9122
9635
|
|
|
9123
9636
|
// src/core/scope-manager.ts
|
|
9124
|
-
import
|
|
9637
|
+
import path37 from "path";
|
|
9125
9638
|
import crypto5 from "crypto";
|
|
9126
9639
|
var scopes = /* @__PURE__ */ new Map();
|
|
9127
9640
|
function hashFor(paths) {
|
|
@@ -9138,7 +9651,7 @@ var ScopePathRejectedError = class extends Error {
|
|
|
9138
9651
|
}
|
|
9139
9652
|
};
|
|
9140
9653
|
function normaliseForCompare(p) {
|
|
9141
|
-
return
|
|
9654
|
+
return path37.resolve(p).replace(/\\/g, "/").toLowerCase();
|
|
9142
9655
|
}
|
|
9143
9656
|
function rejectedPaths(normalised) {
|
|
9144
9657
|
const config = loadConfig();
|
|
@@ -9156,7 +9669,7 @@ function rejectedPaths(normalised) {
|
|
|
9156
9669
|
});
|
|
9157
9670
|
}
|
|
9158
9671
|
function registerScope(paths, label2) {
|
|
9159
|
-
const normalised = paths.map((p) =>
|
|
9672
|
+
const normalised = paths.map((p) => path37.resolve(p));
|
|
9160
9673
|
const rejected = rejectedPaths(normalised);
|
|
9161
9674
|
if (rejected.length > 0) throw new ScopePathRejectedError(rejected);
|
|
9162
9675
|
const hash = hashFor(normalised);
|
|
@@ -9170,7 +9683,7 @@ function registerScope(paths, label2) {
|
|
|
9170
9683
|
const scope = {
|
|
9171
9684
|
hash,
|
|
9172
9685
|
paths: normalised,
|
|
9173
|
-
label: label2 ??
|
|
9686
|
+
label: label2 ?? path37.basename(normalised[0]),
|
|
9174
9687
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9175
9688
|
ended: false
|
|
9176
9689
|
};
|
|
@@ -9367,7 +9880,7 @@ function mountScopeRoutes(app, opts) {
|
|
|
9367
9880
|
const fromSha = fromEntry.repos[p] ?? "HEAD";
|
|
9368
9881
|
const toSha = toEntry === void 0 ? "working" : toEntry.repos[p] ?? "HEAD";
|
|
9369
9882
|
return {
|
|
9370
|
-
name:
|
|
9883
|
+
name: path38.basename(p),
|
|
9371
9884
|
root: p,
|
|
9372
9885
|
files: computeRangeDiff({ root: p, fromRef: fromSha, toRef: toSha })
|
|
9373
9886
|
};
|
|
@@ -9385,7 +9898,7 @@ function mountScopeRoutes(app, opts) {
|
|
|
9385
9898
|
(p) => resolveRepoDiff(p, base, sessionBaseForPath(p))
|
|
9386
9899
|
);
|
|
9387
9900
|
const repos = scope.paths.map((p, i) => ({
|
|
9388
|
-
name:
|
|
9901
|
+
name: path38.basename(p),
|
|
9389
9902
|
root: p,
|
|
9390
9903
|
resolvedBase: resolved[i].resolvedBase,
|
|
9391
9904
|
files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
|
|
@@ -9415,7 +9928,7 @@ function mountScopeRoutes(app, opts) {
|
|
|
9415
9928
|
if (!relPath || !Number.isInteger(start) || !Number.isInteger(end)) {
|
|
9416
9929
|
return c.json({ error: "bad path/start/end" }, 400);
|
|
9417
9930
|
}
|
|
9418
|
-
const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) =>
|
|
9931
|
+
const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path38.basename(p) === repoName);
|
|
9419
9932
|
if (!root) return c.json({ error: "unknown repo" }, 404);
|
|
9420
9933
|
const result = readContextLines({ root, relPath, start, end, ref });
|
|
9421
9934
|
if (!result) return c.json({ error: "cannot read file" }, 400);
|
|
@@ -9653,7 +10166,7 @@ function computeSessionDiff(s, base) {
|
|
|
9653
10166
|
(p) => resolveRepoDiff(p, base, s.baseBranches?.[p] ?? s.baseBranch)
|
|
9654
10167
|
);
|
|
9655
10168
|
const repos = s.paths.map((p, i) => ({
|
|
9656
|
-
name:
|
|
10169
|
+
name: path39.basename(p),
|
|
9657
10170
|
root: p,
|
|
9658
10171
|
resolvedBase: resolved[i].resolvedBase,
|
|
9659
10172
|
files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
|
|
@@ -9673,10 +10186,10 @@ async function startWebServer(opts = {}) {
|
|
|
9673
10186
|
for (const cb of sseListeners) cb({ event, data });
|
|
9674
10187
|
};
|
|
9675
10188
|
const home = os12.homedir();
|
|
9676
|
-
const historyPath =
|
|
10189
|
+
const historyPath = path39.join(home, ".work", "history.json");
|
|
9677
10190
|
const onHistoryChange = () => broadcast("sessions-changed", { ts: Date.now() });
|
|
9678
10191
|
fs40.watchFile(historyPath, { interval: 1e3 }, onHistoryChange);
|
|
9679
|
-
const tasksPath =
|
|
10192
|
+
const tasksPath = path39.join(home, ".work", "tasks.json");
|
|
9680
10193
|
const onTasksChange = () => broadcast("tasks-changed", { ts: Date.now() });
|
|
9681
10194
|
fs40.watchFile(tasksPath, { interval: 1e3 }, onTasksChange);
|
|
9682
10195
|
const projectsRoot = claudeProjectsRoot();
|
|
@@ -9821,10 +10334,10 @@ function info2(message) {
|
|
|
9821
10334
|
process.stderr.write(message + "\n");
|
|
9822
10335
|
}
|
|
9823
10336
|
function urlFilePath() {
|
|
9824
|
-
return
|
|
10337
|
+
return path40.join(os13.homedir(), ".work", "web.url");
|
|
9825
10338
|
}
|
|
9826
10339
|
function pidFilePath() {
|
|
9827
|
-
return
|
|
10340
|
+
return path40.join(os13.homedir(), ".work", "web.pid");
|
|
9828
10341
|
}
|
|
9829
10342
|
function isPidAlive(pid) {
|
|
9830
10343
|
try {
|
|
@@ -9949,7 +10462,7 @@ var webCommand = {
|
|
|
9949
10462
|
const lean = !!argv.lean || process.env.WORK_WEB_LEAN === "1";
|
|
9950
10463
|
const handle = await startWebServer({ lean });
|
|
9951
10464
|
try {
|
|
9952
|
-
fs41.mkdirSync(
|
|
10465
|
+
fs41.mkdirSync(path40.dirname(urlFilePath()), { recursive: true });
|
|
9953
10466
|
fs41.writeFileSync(urlFilePath(), handle.url);
|
|
9954
10467
|
fs41.writeFileSync(pidFilePath(), String(process.pid));
|
|
9955
10468
|
} catch {
|
|
@@ -10487,7 +11000,7 @@ var broadcastCommand = {
|
|
|
10487
11000
|
|
|
10488
11001
|
// src/completions/index.ts
|
|
10489
11002
|
import fs44 from "fs";
|
|
10490
|
-
import
|
|
11003
|
+
import path41 from "path";
|
|
10491
11004
|
function completionHandler(current, argv, done) {
|
|
10492
11005
|
const rawArgs = argv._;
|
|
10493
11006
|
const args = rawArgs.slice(1, -1);
|
|
@@ -10600,18 +11113,18 @@ function completeRepoBranches(alias, current, config, done) {
|
|
|
10600
11113
|
done(branches);
|
|
10601
11114
|
}
|
|
10602
11115
|
function completeGroupBranches(groupName, repoAliases, current, config, done) {
|
|
10603
|
-
const groupDir =
|
|
11116
|
+
const groupDir = path41.join(config.worktreesRoot, groupName);
|
|
10604
11117
|
if (!fs44.existsSync(groupDir)) {
|
|
10605
11118
|
done([]);
|
|
10606
11119
|
return;
|
|
10607
11120
|
}
|
|
10608
11121
|
try {
|
|
10609
11122
|
const branchDirs = fs44.readdirSync(groupDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => {
|
|
10610
|
-
const bdPath =
|
|
11123
|
+
const bdPath = path41.join(groupDir, d.name);
|
|
10611
11124
|
for (const alias of repoAliases) {
|
|
10612
11125
|
const repoPath = config.repos[alias];
|
|
10613
11126
|
if (!repoPath) continue;
|
|
10614
|
-
const subPath =
|
|
11127
|
+
const subPath = path41.join(bdPath, path41.basename(repoPath));
|
|
10615
11128
|
if (fs44.existsSync(subPath)) {
|
|
10616
11129
|
const branch = getCurrentBranch(subPath);
|
|
10617
11130
|
if (branch) return branch;
|
|
@@ -10626,7 +11139,7 @@ function completeGroupBranches(groupName, repoAliases, current, config, done) {
|
|
|
10626
11139
|
}
|
|
10627
11140
|
|
|
10628
11141
|
// src/version.ts
|
|
10629
|
-
var VERSION = true ? "1.
|
|
11142
|
+
var VERSION = true ? "1.8.5" : "dev";
|
|
10630
11143
|
|
|
10631
11144
|
// src/cli.ts
|
|
10632
11145
|
function showHelp() {
|
|
@@ -10724,7 +11237,7 @@ function handleFatalError(err) {
|
|
|
10724
11237
|
if (err instanceof Error && err.message?.includes("pty that has already exited")) {
|
|
10725
11238
|
try {
|
|
10726
11239
|
fs45.appendFileSync(
|
|
10727
|
-
|
|
11240
|
+
path42.join(getConfigDir(), "debug.log"),
|
|
10728
11241
|
`${(/* @__PURE__ */ new Date()).toISOString()} [WARN] Ignored async node-pty error: ${err.message}
|
|
10729
11242
|
`
|
|
10730
11243
|
);
|
|
@@ -10735,7 +11248,7 @@ function handleFatalError(err) {
|
|
|
10735
11248
|
try {
|
|
10736
11249
|
const msg = err instanceof Error ? err.stack || err.message : String(err);
|
|
10737
11250
|
fs45.appendFileSync(
|
|
10738
|
-
|
|
11251
|
+
path42.join(getConfigDir(), "debug.log"),
|
|
10739
11252
|
`${(/* @__PURE__ */ new Date()).toISOString()} [FATAL] handleFatalError: ${msg}
|
|
10740
11253
|
`
|
|
10741
11254
|
);
|