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