rex-worktrees 0.4.4 → 0.4.6
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/README.md +16 -8
- package/dist/rex-worktrees +2 -2
- package/dist/rex-worktrees.js +390 -250
- package/package.json +1 -1
package/dist/rex-worktrees.js
CHANGED
|
@@ -20663,6 +20663,13 @@ var layer7 = /* @__PURE__ */ succeed5(Stdio, /* @__PURE__ */ make29({
|
|
|
20663
20663
|
// node_modules/@effect/platform-bun/dist/BunStdio.js
|
|
20664
20664
|
var layer8 = layer7;
|
|
20665
20665
|
|
|
20666
|
+
// node_modules/@effect/platform-bun/dist/BunTerminal.js
|
|
20667
|
+
var exports_BunTerminal = {};
|
|
20668
|
+
__export(exports_BunTerminal, {
|
|
20669
|
+
make: () => make44,
|
|
20670
|
+
layer: () => layer10
|
|
20671
|
+
});
|
|
20672
|
+
|
|
20666
20673
|
// node_modules/effect/dist/Terminal.js
|
|
20667
20674
|
var exports_Terminal = {};
|
|
20668
20675
|
__export(exports_Terminal, {
|
|
@@ -33411,6 +33418,7 @@ function defaultShouldQuit(input) {
|
|
|
33411
33418
|
}
|
|
33412
33419
|
|
|
33413
33420
|
// node_modules/@effect/platform-bun/dist/BunTerminal.js
|
|
33421
|
+
var make44 = make43;
|
|
33414
33422
|
var layer10 = layer9;
|
|
33415
33423
|
|
|
33416
33424
|
// node_modules/@effect/platform-bun/dist/BunServices.js
|
|
@@ -33622,7 +33630,9 @@ var GitCloneInputSchema = exports_Schema.Struct({
|
|
|
33622
33630
|
name: exports_Schema.String,
|
|
33623
33631
|
branch: exports_Schema.String,
|
|
33624
33632
|
branchMode: exports_Schema.Literals(["existing", "create"]),
|
|
33625
|
-
worktreeName: exports_Schema.optional(exports_Schema.String)
|
|
33633
|
+
worktreeName: exports_Schema.optional(exports_Schema.String),
|
|
33634
|
+
checkout: exports_Schema.optional(exports_Schema.Literals(["primary", "worktree"])),
|
|
33635
|
+
directory: exports_Schema.optional(exports_Schema.String)
|
|
33626
33636
|
});
|
|
33627
33637
|
var JjCloneInputSchema = exports_Schema.Struct({
|
|
33628
33638
|
vcs: exports_Schema.Literal("jj"),
|
|
@@ -33632,7 +33642,9 @@ var JjCloneInputSchema = exports_Schema.Struct({
|
|
|
33632
33642
|
clientId: exports_Schema.optional(ClientIdSchema),
|
|
33633
33643
|
name: exports_Schema.String,
|
|
33634
33644
|
worktreeName: exports_Schema.optional(exports_Schema.String),
|
|
33635
|
-
revision: exports_Schema.optional(exports_Schema.String)
|
|
33645
|
+
revision: exports_Schema.optional(exports_Schema.String),
|
|
33646
|
+
checkout: exports_Schema.optional(exports_Schema.Literals(["primary", "worktree"])),
|
|
33647
|
+
directory: exports_Schema.optional(exports_Schema.String)
|
|
33636
33648
|
});
|
|
33637
33649
|
var CloneInputSchema = exports_Schema.Union([GitCloneInputSchema, JjCloneInputSchema]);
|
|
33638
33650
|
var ClonePlanFields = {
|
|
@@ -33674,7 +33686,8 @@ var LaunchInputFields = {
|
|
|
33674
33686
|
name: exports_Schema.String,
|
|
33675
33687
|
clientId: exports_Schema.optional(ClientIdSchema),
|
|
33676
33688
|
additional: exports_Schema.optional(exports_Schema.Boolean),
|
|
33677
|
-
split: exports_Schema.optional(exports_Schema.Boolean)
|
|
33689
|
+
split: exports_Schema.optional(exports_Schema.Boolean),
|
|
33690
|
+
directory: exports_Schema.optional(exports_Schema.String)
|
|
33678
33691
|
};
|
|
33679
33692
|
var GitLaunchInputSchema = exports_Schema.Struct({
|
|
33680
33693
|
...LaunchInputFields,
|
|
@@ -33773,10 +33786,10 @@ var RequestSchema = exports_Schema.Union([
|
|
|
33773
33786
|
var ResponseSchema = exports_Schema.Union([
|
|
33774
33787
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("discover"), sessions: exports_Schema.Array(SessionTargetSchema), clients: exports_Schema.Array(ClientTargetSchema), projects: exports_Schema.Array(RepositorySchema), roots: exports_Schema.optional(exports_Schema.Array(exports_Schema.String)), cloneRoot: exports_Schema.String, checkout: exports_Schema.optional(RepositorySchema) }),
|
|
33775
33788
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("sessions"), sessions: exports_Schema.Array(SessionTargetSchema), clients: exports_Schema.Array(ClientTargetSchema) }),
|
|
33776
|
-
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("project"), project: RepositorySchema, checkout: RepositorySchema, worktrees: exports_Schema.Array(WorktreeSchema), branches: exports_Schema.Array(exports_Schema.String), revisions: exports_Schema.Array(JjRevisionChoiceSchema) }),
|
|
33789
|
+
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("project"), project: RepositorySchema, checkout: RepositorySchema, worktrees: exports_Schema.Array(WorktreeSchema), branches: exports_Schema.Array(exports_Schema.String), revisions: exports_Schema.Array(JjRevisionChoiceSchema), worktreeRoot: exports_Schema.optional(exports_Schema.String) }),
|
|
33777
33790
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("project-missing"), path: exports_Schema.String }),
|
|
33778
33791
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("clone-source"), source: CloneSourceSchema }),
|
|
33779
|
-
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("worktrees"), repository: RepositorySchema, worktrees: exports_Schema.Array(WorktreeSchema), branches: exports_Schema.Array(exports_Schema.String), revisions: exports_Schema.Array(JjRevisionChoiceSchema) }),
|
|
33792
|
+
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("worktrees"), repository: RepositorySchema, worktrees: exports_Schema.Array(WorktreeSchema), branches: exports_Schema.Array(exports_Schema.String), revisions: exports_Schema.Array(JjRevisionChoiceSchema), worktreeRoot: exports_Schema.optional(exports_Schema.String) }),
|
|
33780
33793
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("revision"), revision: JjRevisionSchema }),
|
|
33781
33794
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("plan"), plan: LaunchPlanSchema }),
|
|
33782
33795
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("clone-plan"), plan: ClonePlanSchema }),
|
|
@@ -33803,12 +33816,34 @@ var RexWindowsSchema = exports_Schema.Struct({
|
|
|
33803
33816
|
layers: exports_Schema.Array(exports_Schema.Struct({ blocks: exports_Schema.optional(exports_Schema.Array(exports_Schema.Struct({ block_id: BlockIdSchema, host_id: ServerHostIdSchema }))) }))
|
|
33804
33817
|
}))
|
|
33805
33818
|
});
|
|
33819
|
+
var popupSize = { columns: 80, rows: 16 };
|
|
33820
|
+
var RexTerminalSizeSchema = exports_Schema.Struct({
|
|
33821
|
+
columns: exports_Schema.Int.check(exports_Schema.isGreaterThan(0)),
|
|
33822
|
+
rows: exports_Schema.Int.check(exports_Schema.isGreaterThan(0))
|
|
33823
|
+
});
|
|
33824
|
+
|
|
33825
|
+
class RexLayoutNode extends exports_Schema.Class("RexLayoutNode")({
|
|
33826
|
+
rect: exports_Schema.Tuple([exports_Schema.Finite, exports_Schema.Finite, exports_Schema.Finite, exports_Schema.Finite]),
|
|
33827
|
+
block_id: exports_Schema.optional(exports_Schema.NullOr(BlockIdSchema)),
|
|
33828
|
+
split: exports_Schema.optional(exports_Schema.NullOr(exports_Schema.Struct({
|
|
33829
|
+
before: exports_Schema.suspend(() => RexLayoutNode),
|
|
33830
|
+
after: exports_Schema.suspend(() => RexLayoutNode)
|
|
33831
|
+
})))
|
|
33832
|
+
}) {
|
|
33833
|
+
}
|
|
33806
33834
|
var RexViewSchema = exports_Schema.Struct({
|
|
33807
33835
|
active_window_id: exports_Schema.NullOr(WindowIdSchema),
|
|
33808
33836
|
windows: exports_Schema.Array(exports_Schema.Struct({
|
|
33809
33837
|
window_id: WindowIdSchema,
|
|
33838
|
+
focused_block_id: exports_Schema.optional(exports_Schema.NullOr(BlockIdSchema)),
|
|
33839
|
+
zoomed_block_id: exports_Schema.optional(exports_Schema.NullOr(BlockIdSchema)),
|
|
33810
33840
|
layers: exports_Schema.Array(exports_Schema.Struct({
|
|
33811
|
-
|
|
33841
|
+
layout: exports_Schema.NullOr(RexLayoutNode),
|
|
33842
|
+
blocks: exports_Schema.Array(exports_Schema.Struct({
|
|
33843
|
+
block_id: BlockIdSchema,
|
|
33844
|
+
flavor: exports_Schema.String,
|
|
33845
|
+
owner: exports_Schema.optional(exports_Schema.NullOr(ClientIdSchema))
|
|
33846
|
+
}))
|
|
33812
33847
|
}))
|
|
33813
33848
|
}))
|
|
33814
33849
|
});
|
|
@@ -33989,14 +34024,14 @@ var originDefaultHead = exports_Effect.fnUntraced(function* (repoPath) {
|
|
|
33989
34024
|
const ref = yield* git(repoPath, "symbolic-ref", "--quiet", "refs/remotes/origin/HEAD").pipe(exports_Effect.catch(() => fail17("Cannot determine the existing repository's cached origin default branch")));
|
|
33990
34025
|
return (yield* git(repoPath, "rev-parse", "--verify", `${ref.trim()}^{commit}`)).trim();
|
|
33991
34026
|
});
|
|
33992
|
-
var cloneRepository = exports_Effect.fnUntraced(function* (url, destination) {
|
|
34027
|
+
var cloneRepository = exports_Effect.fnUntraced(function* (url, destination, branch) {
|
|
33993
34028
|
const spawner = yield* exports_ChildProcessSpawner.ChildProcessSpawner;
|
|
33994
34029
|
const env = {};
|
|
33995
34030
|
for (const [key5, value3] of Object.entries(process.env))
|
|
33996
34031
|
if (!key5.startsWith("GIT_") && value3 !== undefined)
|
|
33997
34032
|
env[key5] = value3;
|
|
33998
34033
|
env.GIT_TERMINAL_PROMPT = "1";
|
|
33999
|
-
const child = yield* spawner.spawn(exports_ChildProcess.make("git", ["clone", "--origin", "origin", "--", url, destination], {
|
|
34034
|
+
const child = yield* spawner.spawn(exports_ChildProcess.make("git", ["clone", "--origin", "origin", ...branch ? ["--branch", branch] : [], "--", url, destination], {
|
|
34000
34035
|
env,
|
|
34001
34036
|
detached: false,
|
|
34002
34037
|
stdin: "inherit",
|
|
@@ -34007,6 +34042,9 @@ var cloneRepository = exports_Effect.fnUntraced(function* (url, destination) {
|
|
|
34007
34042
|
if (code !== 0)
|
|
34008
34043
|
return yield* fail17(`Git clone failed (exit ${code}); destination retained at ${destination}`);
|
|
34009
34044
|
}, exports_Effect.scoped);
|
|
34045
|
+
var createPrimaryBranch = exports_Effect.fnUntraced(function* (repoPath, branch) {
|
|
34046
|
+
yield* git(repoPath, "switch", "-c", branch);
|
|
34047
|
+
});
|
|
34010
34048
|
var validCloneBranch = exports_Effect.fnUntraced(function* (branch, worktreeName) {
|
|
34011
34049
|
if (!branch || branch.startsWith("-") || branch.split("/").some((part) => !part || part === "." || part === "..") || /[\p{ASCII}&&\p{Cc}]/v.test(branch))
|
|
34012
34050
|
return yield* fail17("Invalid clone branch");
|
|
@@ -34636,29 +34674,43 @@ var focus = exports_Effect.fnUntraced(function* (sessionId, windowId, clientId,
|
|
|
34636
34674
|
}
|
|
34637
34675
|
return warnings.length ? warnings.join("; ") : undefined;
|
|
34638
34676
|
});
|
|
34677
|
+
var findPane = (node, blockId) => !node ? undefined : node.block_id === blockId ? node : node.split ? findPane(node.split.before, blockId) ?? findPane(node.split.after, blockId) : undefined;
|
|
34639
34678
|
var openPopup = exports_Effect.fnUntraced(function* (command, sessionId, origin2 = {}) {
|
|
34640
34679
|
const path = yield* exports_Path.Path;
|
|
34641
34680
|
const endpoint = (yield* localIdentity).endpoint;
|
|
34642
34681
|
const program = yield* binary(path);
|
|
34643
34682
|
const localRex = (args3) => run4(program, ["-S", endpoint, "--autostart=false", ...args3], undefined, nativeEnv());
|
|
34644
34683
|
const view = yield* parse3(RexViewSchema, yield* localRex(["api", "call", "-s", sessionId, "session.view", JSON.stringify({ session_id: sessionId })]));
|
|
34645
|
-
const source = origin2.blockId ? view.windows.find((
|
|
34684
|
+
const source = origin2.blockId ? view.windows.find((window2) => window2.layers.some((layer12) => layer12.blocks.some((block) => block.block_id === origin2.blockId))) : undefined;
|
|
34646
34685
|
if (origin2.blockId && !source)
|
|
34647
34686
|
return yield* exports_Effect.fail(new AppError({ message: "Source pane is no longer in the selected Rex session" }));
|
|
34648
34687
|
const windowId = source?.window_id ?? view.active_window_id;
|
|
34649
|
-
|
|
34688
|
+
const window = view.windows.find((window2) => window2.window_id === windowId);
|
|
34689
|
+
if (!windowId || !window) {
|
|
34650
34690
|
return yield* exports_Effect.fail(new AppError({ message: "No active Rex window for the popup" }));
|
|
34651
34691
|
}
|
|
34652
34692
|
const sourceOwner = source?.layers.flatMap((layer12) => layer12.blocks).find((block) => block.block_id === origin2.blockId)?.owner;
|
|
34653
34693
|
const clients = (yield* parse3(RexClientsSchema, yield* localRex(["client", "ls", "--json"]))).clients.filter((client) => client.info?.kind === "app" && client.connection_state === "connected");
|
|
34654
34694
|
const clientId = [sourceOwner, origin2.clientId].find((id2) => id2 && clients.some((client) => client.client_id === id2));
|
|
34655
34695
|
const popupCommand = clientId ? [...command, "--managed-popup", "--origin-client", clientId] : [...command, "--managed-popup"];
|
|
34656
|
-
const
|
|
34696
|
+
const blocks = window.layers.flatMap((layer12) => layer12.blocks);
|
|
34697
|
+
const terminals = blocks.filter((block) => block.flavor === "com.superlogical.terminal.shell");
|
|
34698
|
+
const terminal = terminals.find((block) => block.block_id === origin2.blockId) ?? terminals.find((block) => block.block_id === window.focused_block_id) ?? terminals[0];
|
|
34699
|
+
let width2 = 1, height = 1;
|
|
34700
|
+
if (terminal) {
|
|
34701
|
+
const pane = window.layers.map((layer12) => findPane(layer12.layout, terminal.block_id)).find((node) => node !== undefined);
|
|
34702
|
+
if (!pane)
|
|
34703
|
+
return yield* exports_Effect.fail(new AppError({ message: "Rex terminal geometry changed before opening the popup" }));
|
|
34704
|
+
const size8 = yield* parse3(RexTerminalSizeSchema, yield* localRex(["block", "call", "-s", sessionId, "-b", terminal.block_id, "size"]));
|
|
34705
|
+
const zoomed = window.zoomed_block_id === terminal.block_id;
|
|
34706
|
+
width2 = Math.min(1, (popupSize.columns + 2) * (zoomed ? 1 : pane.rect[2]) / size8.columns);
|
|
34707
|
+
height = Math.min(1, (popupSize.rows + 3) * (zoomed ? 1 : pane.rect[3]) / size8.rows);
|
|
34708
|
+
}
|
|
34657
34709
|
const args2 = {
|
|
34658
34710
|
session_id: sessionId,
|
|
34659
34711
|
window_id: windowId,
|
|
34660
34712
|
bounds: [(1 - width2) / 2, (1 - height) / 2, width2, height],
|
|
34661
|
-
layout: { block: { flavor: "com.superlogical.terminal.shell", options: { command: commandWithPath(popupCommand), shell: "none", cwd: process.cwd(), exit: { on_completion: true } } } },
|
|
34713
|
+
layout: { block: { flavor: "com.superlogical.terminal.shell", options: { command: commandWithPath(popupCommand), shell: "none", cwd: process.cwd(), size: popupSize, exit: { on_completion: true } } } },
|
|
34662
34714
|
focus: true
|
|
34663
34715
|
};
|
|
34664
34716
|
const created = yield* parse3(RexLayerSchema, yield* localRex(["api", "call", "-s", sessionId, "session.new_layer", JSON.stringify(args2)]));
|
|
@@ -34789,6 +34841,11 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34789
34841
|
const repo = yield* repository3(input.repo);
|
|
34790
34842
|
if (repo.vcs !== input.vcs)
|
|
34791
34843
|
return yield* fail19("Repository backend changed since selection");
|
|
34844
|
+
const pathService = yield* exports_Path.Path;
|
|
34845
|
+
if (input.directory !== undefined && (!pathService.isAbsolute(input.directory) || pathService.resolve(input.directory) !== input.directory || input.directory === pathService.parse(input.directory).root))
|
|
34846
|
+
return yield* fail19("Worktree directory must be a normalized absolute directory");
|
|
34847
|
+
if (input.directory !== undefined && input.path !== undefined)
|
|
34848
|
+
return yield* fail19("Directory cannot be combined with an existing worktree path");
|
|
34792
34849
|
let path;
|
|
34793
34850
|
let checkout;
|
|
34794
34851
|
let branch = null;
|
|
@@ -34802,9 +34859,11 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34802
34859
|
return yield* fail19("Select exactly one branch or existing worktree path");
|
|
34803
34860
|
if (input.path && input.worktreeName !== undefined)
|
|
34804
34861
|
return yield* fail19("Worktree name only applies to a branch checkout");
|
|
34805
|
-
worktreeRoot = input.branch ? yield* resolveWorktreeRoot(repo.path) : undefined;
|
|
34862
|
+
worktreeRoot = input.branch ? input.directory ? pathService.dirname(input.directory) : yield* resolveWorktreeRoot(repo.path) : undefined;
|
|
34806
34863
|
if (input.branch) {
|
|
34807
|
-
const destination = yield* planWorktree(repo.path, input.branch, worktreeRoot, input.worktreeName);
|
|
34864
|
+
const destination = yield* planWorktree(repo.path, input.branch, worktreeRoot, input.directory ? pathService.basename(input.directory) : input.worktreeName);
|
|
34865
|
+
if (input.directory && destination.path !== input.directory)
|
|
34866
|
+
return yield* fail19("Branch is already checked out at a different directory");
|
|
34808
34867
|
path = destination.path;
|
|
34809
34868
|
branch = input.branch;
|
|
34810
34869
|
checkout = destination.existing ? "existing" : (yield* listBranches(repo.path)).includes(branch) ? "attach" : "create";
|
|
@@ -34832,7 +34891,9 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34832
34891
|
workspaceName = tree.name;
|
|
34833
34892
|
checkout = "existing";
|
|
34834
34893
|
} else {
|
|
34835
|
-
|
|
34894
|
+
if (input.directory && pathService.basename(input.directory) !== input.worktreeName)
|
|
34895
|
+
return yield* fail19("Workspace name must match the directory name");
|
|
34896
|
+
worktreeRoot = input.directory ? pathService.dirname(input.directory) : yield* resolveWorktreeRoot(repo.path);
|
|
34836
34897
|
const planned = yield* planWorkspace(repo.path, input.worktreeName, input.revision, worktreeRoot);
|
|
34837
34898
|
path = planned.path;
|
|
34838
34899
|
workspaceName = planned.workspaceName;
|
|
@@ -34881,7 +34942,7 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34881
34942
|
return {
|
|
34882
34943
|
...common,
|
|
34883
34944
|
vcs: "git",
|
|
34884
|
-
input: { ...input, repo: repo.path, ...input.path ? { path } : {} },
|
|
34945
|
+
input: { ...input, repo: repo.path, ...input.path ? { path } : {}, ...input.directory ? { worktreeName: pathService.basename(input.directory) } : {} },
|
|
34885
34946
|
branch,
|
|
34886
34947
|
checkout,
|
|
34887
34948
|
...gitBase ? { base: gitBase } : {},
|
|
@@ -34897,7 +34958,7 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34897
34958
|
label: action === "focus" ? "Focus existing tab" : checkout === "create" ? "Create workspace & open" : action === "split" ? "Open pane" : "Open tab"
|
|
34898
34959
|
};
|
|
34899
34960
|
});
|
|
34900
|
-
var sameLaunchPlan = (a, b) => a.vcs === b.vcs && a.input.vcs === b.input.vcs && a.hostId === b.hostId && a.worktreeRoot === b.worktreeRoot && a.clientId === b.clientId && a.input.repo === b.input.repo && sameSession(a.input.session, b.input.session) && a.input.path === b.input.path && a.input.worktreeName === b.input.worktreeName && a.input.name === b.input.name && a.input.clientId === b.input.clientId && a.input.additional === b.input.additional && a.input.split === b.input.split && a.path === b.path && a.checkout === b.checkout && a.action === b.action && a.nameRole === b.nameRole && a.name === b.name && a.target?.windowId === b.target?.windowId && a.target?.blockId === b.target?.blockId && a.target?.label === b.target?.label && (a.vcs === "git" && b.vcs === "git" && a.input.vcs === "git" && b.input.vcs === "git" ? a.input.branch === b.input.branch && a.branch === b.branch && a.base?.head === b.base?.head && a.base?.branch === b.base?.branch : a.vcs === "jj" && b.vcs === "jj" && a.input.vcs === "jj" && b.input.vcs === "jj" && a.input.revision === b.input.revision && a.workspaceName === b.workspaceName && a.base?.commitId === b.base?.commitId && a.base?.changeId === b.base?.changeId);
|
|
34961
|
+
var sameLaunchPlan = (a, b) => a.vcs === b.vcs && a.input.vcs === b.input.vcs && a.hostId === b.hostId && a.worktreeRoot === b.worktreeRoot && a.clientId === b.clientId && a.input.repo === b.input.repo && sameSession(a.input.session, b.input.session) && a.input.path === b.input.path && a.input.directory === b.input.directory && a.input.worktreeName === b.input.worktreeName && a.input.name === b.input.name && a.input.clientId === b.input.clientId && a.input.additional === b.input.additional && a.input.split === b.input.split && a.path === b.path && a.checkout === b.checkout && a.action === b.action && a.nameRole === b.nameRole && a.name === b.name && a.target?.windowId === b.target?.windowId && a.target?.blockId === b.target?.blockId && a.target?.label === b.target?.label && (a.vcs === "git" && b.vcs === "git" && a.input.vcs === "git" && b.input.vcs === "git" ? a.input.branch === b.input.branch && a.branch === b.branch && a.base?.head === b.base?.head && a.base?.branch === b.base?.branch : a.vcs === "jj" && b.vcs === "jj" && a.input.vcs === "jj" && b.input.vcs === "jj" && a.input.revision === b.input.revision && a.workspaceName === b.workspaceName && a.base?.commitId === b.base?.commitId && a.base?.changeId === b.base?.changeId);
|
|
34901
34962
|
var launch = exports_Effect.fnUntraced(function* (input, command, reviewed, expectedHostId) {
|
|
34902
34963
|
const pathService = yield* exports_Path.Path;
|
|
34903
34964
|
if (!command[0] || !pathService.isAbsolute(command[0]))
|
|
@@ -35109,12 +35170,26 @@ var checkCloneParent = exports_Effect.fnUntraced(function* (destination) {
|
|
|
35109
35170
|
catch: (cause) => new AppError({ message: `Cannot create clone destination ${destination}: ${ancestor} is not writable; choose another destination or fix its permissions`, cause })
|
|
35110
35171
|
});
|
|
35111
35172
|
});
|
|
35173
|
+
var validateCloneDestination = exports_Effect.fnUntraced(function* (input) {
|
|
35174
|
+
const path = yield* exports_Path.Path;
|
|
35175
|
+
if (input.directory !== undefined) {
|
|
35176
|
+
if (!path.isAbsolute(input.directory) || path.resolve(input.directory) !== input.directory || input.directory === path.parse(input.directory).root)
|
|
35177
|
+
return yield* fail19("Worktree directory must be a normalized absolute directory");
|
|
35178
|
+
if (input.checkout !== "worktree")
|
|
35179
|
+
return yield* fail19("Worktree directory requires a worktree checkout");
|
|
35180
|
+
}
|
|
35181
|
+
if (input.checkout === "primary" && input.worktreeName !== undefined)
|
|
35182
|
+
return yield* fail19("Primary checkout cannot have a worktree name");
|
|
35183
|
+
if (input.checkout === "worktree" && input.vcs === "jj" && !input.directory && !input.worktreeName)
|
|
35184
|
+
return yield* fail19("JJ worktree checkout requires a workspace name or directory");
|
|
35185
|
+
});
|
|
35112
35186
|
var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
35113
35187
|
const host = yield* localHost;
|
|
35114
35188
|
if (expectedHostId && host.id !== expectedHostId)
|
|
35115
35189
|
return yield* fail19("Wrong Rex clone host");
|
|
35116
35190
|
if (input.vcs !== input.source.vcs)
|
|
35117
35191
|
return yield* fail19("Clone source backend does not match request");
|
|
35192
|
+
yield* validateCloneDestination(input);
|
|
35118
35193
|
yield* exports_Schema.decodeUnknownEffect(SessionSelectionSchema)(input.session);
|
|
35119
35194
|
if (input.session.kind === "existing") {
|
|
35120
35195
|
const sessionId = input.session.id;
|
|
@@ -35138,6 +35213,8 @@ var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
35138
35213
|
if (commonDir === undefined)
|
|
35139
35214
|
yield* checkCloneParent(input.repo);
|
|
35140
35215
|
const existing = commonDir !== undefined;
|
|
35216
|
+
if (existing && input.checkout === "primary" && input.vcs === "git" && (input.branchMode !== "existing" || (yield* repositoryHead(input.repo)).branch !== input.branch))
|
|
35217
|
+
return yield* fail19("Existing primary checkout is not on the requested branch");
|
|
35141
35218
|
let gitBase;
|
|
35142
35219
|
let base;
|
|
35143
35220
|
if (input.vcs === "git") {
|
|
@@ -35156,9 +35233,14 @@ var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
35156
35233
|
}
|
|
35157
35234
|
if (input.vcs === "jj" && existing && !base)
|
|
35158
35235
|
base = yield* resolveRevision(input.repo, "@-");
|
|
35236
|
+
if (input.vcs === "jj" && existing && input.checkout === "primary" && base) {
|
|
35237
|
+
const current = yield* resolveRevision(input.repo, "@-");
|
|
35238
|
+
if (current.commitId !== base.commitId || current.changeId !== base.changeId)
|
|
35239
|
+
return yield* fail19("Existing primary workspace is not based on the requested revision");
|
|
35240
|
+
}
|
|
35159
35241
|
const clientId = input.clientId ?? (clients.length === 1 ? clients[0]?.id : undefined);
|
|
35160
35242
|
const warning = !clientId && clients.length > 1 ? "Multiple Rex apps are connected; select the intended app" : undefined;
|
|
35161
|
-
const snapshotDetail = input.vcs === "jj" && (input.worktreeName || existing) ? `JJ ${input.worktreeName ? "workspace creation" : "new change"} snapshots the destination workspace at ${input.repo}; its working-copy commit and colocated Git index intent-to-add entries may change.` : undefined;
|
|
35243
|
+
const snapshotDetail = input.vcs === "jj" && input.checkout !== "primary" && (input.directory || input.worktreeName || existing) ? `JJ ${input.directory || input.worktreeName ? "workspace creation" : "new change"} snapshots the destination workspace at ${input.repo}; its working-copy commit and colocated Git index intent-to-add entries may change.` : undefined;
|
|
35162
35244
|
const common = {
|
|
35163
35245
|
hostId: host.id,
|
|
35164
35246
|
...clientId ? { clientId } : {},
|
|
@@ -35183,7 +35265,7 @@ var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
35183
35265
|
...base ? { base } : {}
|
|
35184
35266
|
};
|
|
35185
35267
|
});
|
|
35186
|
-
var sameClonePlan = (a, b) => a.vcs === b.vcs && a.input.vcs === b.input.vcs && a.hostId === b.hostId && a.clientId === b.clientId && a.repo === b.repo && a.existing === b.existing && a.commonDir === b.commonDir && a.input.repo === b.input.repo && sameSession(a.input.session, b.input.session) && a.input.clientId === b.input.clientId && a.input.name === b.input.name && a.input.worktreeName === b.input.worktreeName && a.input.source.url === b.input.source.url && a.input.source.sourceHostId === b.input.source.sourceHostId && (a.vcs === "git" && b.vcs === "git" && a.input.vcs === "git" && b.input.vcs === "git" ? a.base === b.base && a.input.branch === b.input.branch && a.input.branchMode === b.input.branchMode && a.input.source.branch === b.input.source.branch && a.input.source.branches.length === b.input.source.branches.length && a.input.source.branches.every((branch, index2) => branch === b.input.source.branches[index2]) : a.vcs === "jj" && b.vcs === "jj" && a.input.vcs === "jj" && b.input.vcs === "jj" && a.base?.commitId === b.base?.commitId && a.base?.changeId === b.base?.changeId && a.input.revision === b.input.revision && a.input.source.revision?.commitId === b.input.source.revision?.commitId && a.input.source.revision?.changeId === b.input.source.revision?.changeId && a.input.source.revisions.length === b.input.source.revisions.length && a.input.source.revisions.every((choice, index2) => choice.expression === b.input.source.revisions[index2]?.expression && choice.revision.commitId === b.input.source.revisions[index2]?.revision.commitId && choice.revision.changeId === b.input.source.revisions[index2]?.revision.changeId));
|
|
35268
|
+
var sameClonePlan = (a, b) => a.vcs === b.vcs && a.input.vcs === b.input.vcs && a.hostId === b.hostId && a.clientId === b.clientId && a.repo === b.repo && a.existing === b.existing && a.commonDir === b.commonDir && a.input.repo === b.input.repo && sameSession(a.input.session, b.input.session) && a.input.clientId === b.input.clientId && a.input.name === b.input.name && a.input.worktreeName === b.input.worktreeName && a.input.directory === b.input.directory && a.input.checkout === b.input.checkout && a.input.source.url === b.input.source.url && a.input.source.sourceHostId === b.input.source.sourceHostId && (a.vcs === "git" && b.vcs === "git" && a.input.vcs === "git" && b.input.vcs === "git" ? a.base === b.base && a.input.branch === b.input.branch && a.input.branchMode === b.input.branchMode && a.input.source.branch === b.input.source.branch && a.input.source.branches.length === b.input.source.branches.length && a.input.source.branches.every((branch, index2) => branch === b.input.source.branches[index2]) : a.vcs === "jj" && b.vcs === "jj" && a.input.vcs === "jj" && b.input.vcs === "jj" && a.base?.commitId === b.base?.commitId && a.base?.changeId === b.base?.changeId && a.input.revision === b.input.revision && a.input.source.revision?.commitId === b.input.source.revision?.commitId && a.input.source.revision?.changeId === b.input.source.revision?.changeId && a.input.source.revisions.length === b.input.source.revisions.length && a.input.source.revisions.every((choice, index2) => choice.expression === b.input.source.revisions[index2]?.expression && choice.revision.commitId === b.input.source.revisions[index2]?.revision.commitId && choice.revision.changeId === b.input.source.revisions[index2]?.revision.changeId));
|
|
35187
35269
|
var launchClone = exports_Effect.fnUntraced(function* (input, command, reviewed, expectedHostId) {
|
|
35188
35270
|
const path = yield* exports_Path.Path;
|
|
35189
35271
|
if (!command[0] || !path.isAbsolute(command[0]))
|
|
@@ -35206,6 +35288,9 @@ var launchClone = exports_Effect.fnUntraced(function* (input, command, reviewed,
|
|
|
35206
35288
|
return result4;
|
|
35207
35289
|
});
|
|
35208
35290
|
var prepareCloneCheckout = exports_Effect.fnUntraced(function* (plan) {
|
|
35291
|
+
yield* validateCloneDestination(plan.input);
|
|
35292
|
+
if (plan.repo !== plan.input.repo)
|
|
35293
|
+
return yield* fail19("Clone destination changed since review");
|
|
35209
35294
|
if (plan.vcs === "git")
|
|
35210
35295
|
yield* validCloneBranch(plan.input.branch, plan.input.worktreeName);
|
|
35211
35296
|
const url = yield* exports_Effect.try({
|
|
@@ -35237,7 +35322,7 @@ var prepareCloneCheckout = exports_Effect.fnUntraced(function* (plan) {
|
|
|
35237
35322
|
if ((yield* fs.realPath(parent)) !== parent || (yield* fs.realPath(plan.repo)) !== plan.repo)
|
|
35238
35323
|
return yield* fail19(`Clone path changed; reserved destination retained at ${plan.repo}`);
|
|
35239
35324
|
if (plan.vcs === "git")
|
|
35240
|
-
yield* cloneRepository(url, plan.repo);
|
|
35325
|
+
yield* cloneRepository(url, plan.repo, plan.input.checkout === "primary" && plan.input.branchMode === "existing" ? plan.input.branch : undefined);
|
|
35241
35326
|
else
|
|
35242
35327
|
yield* cloneRepository2(url, plan.repo);
|
|
35243
35328
|
}
|
|
@@ -35250,11 +35335,18 @@ var prepareCloneCheckout = exports_Effect.fnUntraced(function* (plan) {
|
|
|
35250
35335
|
if (plan.vcs === "jj") {
|
|
35251
35336
|
const base = plan.base ?? (yield* resolveRevision(repo.path, "@-"));
|
|
35252
35337
|
let cwd2;
|
|
35253
|
-
|
|
35254
|
-
|
|
35255
|
-
|
|
35256
|
-
|
|
35257
|
-
|
|
35338
|
+
const workspaceName = plan.input.directory ? pathService.basename(plan.input.directory) : plan.input.worktreeName;
|
|
35339
|
+
const worktreeRoot2 = plan.input.directory ? pathService.dirname(plan.input.directory) : workspaceName ? yield* resolveWorktreeRoot(repo.path) : undefined;
|
|
35340
|
+
if (plan.input.checkout === "primary" && plan.existing) {
|
|
35341
|
+
const current = yield* resolveRevision(repo.path, "@-");
|
|
35342
|
+
if (current.commitId !== base.commitId || current.changeId !== base.changeId)
|
|
35343
|
+
return yield* fail19("Existing primary workspace changed since review");
|
|
35344
|
+
cwd2 = repo.path;
|
|
35345
|
+
} else if (workspaceName) {
|
|
35346
|
+
const planned = yield* planWorkspace(repo.path, workspaceName, base.commitId, worktreeRoot2);
|
|
35347
|
+
if (planned.base.commitId !== base.commitId || planned.base.changeId !== base.changeId || plan.input.directory && planned.path !== plan.input.directory)
|
|
35348
|
+
return yield* fail19(`JJ clone base or directory is unavailable; clone retained at ${plan.repo}`);
|
|
35349
|
+
const created = yield* createWorkspace(repo.path, planned.workspaceName, base, worktreeRoot2);
|
|
35258
35350
|
if (!created.path || !created.present || created.path !== planned.path)
|
|
35259
35351
|
return yield* fail19(`JJ workspace registration changed; clone retained at ${plan.repo}`);
|
|
35260
35352
|
cwd2 = created.path;
|
|
@@ -35271,16 +35363,32 @@ var prepareCloneCheckout = exports_Effect.fnUntraced(function* (plan) {
|
|
|
35271
35363
|
const local = yield* listBranches(repo.path);
|
|
35272
35364
|
const remote = yield* remoteBranches(repo.path);
|
|
35273
35365
|
const { branch, branchMode } = plan.input;
|
|
35366
|
+
if (plan.input.checkout === "primary") {
|
|
35367
|
+
if (plan.existing) {
|
|
35368
|
+
if (branchMode !== "existing" || (yield* repositoryHead(repo.path)).branch !== branch)
|
|
35369
|
+
return yield* fail19("Existing primary checkout is not on the requested branch");
|
|
35370
|
+
} else if (branchMode === "create") {
|
|
35371
|
+
if (local.includes(branch) || remote.includes(branch))
|
|
35372
|
+
return yield* fail19(`Branch ${branch} already exists; clone retained at ${plan.repo}`);
|
|
35373
|
+
yield* createPrimaryBranch(repo.path, branch);
|
|
35374
|
+
} else if ((yield* repositoryHead(repo.path)).branch !== branch) {
|
|
35375
|
+
return yield* fail19(`Cloned primary checkout is not on ${branch}; clone retained at ${plan.repo}`);
|
|
35376
|
+
}
|
|
35377
|
+
return { repo, cwd: yield* fs.realPath(repo.path) };
|
|
35378
|
+
}
|
|
35379
|
+
const worktreeRoot = plan.input.directory ? pathService.dirname(plan.input.directory) : yield* resolveWorktreeRoot(repo.path);
|
|
35380
|
+
const worktreeName = plan.input.directory ? pathService.basename(plan.input.directory) : plan.input.worktreeName;
|
|
35274
35381
|
let cwd;
|
|
35275
35382
|
if (branchMode === "existing") {
|
|
35276
35383
|
if (!local.includes(branch) && !remote.includes(branch))
|
|
35277
35384
|
return yield* fail19(`Branch ${branch} was not pushed to origin; clone retained at ${plan.repo}`);
|
|
35278
|
-
const
|
|
35385
|
+
const planned = yield* planWorktree(repo.path, branch, worktreeRoot, worktreeName);
|
|
35386
|
+
if (plan.input.directory && planned.path !== plan.input.directory)
|
|
35387
|
+
return yield* fail19("Branch is already checked out at a different directory");
|
|
35279
35388
|
if (local.includes(branch)) {
|
|
35280
|
-
|
|
35281
|
-
cwd = planned.existing ? planned.path : (yield* createWorktree(repo.path, branch, { attachOnly: true, worktreeRoot, worktreeName: plan.input.worktreeName })).path;
|
|
35389
|
+
cwd = planned.existing ? planned.path : (yield* createWorktree(repo.path, branch, { attachOnly: true, worktreeRoot, worktreeName })).path;
|
|
35282
35390
|
} else {
|
|
35283
|
-
cwd = (yield* createWorktree(repo.path, branch, { startPoint: yield* remoteBranchHead(repo.path, branch), worktreeRoot, worktreeName
|
|
35391
|
+
cwd = (yield* createWorktree(repo.path, branch, { startPoint: yield* remoteBranchHead(repo.path, branch), worktreeRoot, worktreeName })).path;
|
|
35284
35392
|
}
|
|
35285
35393
|
} else {
|
|
35286
35394
|
if (local.includes(branch) || remote.includes(branch))
|
|
@@ -35288,7 +35396,7 @@ var prepareCloneCheckout = exports_Effect.fnUntraced(function* (plan) {
|
|
|
35288
35396
|
const base = plan.existing ? plan.base : (yield* repositoryHead(repo.path)).head;
|
|
35289
35397
|
if (!base)
|
|
35290
35398
|
return yield* fail19("Origin default branch changed since review");
|
|
35291
|
-
cwd = (yield* createWorktree(repo.path, branch, { startPoint: base, worktreeRoot
|
|
35399
|
+
cwd = (yield* createWorktree(repo.path, branch, { startPoint: base, worktreeRoot, worktreeName })).path;
|
|
35292
35400
|
}
|
|
35293
35401
|
return { repo, cwd: yield* fs.realPath(cwd) };
|
|
35294
35402
|
});
|
|
@@ -35370,7 +35478,8 @@ var dispatchHost = exports_Effect.fnUntraced(function* (request3, command) {
|
|
|
35370
35478
|
const inventory2 = yield* exports_Effect.all({
|
|
35371
35479
|
worktrees: canonical2.vcs === "git" ? listWorktrees(canonical2.path) : listWorkspaces(canonical2.path),
|
|
35372
35480
|
branches: canonical2.vcs === "git" ? listBranches(canonical2.path) : exports_Effect.succeed([]),
|
|
35373
|
-
revisions: canonical2.vcs === "jj" ? listRevisions(canonical2.path) : exports_Effect.succeed([])
|
|
35481
|
+
revisions: canonical2.vcs === "jj" ? listRevisions(canonical2.path) : exports_Effect.succeed([]),
|
|
35482
|
+
worktreeRoot: resolveWorktreeRoot(canonical2.path)
|
|
35374
35483
|
}, { concurrency: 4 });
|
|
35375
35484
|
result4 = {
|
|
35376
35485
|
...identity3,
|
|
@@ -35395,7 +35504,8 @@ var dispatchHost = exports_Effect.fnUntraced(function* (request3, command) {
|
|
|
35395
35504
|
const inventory2 = yield* exports_Effect.all({
|
|
35396
35505
|
worktrees: repo.vcs === "git" ? listWorktrees(repo.path) : listWorkspaces(repo.path),
|
|
35397
35506
|
branches: repo.vcs === "git" ? listBranches(repo.path) : exports_Effect.succeed([]),
|
|
35398
|
-
revisions: repo.vcs === "jj" ? listRevisions(repo.path) : exports_Effect.succeed([])
|
|
35507
|
+
revisions: repo.vcs === "jj" ? listRevisions(repo.path) : exports_Effect.succeed([]),
|
|
35508
|
+
worktreeRoot: resolveWorktreeRoot(repo.path)
|
|
35399
35509
|
}, { concurrency: 4 });
|
|
35400
35510
|
result4 = {
|
|
35401
35511
|
...identity3,
|
|
@@ -35506,13 +35616,13 @@ var inspectProject = exports_Effect.fnUntraced(function* (host, command, path) {
|
|
|
35506
35616
|
return yield* fail20(`Project directory does not exist: ${result4.path}`);
|
|
35507
35617
|
if (result4.kind !== "project")
|
|
35508
35618
|
return yield* fail20("Unexpected project response");
|
|
35509
|
-
return { project: result4.project, checkout: result4.checkout, worktrees: result4.worktrees, branches: result4.branches, revisions: result4.revisions };
|
|
35619
|
+
return { project: result4.project, checkout: result4.checkout, worktrees: result4.worktrees, branches: result4.branches, revisions: result4.revisions, worktreeRoot: result4.worktreeRoot };
|
|
35510
35620
|
});
|
|
35511
35621
|
var inspectWorktrees = exports_Effect.fnUntraced(function* (host, command, repo) {
|
|
35512
35622
|
const result4 = yield* request3(host, command, { kind: "worktrees", repo });
|
|
35513
35623
|
if (result4.kind !== "worktrees")
|
|
35514
35624
|
return yield* fail20("Unexpected worktree response");
|
|
35515
|
-
return { repository: result4.repository, worktrees: result4.worktrees, branches: result4.branches, revisions: result4.revisions };
|
|
35625
|
+
return { repository: result4.repository, worktrees: result4.worktrees, branches: result4.branches, revisions: result4.revisions, worktreeRoot: result4.worktreeRoot };
|
|
35516
35626
|
});
|
|
35517
35627
|
var inspectRevision = exports_Effect.fnUntraced(function* (host, command, repo, revision) {
|
|
35518
35628
|
const result4 = yield* request3(host, command, { kind: "revision", repo, revision });
|
|
@@ -38517,59 +38627,53 @@ var safeDisplayText = (text, preserveWhitespace = false) => {
|
|
|
38517
38627
|
};
|
|
38518
38628
|
var fit = (text, width2) => Bun.stringWidth(text) > width2 ? Bun.sliceAnsi(text, 0, Math.max(0, width2), { ellipsis: "\u2026" }) : text;
|
|
38519
38629
|
var pad = (text, width2) => text + " ".repeat(Math.max(0, width2 - Bun.stringWidth(text)));
|
|
38630
|
+
var formRows = [
|
|
38631
|
+
{ id: "project", label: "Project", value: "\u2014", disabled: true },
|
|
38632
|
+
{ id: "machine", label: "Machine", value: "\u2014", disabled: true },
|
|
38633
|
+
{ id: "session", label: "Session", value: "\u2014", disabled: true },
|
|
38634
|
+
{ id: "destination", label: "Worktree", value: "\u2014", disabled: true },
|
|
38635
|
+
{ id: "branch", label: "Branch", value: "\u2014", disabled: true },
|
|
38636
|
+
{ id: "checkoutName", label: "Directory", value: "\u2014", disabled: true },
|
|
38637
|
+
{ id: "mode", label: "Mode", value: "\u2014", disabled: true }
|
|
38638
|
+
];
|
|
38639
|
+
var choiceCount = popupSize.rows - formRows.length - 6;
|
|
38520
38640
|
var renderFormFrame = (view, focused, columns, rows2, colors2 = !process.env.NO_COLOR, options = {}) => {
|
|
38521
38641
|
const width2 = Math.max(2, columns);
|
|
38522
|
-
|
|
38642
|
+
if (rows2 < popupSize.rows)
|
|
38643
|
+
return fit(`Rex Worktrees needs ${popupSize.rows} terminal rows. Resize this pane; Esc closes.`, width2);
|
|
38644
|
+
const detailCount = rows2 - formRows.length - 4;
|
|
38523
38645
|
const screen = [];
|
|
38524
|
-
const
|
|
38525
|
-
const line = (left, right, title = "") => {
|
|
38526
|
-
const text = fit(safeDisplayText(title), inside);
|
|
38527
|
-
return color(`${left}${text}${"\u2500".repeat(Math.max(0, inside - Bun.stringWidth(text)))}${right}`, "muted", colors2);
|
|
38528
|
-
};
|
|
38529
|
-
const add4 = (text) => screen.push(border(text));
|
|
38530
|
-
screen.push(line("\u250C", "\u2510"));
|
|
38646
|
+
const add4 = (text) => screen.push(pad(fit(text, width2), width2));
|
|
38531
38647
|
add4(`${color("REX", "cyan", colors2)} ${color("/ WORKTREES", "bold", colors2)}`);
|
|
38532
|
-
|
|
38533
|
-
|
|
38534
|
-
|
|
38535
|
-
const focusIndex = view.rows.findIndex((row) => row.id === focused);
|
|
38536
|
-
const start = Math.max(0, Math.min(focusIndex - fieldCount + 1, view.rows.length - fieldCount));
|
|
38537
|
-
for (let index2 = 0;index2 < fieldCount; index2++) {
|
|
38538
|
-
const row = view.rows[start + index2];
|
|
38539
|
-
if (!row) {
|
|
38540
|
-
add4("");
|
|
38541
|
-
continue;
|
|
38542
|
-
}
|
|
38648
|
+
add4(color("\u2500".repeat(width2), "muted", colors2));
|
|
38649
|
+
for (const slot of formRows) {
|
|
38650
|
+
const row = view.rows.find((row2) => row2.id === slot.id) ?? slot;
|
|
38543
38651
|
const active = focused === row.id;
|
|
38544
38652
|
const tone = row.disabled ? "muted" : active ? "cyan" : "bold";
|
|
38545
|
-
const indicator =
|
|
38546
|
-
add4(`${color(indicator, tone, colors2)} ${color(pad(fit(safeDisplayText(row.label).toUpperCase(), 13), 13), tone, colors2)} ${color(fit(safeDisplayText(row.value) || "\u2014", Math.max(1,
|
|
38653
|
+
const indicator = active ? "\u203A" : " ";
|
|
38654
|
+
add4(`${color(indicator, tone, colors2)} ${color(pad(fit(safeDisplayText(row.label).toUpperCase(), 13), 13), tone, colors2)} ${color(fit(safeDisplayText(row.value) || "\u2014", Math.max(1, width2 - 17)), tone, colors2)}`);
|
|
38547
38655
|
}
|
|
38548
|
-
add4("");
|
|
38549
38656
|
const current = view.rows.find((row) => row.id === focused);
|
|
38550
|
-
|
|
38657
|
+
const heading = fit(safeDisplayText(options.editor?.title ?? current?.label ?? "Details") + " ", width2);
|
|
38658
|
+
add4(color(`${heading}${"\u2500".repeat(Math.max(0, width2 - Bun.stringWidth(heading)))}`, "muted", colors2));
|
|
38551
38659
|
const subtitle = current?.detail ?? view.rows.find((row) => row.id === "destination")?.detail ?? "";
|
|
38552
|
-
const wrapped = [view.error, view.notice, subtitle].filter(Boolean).flatMap((message) => Bun.wrapAnsi(safeDisplayText(message), Math.max(1,
|
|
38660
|
+
const wrapped = [view.error, view.notice, subtitle].filter(Boolean).flatMap((message) => Bun.wrapAnsi(safeDisplayText(message), Math.max(1, width2 - 8), { hard: true }).split(`
|
|
38553
38661
|
`));
|
|
38554
38662
|
const visible = options.editor ? 1 : detailCount;
|
|
38555
38663
|
const offset = Math.max(0, Math.min(options.detailOffset ?? 0, wrapped.length - visible));
|
|
38556
38664
|
const detailLine = (index2) => `${index2 === 0 && offset > 0 ? "\u2191 " : ""}${wrapped[offset + index2] ?? ""}${index2 === visible - 1 && offset + visible < wrapped.length ? " \u2193 PgDn" : ""}`;
|
|
38557
38665
|
if (options.editor) {
|
|
38558
|
-
|
|
38559
|
-
for (let index2 = 0;index2 < detailCount - errorRows; index2++)
|
|
38666
|
+
for (let index2 = 0;index2 < detailCount - 1; index2++)
|
|
38560
38667
|
add4(options.editor.lines[index2] ?? "");
|
|
38561
|
-
|
|
38562
|
-
add4(color(detailLine(0), "red", colors2));
|
|
38668
|
+
add4(view.error ? color(detailLine(0), "red", colors2) : "");
|
|
38563
38669
|
} else {
|
|
38564
38670
|
for (let index2 = 0;index2 < detailCount; index2++)
|
|
38565
38671
|
add4(color(detailLine(index2), view.error ? "red" : view.notice ? "amber" : "muted", colors2));
|
|
38566
38672
|
}
|
|
38567
|
-
screen.push(line("\u251C", "\u2524"));
|
|
38568
38673
|
const hint = (key5, label) => `${color(key5, "bold", colors2)} ${color(label, "muted", colors2)}`;
|
|
38569
38674
|
const button = (label, active, primary = false, disabled = false) => color(`${active ? "\u203A" : " "}[ ${safeDisplayText(label)} ]`, disabled ? "muted" : active ? "cyan" : primary ? "bold" : "muted", colors2);
|
|
38570
38675
|
add4(options.footer ? color(options.footer, "muted", colors2) : options.editor ? `${hint("Enter", "accept")} \xB7 ${hint("Esc", "back")} \xB7 ${hint("\u2191\u2193", "choices")} \xB7 ${hint("PgUp/PgDn", "details")}` : `${button(`${view.submitLabel} \xB7 Ctrl+S`, focused === "submit", true, view.submitDisabled)} ${button("Cancel \xB7 Esc", focused === "cancel")} ${hint("Tab", "next")}`);
|
|
38571
|
-
screen.
|
|
38572
|
-
return screen.slice(0, Math.max(1, rows2)).join(`\r
|
|
38676
|
+
return screen.join(`\r
|
|
38573
38677
|
`);
|
|
38574
38678
|
};
|
|
38575
38679
|
var matchingChoices = (choices, text) => {
|
|
@@ -38612,8 +38716,8 @@ var advanceInputChoice = (state, event, choices, selectionOnly = false) => {
|
|
|
38612
38716
|
return { _tag: "Beep" };
|
|
38613
38717
|
return { _tag: "NextFrame", state: { text: state.text + text, selected: selectionOnly ? state.selected : null } };
|
|
38614
38718
|
};
|
|
38615
|
-
var renderInputChoice = (state, choices, columns,
|
|
38616
|
-
const width2 = Math.max(20, columns)
|
|
38719
|
+
var renderInputChoice = (state, choices, columns, colors2 = !process.env.NO_COLOR, selectionOnly = false, count2 = choiceCount) => {
|
|
38720
|
+
const width2 = Math.max(20, columns);
|
|
38617
38721
|
const matches = matchingChoices(choices, state.text);
|
|
38618
38722
|
const selected = matches.indexOf(state.selected ?? -1);
|
|
38619
38723
|
const start = selected < 0 ? 0 : Math.max(0, Math.min(selected, matches.length - count2));
|
|
@@ -38631,14 +38735,25 @@ var acknowledge = (title, lines2, tone, view = { rows: [], submitLabel: "Close"
|
|
|
38631
38735
|
render: (detailOffset, action) => action._tag === "Submit" ? exports_Effect.succeed("") : exports_Effect.gen(function* () {
|
|
38632
38736
|
const terminal = yield* exports_Terminal.Terminal;
|
|
38633
38737
|
const notice = `${title} \xB7 ${lines2.join(" \xB7 ")}`;
|
|
38634
|
-
return `\x1B[H\x1B[2J${renderFormFrame({ ...view, error: tone === "error" ? notice : undefined, notice: tone !== "error" ? notice : undefined }, "submit", yield* terminal.columns, yield* terminal.rows, !process.env.NO_COLOR, { detailOffset, footer: "Enter / Space close \xB7 Esc close \xB7 PgUp/PgDn details" })}`;
|
|
38738
|
+
return `\x1B[?25l\x1B[H\x1B[2J${renderFormFrame({ ...view, error: tone === "error" ? notice : undefined, notice: tone !== "error" ? notice : undefined }, "submit", yield* terminal.columns, yield* terminal.rows, !process.env.NO_COLOR, { detailOffset, footer: "Enter / Space close \xB7 Esc close \xB7 PgUp/PgDn details" })}\x1B[0J`;
|
|
38635
38739
|
}),
|
|
38636
38740
|
clear: () => exports_Effect.succeed(""),
|
|
38637
38741
|
process: (input, offset) => exports_Effect.succeed(input.key.name === "pageup" || input.key.name === "pagedown" ? { _tag: "NextFrame", state: Math.max(0, offset + (input.key.name === "pageup" ? -1 : 1)) } : input.key.name === "enter" || input.key.name === "return" || input.key.name === "space" || input.key.name === "escape" || input.key.ctrl && input.key.name === "c" ? { _tag: "Submit", value: undefined } : { _tag: "Beep" })
|
|
38638
38742
|
})).pipe(exports_Effect.catch(() => exports_Effect.void));
|
|
38639
38743
|
var problem = (error2) => error2 instanceof AppError ? error2.message : exports_Cause.pretty(exports_Cause.fail(error2));
|
|
38640
38744
|
var selected = (value3, current, title, description) => ({ value: value3, selected: current, title, description });
|
|
38641
|
-
var
|
|
38745
|
+
var directoryFor = (draft) => {
|
|
38746
|
+
if (draft.destination?.path)
|
|
38747
|
+
return draft.destination.path;
|
|
38748
|
+
if (draft.clone && !draft.isCreating)
|
|
38749
|
+
return draft.clone.repo;
|
|
38750
|
+
if (draft.directory)
|
|
38751
|
+
return draft.directory;
|
|
38752
|
+
const repo = draft.clone?.repo ?? draft.project?.path;
|
|
38753
|
+
const name = draft.worktreeName ?? draft.destination?.branch;
|
|
38754
|
+
return repo && name ? `${(draft.worktreeRoot ?? `${repo}.worktrees`).replace(/\/$/, "")}/${name}` : undefined;
|
|
38755
|
+
};
|
|
38756
|
+
var generatedName = (draft) => draft.clone && !draft.isCreating ? draft.projectChoice?.name ?? "Project" : draft.worktreeName ?? draft.destination?.label ?? draft.projectChoice?.name ?? "Worktree";
|
|
38642
38757
|
var inputFor = (draft) => {
|
|
38643
38758
|
if (!draft.host || !draft.project || !draft.projectChoice || !draft.destination || !draft.session)
|
|
38644
38759
|
return;
|
|
@@ -38650,9 +38765,20 @@ var inputFor = (draft) => {
|
|
|
38650
38765
|
additional: draft.mode === "new-tab",
|
|
38651
38766
|
split: draft.mode === "split"
|
|
38652
38767
|
};
|
|
38768
|
+
if (draft.destination.path)
|
|
38769
|
+
return { ...common, vcs: draft.project.vcs, path: draft.destination.path };
|
|
38770
|
+
const directory = directoryFor(draft);
|
|
38771
|
+
if (!directory)
|
|
38772
|
+
return;
|
|
38653
38773
|
if (draft.project.vcs === "jj")
|
|
38654
|
-
return draft.
|
|
38655
|
-
return draft.destination.branch ? {
|
|
38774
|
+
return draft.worktreeName && draft.destination.revision ? { ...common, vcs: "jj", worktreeName: draft.worktreeName, revision: draft.destination.revision, directory } : undefined;
|
|
38775
|
+
return draft.destination.branch ? {
|
|
38776
|
+
...common,
|
|
38777
|
+
vcs: "git",
|
|
38778
|
+
branch: draft.destination.branch,
|
|
38779
|
+
directory,
|
|
38780
|
+
...draft.worktreeName ? { worktreeName: draft.worktreeName } : {}
|
|
38781
|
+
} : undefined;
|
|
38656
38782
|
};
|
|
38657
38783
|
var changeProjectChoice = (draft, projectChoice) => ({
|
|
38658
38784
|
...draft,
|
|
@@ -38661,20 +38787,30 @@ var changeProjectChoice = (draft, projectChoice) => ({
|
|
|
38661
38787
|
clone: undefined,
|
|
38662
38788
|
destination: undefined,
|
|
38663
38789
|
worktreeName: undefined,
|
|
38790
|
+
directory: undefined,
|
|
38791
|
+
worktreeRoot: undefined,
|
|
38792
|
+
isCreating: false,
|
|
38664
38793
|
sourcePath: undefined
|
|
38665
38794
|
});
|
|
38666
|
-
var changeProject = (draft, candidate) =>
|
|
38667
|
-
|
|
38668
|
-
|
|
38669
|
-
|
|
38670
|
-
|
|
38671
|
-
|
|
38672
|
-
|
|
38673
|
-
|
|
38795
|
+
var changeProject = (draft, candidate) => {
|
|
38796
|
+
const same = draft.project?.vcs === candidate.vcs && draft.project.commonDir === candidate.commonDir;
|
|
38797
|
+
return {
|
|
38798
|
+
...draft,
|
|
38799
|
+
project: candidate,
|
|
38800
|
+
clone: undefined,
|
|
38801
|
+
destination: same ? draft.destination : undefined,
|
|
38802
|
+
worktreeName: same ? draft.worktreeName : undefined,
|
|
38803
|
+
directory: same ? draft.directory : undefined,
|
|
38804
|
+
isCreating: same && draft.isCreating,
|
|
38805
|
+
sourcePath: candidate.vcs === "jj" && same ? draft.sourcePath : undefined
|
|
38806
|
+
};
|
|
38807
|
+
};
|
|
38674
38808
|
var changeDestination = (draft, candidate, worktreeName) => ({
|
|
38675
38809
|
...draft,
|
|
38676
38810
|
destination: candidate,
|
|
38677
|
-
worktreeName: candidate.path ? undefined : worktreeName
|
|
38811
|
+
worktreeName: candidate.path ? undefined : worktreeName,
|
|
38812
|
+
directory: candidate.path ? undefined : draft.directory,
|
|
38813
|
+
isCreating: candidate.path ? false : draft.isCreating
|
|
38678
38814
|
});
|
|
38679
38815
|
var selectWorktree = (draft, tree) => {
|
|
38680
38816
|
if (!tree.path || tree.vcs === "jj" && !tree.present)
|
|
@@ -38682,6 +38818,7 @@ var selectWorktree = (draft, tree) => {
|
|
|
38682
38818
|
return {
|
|
38683
38819
|
...changeDestination(draft, {
|
|
38684
38820
|
path: tree.path,
|
|
38821
|
+
worktree: tree,
|
|
38685
38822
|
label: tree.vcs === "jj" ? tree.name : tree.path.split("/").filter(Boolean).at(-1) ?? tree.path
|
|
38686
38823
|
}),
|
|
38687
38824
|
...tree.vcs === "jj" ? {
|
|
@@ -38690,15 +38827,14 @@ var selectWorktree = (draft, tree) => {
|
|
|
38690
38827
|
} : {}
|
|
38691
38828
|
};
|
|
38692
38829
|
};
|
|
38693
|
-
var typeWorktreeName = (draft, name, mainline) => ({
|
|
38694
|
-
...draft,
|
|
38695
|
-
worktreeName: name,
|
|
38696
|
-
destination: draft.destination && !draft.destination.path ? draft.destination : draft.project?.vcs === "jj" && !draft.clone && mainline ? { revision: mainline.revision.commitId, label: mainline.label } : undefined
|
|
38697
|
-
});
|
|
38698
38830
|
var selectRevision = (draft, choice) => changeDestination(draft, { revision: choice.revision.commitId, label: choice.label }, draft.worktreeName);
|
|
38699
38831
|
var cloneInputFor = (draft) => {
|
|
38700
38832
|
if (!draft.host || !draft.clone || !draft.session || !draft.clone.repo.startsWith("/"))
|
|
38701
38833
|
return;
|
|
38834
|
+
const directory = draft.isCreating ? directoryFor(draft) : undefined;
|
|
38835
|
+
const checkout = draft.isCreating ? "worktree" : "primary";
|
|
38836
|
+
if (draft.isCreating && (!directory || draft.clone.vcs === "git" && draft.destination?.branch === draft.clone.branch))
|
|
38837
|
+
return;
|
|
38702
38838
|
if (draft.clone.vcs === "jj") {
|
|
38703
38839
|
const revision = draft.clone.revision?.commitId === draft.destination?.revision ? draft.clone.revision : draft.clone.revisions.find((choice) => choice.revision.commitId === draft.destination?.revision)?.revision;
|
|
38704
38840
|
return {
|
|
@@ -38713,8 +38849,10 @@ var cloneInputFor = (draft) => {
|
|
|
38713
38849
|
repo: draft.clone.repo,
|
|
38714
38850
|
session: draft.session,
|
|
38715
38851
|
clientId: draft.clientId,
|
|
38852
|
+
checkout,
|
|
38853
|
+
directory,
|
|
38716
38854
|
name: generatedName(draft),
|
|
38717
|
-
...draft.worktreeName ? { worktreeName: draft.worktreeName } : {},
|
|
38855
|
+
...draft.isCreating && draft.worktreeName ? { worktreeName: draft.worktreeName } : {},
|
|
38718
38856
|
...draft.destination?.revision ? { revision: draft.destination.revision } : {}
|
|
38719
38857
|
};
|
|
38720
38858
|
}
|
|
@@ -38732,25 +38870,28 @@ var cloneInputFor = (draft) => {
|
|
|
38732
38870
|
repo: draft.clone.repo,
|
|
38733
38871
|
session: draft.session,
|
|
38734
38872
|
clientId: draft.clientId,
|
|
38873
|
+
checkout,
|
|
38874
|
+
directory,
|
|
38735
38875
|
name: generatedName(draft),
|
|
38736
38876
|
branch: draft.destination.branch,
|
|
38737
38877
|
branchMode: draft.clone.branches.includes(draft.destination.branch) ? "existing" : "create",
|
|
38738
|
-
...draft.worktreeName ? { worktreeName: draft.worktreeName } : {}
|
|
38878
|
+
...draft.isCreating && draft.worktreeName ? { worktreeName: draft.worktreeName } : {}
|
|
38739
38879
|
};
|
|
38740
38880
|
};
|
|
38741
38881
|
var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effect.scoped(exports_Effect.suspend(() => {
|
|
38742
38882
|
let launchAcknowledged = false;
|
|
38743
38883
|
return exports_Effect.gen(function* () {
|
|
38744
38884
|
const terminal = yield* exports_Terminal.Terminal;
|
|
38745
|
-
|
|
38885
|
+
const path = yield* exports_Path.Path;
|
|
38886
|
+
yield* exports_Effect.acquireRelease(terminal.display("\x1B[?1049h\x1B[?25l"), () => terminal.display("\x1B[?25h\x1B[?1049l").pipe(exports_Effect.orDie));
|
|
38746
38887
|
let machines = [];
|
|
38747
38888
|
let draft = { mode: "auto" };
|
|
38748
38889
|
let sessions = [];
|
|
38749
38890
|
let focused = "project";
|
|
38891
|
+
let isBranchEditPending = false;
|
|
38750
38892
|
let error2;
|
|
38751
38893
|
let blocked = false;
|
|
38752
38894
|
let cloneRoot = "";
|
|
38753
|
-
let cloneRoots = [];
|
|
38754
38895
|
let contextPath;
|
|
38755
38896
|
let activeView;
|
|
38756
38897
|
const resizeEvents = exports_Effect.gen(function* () {
|
|
@@ -38761,30 +38902,34 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38761
38902
|
});
|
|
38762
38903
|
const chooseField = exports_Effect.fnUntraced(function* (view, initialFocus) {
|
|
38763
38904
|
let detailOffset = 0;
|
|
38764
|
-
|
|
38905
|
+
let visibleRows = popupSize.rows;
|
|
38906
|
+
const fields = [...formRows.filter((slot) => view.rows.some((row) => row.id === slot.id && !row.disabled && !row.isReadOnly)).map((row) => row.id), "submit", "cancel"];
|
|
38765
38907
|
const initial = Math.max(0, fields.indexOf(initialFocus));
|
|
38766
38908
|
const prompt = exports_Prompt.Custom(initial, yield* resizeEvents, {
|
|
38767
38909
|
render: (index2, action) => action._tag === "Submit" ? exports_Effect.succeed("") : exports_Effect.gen(function* () {
|
|
38768
38910
|
const columns = yield* terminal.columns;
|
|
38769
38911
|
const rows2 = yield* terminal.rows;
|
|
38770
|
-
|
|
38912
|
+
visibleRows = rows2;
|
|
38913
|
+
return `\x1B[?25l\x1B[H\x1B[2J${renderFormFrame(view, fields[index2], columns, rows2, !process.env.NO_COLOR, { detailOffset })}\x1B[0J`;
|
|
38771
38914
|
}),
|
|
38772
38915
|
clear: () => exports_Effect.succeed(""),
|
|
38773
38916
|
process: (event, index2) => {
|
|
38774
38917
|
if (event._tag === "Event")
|
|
38775
38918
|
return exports_Effect.succeed({ _tag: "NextFrame", state: index2 });
|
|
38776
38919
|
const { key: key5 } = event.input;
|
|
38920
|
+
if (key5.name === "escape" || key5.ctrl && key5.name === "c")
|
|
38921
|
+
return exports_Effect.succeed({ _tag: "Submit", value: "cancel" });
|
|
38922
|
+
if (visibleRows < popupSize.rows)
|
|
38923
|
+
return exports_Effect.succeed({ _tag: "Beep" });
|
|
38777
38924
|
if (key5.name === "pageup" || key5.name === "pagedown") {
|
|
38778
38925
|
detailOffset = Math.max(0, detailOffset + (key5.name === "pageup" ? -1 : 1));
|
|
38779
38926
|
return exports_Effect.succeed({ _tag: "NextFrame", state: index2 });
|
|
38780
38927
|
}
|
|
38781
|
-
if (key5.name === "escape" || key5.ctrl && key5.name === "c")
|
|
38782
|
-
return exports_Effect.succeed({ _tag: "Submit", value: "cancel" });
|
|
38783
38928
|
if (key5.ctrl && key5.name === "s")
|
|
38784
38929
|
return exports_Effect.succeed(view.submitDisabled ? { _tag: "Beep" } : { _tag: "Submit", value: "submit" });
|
|
38785
38930
|
if (key5.name === "enter" || key5.name === "return") {
|
|
38786
38931
|
const selected2 = fields[index2];
|
|
38787
|
-
return exports_Effect.succeed(selected2 === "submit" && view.submitDisabled
|
|
38932
|
+
return exports_Effect.succeed(selected2 === "submit" && view.submitDisabled ? { _tag: "Beep" } : { _tag: "Submit", value: selected2 });
|
|
38788
38933
|
}
|
|
38789
38934
|
const backward = key5.name === "up" || key5.name === "k" && !key5.ctrl || key5.name === "backtab" || key5.name === "tab" && key5.shift;
|
|
38790
38935
|
const forward = key5.name === "down" || key5.name === "j" && !key5.ctrl || key5.name === "tab";
|
|
@@ -38795,18 +38940,22 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38795
38940
|
}, exports_Effect.scoped);
|
|
38796
38941
|
const inputChoice = exports_Effect.fnUntraced(function* (options) {
|
|
38797
38942
|
let detailOffset = 0;
|
|
38943
|
+
let visibleRows = popupSize.rows;
|
|
38798
38944
|
const result4 = yield* exports_Prompt.run(exports_Prompt.Custom({ text: "", selected: options.selected === undefined || options.selected < 0 ? null : options.selected }, yield* resizeEvents, {
|
|
38799
38945
|
render: (state, action) => action._tag === "Submit" ? exports_Effect.succeed("") : exports_Effect.gen(function* () {
|
|
38800
38946
|
const columns = yield* terminal.columns;
|
|
38801
38947
|
const rows2 = yield* terminal.rows;
|
|
38948
|
+
visibleRows = rows2;
|
|
38802
38949
|
const view = activeView;
|
|
38803
|
-
const editor = renderInputChoice(state, options.choices, columns,
|
|
38950
|
+
const editor = renderInputChoice(state, options.choices, columns, !process.env.NO_COLOR, options.selectionOnly, Math.max(1, rows2 - formRows.length - 6));
|
|
38804
38951
|
if (!view)
|
|
38805
38952
|
return "";
|
|
38806
|
-
return `\x1B[H\x1B[2J${renderFormFrame(view, focused, columns, rows2, !process.env.NO_COLOR, { editor: { title: options.message, lines: editor }, detailOffset })}`;
|
|
38953
|
+
return `\x1B[?25l\x1B[H\x1B[2J${renderFormFrame(view, focused, columns, rows2, !process.env.NO_COLOR, { editor: { title: options.message, lines: editor }, detailOffset })}\x1B[0J`;
|
|
38807
38954
|
}),
|
|
38808
38955
|
clear: () => exports_Effect.succeed(""),
|
|
38809
38956
|
process: (event, state) => {
|
|
38957
|
+
if (event._tag !== "Event" && visibleRows < popupSize.rows && event.input.key.name !== "escape" && !(event.input.key.ctrl && event.input.key.name === "c"))
|
|
38958
|
+
return exports_Effect.succeed({ _tag: "Beep" });
|
|
38810
38959
|
if (event._tag !== "Event" && (event.input.key.name === "pageup" || event.input.key.name === "pagedown")) {
|
|
38811
38960
|
detailOffset = Math.max(0, detailOffset + (event.input.key.name === "pageup" ? -1 : 1));
|
|
38812
38961
|
return exports_Effect.succeed({ _tag: "NextFrame", state });
|
|
@@ -38864,59 +39013,48 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38864
39013
|
projectChoice: choice,
|
|
38865
39014
|
host,
|
|
38866
39015
|
project: undefined,
|
|
39016
|
+
sourcePath: undefined,
|
|
38867
39017
|
clone: { ...source, repo },
|
|
38868
39018
|
destination: source.vcs === "git" && source.branch ? { branch: source.branch, label: source.branch } : undefined,
|
|
38869
|
-
worktreeName: undefined
|
|
39019
|
+
worktreeName: undefined,
|
|
39020
|
+
directory: undefined,
|
|
39021
|
+
worktreeRoot: undefined,
|
|
39022
|
+
isCreating: false
|
|
38870
39023
|
};
|
|
38871
39024
|
});
|
|
38872
|
-
const cloneDestination2 = exports_Effect.fnUntraced(function* (choice, host) {
|
|
38873
|
-
let repo = clonePath(choice);
|
|
38874
|
-
if (!repo) {
|
|
38875
|
-
const picked = yield* inputChoice({
|
|
38876
|
-
message: "Project name is not a safe clone directory; type an absolute clone destination",
|
|
38877
|
-
choices: []
|
|
38878
|
-
});
|
|
38879
|
-
repo = picked.kind === "selected" ? picked.value : picked.text.trim();
|
|
38880
|
-
}
|
|
38881
|
-
if (!repo.startsWith("/"))
|
|
38882
|
-
return yield* exports_Effect.fail(new AppError({ message: "Clone destination must be an absolute path on this machine" }));
|
|
38883
|
-
yield* proposeClone(choice, host, repo);
|
|
38884
|
-
});
|
|
38885
39025
|
const bindProject = exports_Effect.fnUntraced(function* (choice, host, available) {
|
|
38886
39026
|
const source = choice.source;
|
|
38887
|
-
|
|
38888
|
-
|
|
38889
|
-
|
|
38890
|
-
if (
|
|
38891
|
-
|
|
38892
|
-
|
|
38893
|
-
|
|
38894
|
-
|
|
38895
|
-
|
|
38896
|
-
|
|
38897
|
-
|
|
38898
|
-
|
|
38899
|
-
|
|
38900
|
-
|
|
38901
|
-
});
|
|
38902
|
-
path = directory.kind === "selected" ? directory.value : directory.text.trim();
|
|
39027
|
+
const sameHost = source?.machineKey === host.key && source.hostId === host.hostId;
|
|
39028
|
+
const matches = available.filter((repo) => repo.name === choice.name && (!source || repo.vcs === source.repository.vcs));
|
|
39029
|
+
let directory = sameHost ? source.checkoutPath ?? source.repository.path : choice.path;
|
|
39030
|
+
if (!directory && matches.length === 1)
|
|
39031
|
+
directory = matches[0].path;
|
|
39032
|
+
if (!directory && matches.length > 1)
|
|
39033
|
+
return yield* exports_Effect.fail(new AppError({ message: `Multiple projects named ${choice.name} on this machine; select its exact project directory` }));
|
|
39034
|
+
directory ??= source ? clonePath(choice) : undefined;
|
|
39035
|
+
if (!directory) {
|
|
39036
|
+
if (source) {
|
|
39037
|
+
yield* proposeClone(choice, host, "");
|
|
39038
|
+
return;
|
|
39039
|
+
}
|
|
39040
|
+
return yield* exports_Effect.fail(new AppError({ message: "Select a known project or enter its absolute directory on this machine" }));
|
|
38903
39041
|
}
|
|
38904
|
-
if (!path.
|
|
39042
|
+
if (!path.isAbsolute(directory))
|
|
38905
39043
|
return yield* exports_Effect.fail(new AppError({ message: "Project directory must be an absolute path on this machine" }));
|
|
38906
|
-
const inspected = yield* exports_Effect.result(inspectProject(host, command,
|
|
39044
|
+
const inspected = yield* exports_Effect.result(inspectProject(host, command, directory));
|
|
38907
39045
|
if (exports_Result.isFailure(inspected)) {
|
|
38908
|
-
if (
|
|
38909
|
-
yield* proposeClone(choice, host,
|
|
39046
|
+
if (source && inspected.failure instanceof AppError && inspected.failure.message.startsWith("Project directory does not exist:")) {
|
|
39047
|
+
yield* proposeClone(choice, host, directory);
|
|
38910
39048
|
return;
|
|
38911
39049
|
}
|
|
38912
39050
|
return yield* exports_Effect.fail(inspected.failure);
|
|
38913
39051
|
}
|
|
38914
|
-
if (
|
|
39052
|
+
if (sameHost && (inspected.success.project.vcs !== source.repository.vcs || inspected.success.project.commonDir !== source.repository.commonDir))
|
|
38915
39053
|
return yield* exports_Effect.fail(new AppError({ message: "Project directory changed; select the exact project directory again" }));
|
|
38916
39054
|
return inspected.success;
|
|
38917
39055
|
});
|
|
38918
39056
|
const useProject = (found) => {
|
|
38919
|
-
draft = changeProject(draft, found.project);
|
|
39057
|
+
draft = { ...changeProject(draft, found.project), worktreeRoot: found.worktreeRoot };
|
|
38920
39058
|
if (found.checkout.vcs === "jj" && !draft.sourcePath)
|
|
38921
39059
|
draft = { ...draft, sourcePath: found.checkout.path };
|
|
38922
39060
|
if (!draft.destination) {
|
|
@@ -38931,14 +39069,13 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38931
39069
|
draft = { machine, projectChoice: draft.projectChoice, mode: draft.mode };
|
|
38932
39070
|
sessions = [];
|
|
38933
39071
|
cloneRoot = "";
|
|
38934
|
-
cloneRoots = [];
|
|
38935
39072
|
error2 = undefined;
|
|
38936
39073
|
const discoveredContext = machine.local ? contextPath : undefined;
|
|
38937
39074
|
contextPath = undefined;
|
|
38938
39075
|
if (showLoading) {
|
|
38939
39076
|
const pending = { ...formView(true), notice: `Connecting to ${machine.label}\u2026` };
|
|
38940
39077
|
activeView = pending;
|
|
38941
|
-
yield* terminal.display(`\x1B[H\x1B[2J${renderFormFrame(pending, "machine", yield* terminal.columns, yield* terminal.rows)}`);
|
|
39078
|
+
yield* terminal.display(`\x1B[?25l\x1B[H\x1B[2J${renderFormFrame(pending, "machine", yield* terminal.columns, yield* terminal.rows)}\x1B[0J`);
|
|
38942
39079
|
}
|
|
38943
39080
|
const connected = yield* exports_Effect.result(connectAndDiscover(machine, command, discoveredContext));
|
|
38944
39081
|
if (exports_Result.isFailure(connected)) {
|
|
@@ -38951,7 +39088,6 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38951
39088
|
else
|
|
38952
39089
|
draft = { ...draft, host };
|
|
38953
39090
|
cloneRoot = found.cloneRoot;
|
|
38954
|
-
cloneRoots = found.roots;
|
|
38955
39091
|
projects = [
|
|
38956
39092
|
...projects.filter((item) => item.source?.machineKey !== machine.key || item.source.hostId !== host.hostId),
|
|
38957
39093
|
...found.projects.map((repo) => known(host, repo, found.checkout))
|
|
@@ -38983,6 +39119,10 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38983
39119
|
error2 = undefined;
|
|
38984
39120
|
});
|
|
38985
39121
|
const formView = (initializing = false) => {
|
|
39122
|
+
const jj2 = (draft.clone?.vcs ?? draft.project?.vcs) === "jj";
|
|
39123
|
+
const tree = draft.destination?.path ? draft.destination.worktree : undefined;
|
|
39124
|
+
const ready = !!draft.host && !!(draft.project || draft.clone);
|
|
39125
|
+
const directory = directoryFor(draft);
|
|
38986
39126
|
const rows2 = [
|
|
38987
39127
|
{ id: "project", label: "Project", value: draft.projectChoice?.name ?? "Choose a project" },
|
|
38988
39128
|
{
|
|
@@ -38991,55 +39131,55 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38991
39131
|
value: draft.machine?.label ?? "Choose Rex host",
|
|
38992
39132
|
detail: draft.host ? `Host ID: ${draft.host.hostId}` : draft.machine?.selector
|
|
38993
39133
|
},
|
|
38994
|
-
{
|
|
38995
|
-
id: "destination",
|
|
38996
|
-
label: draft.clone ? "Clone to" : draft.project?.vcs === "jj" ? "Workspace" : "Checkout",
|
|
38997
|
-
value: draft.clone?.repo ?? (draft.project?.vcs === "jj" && !draft.destination?.path ? draft.worktreeName : undefined) ?? draft.destination?.label ?? (draft.project?.vcs === "jj" ? "Choose workspace or type new name" : "Choose checkout or type branch"),
|
|
38998
|
-
detail: draft.clone?.repo ?? draft.destination?.path,
|
|
38999
|
-
disabled: !draft.host || !(draft.project || draft.clone)
|
|
39000
|
-
},
|
|
39001
39134
|
{
|
|
39002
39135
|
id: "session",
|
|
39003
39136
|
label: "Session",
|
|
39004
39137
|
value: draft.session?.kind === "new" ? `New: ${draft.session.name}` : sessions.find((s) => s.id === (draft.session?.kind === "existing" ? draft.session.id : undefined))?.label ?? (draft.session?.kind === "existing" ? draft.session.id : "Choose or type new session"),
|
|
39005
39138
|
detail: draft.session?.kind === "existing" ? draft.session.id : draft.session?.kind === "new" ? "Create on submit" : undefined,
|
|
39006
39139
|
disabled: !draft.host
|
|
39007
|
-
}
|
|
39008
|
-
|
|
39009
|
-
|
|
39010
|
-
|
|
39140
|
+
},
|
|
39141
|
+
{
|
|
39142
|
+
id: "destination",
|
|
39143
|
+
label: jj2 ? "Workspace" : "Worktree",
|
|
39144
|
+
value: draft.clone && !draft.isCreating ? "Project checkout (after clone)" : draft.isCreating ? jj2 ? "Create new workspace\u2026" : "Create new worktree\u2026" : draft.destination?.label ?? (jj2 ? "Choose a workspace" : "Choose a worktree"),
|
|
39145
|
+
detail: tree ? "Branch and Directory describe this worktree; select another worktree to change them." : draft.isCreating ? jj2 ? "Choose the starting revision and directory for the new workspace." : "Choose an unused branch or a new branch name, then its directory." : undefined,
|
|
39146
|
+
disabled: !ready
|
|
39147
|
+
},
|
|
39148
|
+
{
|
|
39011
39149
|
id: "branch",
|
|
39012
|
-
label: "Start from",
|
|
39013
|
-
value: draft.destination?.revision ? draft.destination.label : draft.clone ? "Cloned default" : "Select or type
|
|
39014
|
-
|
|
39015
|
-
|
|
39016
|
-
|
|
39017
|
-
|
|
39018
|
-
|
|
39019
|
-
rows2.push({
|
|
39150
|
+
label: tree?.vcs === "jj" ? "Revision" : jj2 ? "Start from" : "Branch",
|
|
39151
|
+
value: tree?.vcs === "jj" ? `${tree.changeId.slice(0, 12)} \xB7 ${tree.head.slice(0, 12)}` : tree?.vcs === "git" ? tree.branch ?? `Detached HEAD \xB7 ${tree.head.slice(0, 12)}` : jj2 ? draft.destination?.revision ? draft.destination.label : draft.clone ? "Cloned default" : "Choose a starting revision" : draft.destination?.branch ?? "Select or type branch",
|
|
39152
|
+
detail: tree ? undefined : jj2 ? "Revision for the new workspace; the source workspace is not moved." : "Select an unused existing branch, or type the name of a new branch.",
|
|
39153
|
+
isReadOnly: !!tree,
|
|
39154
|
+
disabled: !ready || !tree && !draft.clone && !draft.isCreating
|
|
39155
|
+
},
|
|
39156
|
+
{
|
|
39020
39157
|
id: "checkoutName",
|
|
39021
|
-
label:
|
|
39022
|
-
value:
|
|
39023
|
-
|
|
39024
|
-
|
|
39025
|
-
|
|
39026
|
-
|
|
39158
|
+
label: "Directory",
|
|
39159
|
+
value: directory || (draft.clone ? "Choose an absolute directory" : "Choose a branch first"),
|
|
39160
|
+
detail: directory,
|
|
39161
|
+
isReadOnly: !!tree,
|
|
39162
|
+
disabled: !ready || !draft.clone && !directory
|
|
39163
|
+
},
|
|
39164
|
+
{
|
|
39027
39165
|
id: "mode",
|
|
39028
39166
|
label: "Mode",
|
|
39029
|
-
value: draft.mode === "auto" ? "Reuse matching tab, otherwise new tab" : draft.mode === "new-tab" ? "Always new tab" : "Split matching tab, otherwise new tab",
|
|
39167
|
+
value: draft.clone ? "New tab (cloning)" : draft.mode === "auto" ? "Reuse matching tab, otherwise new tab" : draft.mode === "new-tab" ? "Always new tab" : "Split matching tab, otherwise new tab",
|
|
39168
|
+
isReadOnly: !!draft.clone,
|
|
39030
39169
|
disabled: !draft.host
|
|
39031
|
-
}
|
|
39170
|
+
}
|
|
39171
|
+
];
|
|
39032
39172
|
return {
|
|
39033
39173
|
rows: rows2.map((row) => ({ ...row, disabled: initializing || row.disabled })),
|
|
39034
|
-
submitLabel: draft.clone ? "Clone &
|
|
39174
|
+
submitLabel: draft.clone ? "Clone & open" : tree ? jj2 ? "Open workspace" : "Open worktree" : jj2 ? "Create workspace & open" : "Create worktree & open",
|
|
39035
39175
|
submitDisabled: initializing || blocked || !draft.host || !(cloneInputFor(draft) || inputFor(draft)),
|
|
39036
|
-
notice: draft.clone ? "Only pushed history transfers
|
|
39037
|
-
error: initializing ? undefined : error2 ?? (!draft.projectChoice ? "Select a project" : !draft.machine ? "Select a Rex machine" : !draft.host ? "Connect to the selected machine and install its worktrees helper if missing" : !
|
|
39176
|
+
notice: draft.clone ? `This project will be cloned onto this machine: ${draft.clone.repo || "choose its Directory"}. Only pushed history transfers.` : undefined,
|
|
39177
|
+
error: initializing ? undefined : error2 ?? (!draft.projectChoice ? "Select a project" : !draft.machine ? "Select a Rex machine" : !draft.host ? "Connect to the selected machine and install its worktrees helper if missing" : !ready ? "Select the exact project directory on this machine" : !draft.destination && !draft.clone ? "Choose an existing worktree or Create new worktree\u2026" : !jj2 && !tree && !draft.destination?.branch ? "Choose a branch" : jj2 && draft.isCreating && !draft.destination?.revision && !draft.clone ? "Choose a starting revision" : !directory ? "Choose an absolute directory" : !draft.session ? "Choose an existing Rex session or type a new name" : undefined)
|
|
39038
39178
|
};
|
|
39039
39179
|
};
|
|
39040
39180
|
const initialView = { ...formView(true), notice: "Discovering projects and Rex sessions\u2026" };
|
|
39041
39181
|
activeView = initialView;
|
|
39042
|
-
yield* terminal.display(`\x1B[H\x1B[2J${renderFormFrame(initialView, "project", yield* terminal.columns, yield* terminal.rows)}`);
|
|
39182
|
+
yield* terminal.display(`\x1B[?25l\x1B[H\x1B[2J${renderFormFrame(initialView, "project", yield* terminal.columns, yield* terminal.rows)}\x1B[0J`);
|
|
39043
39183
|
const initialize = exports_Effect.gen(function* () {
|
|
39044
39184
|
contextPath = yield* context3;
|
|
39045
39185
|
yield* loadMachines;
|
|
@@ -39056,7 +39196,8 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39056
39196
|
while (true) {
|
|
39057
39197
|
const view = formView();
|
|
39058
39198
|
activeView = view;
|
|
39059
|
-
const action = yield* chooseField(view, focused).pipe(exports_Effect.catchTag("QuitError", () => exports_Effect.succeed("cancel")));
|
|
39199
|
+
const action = isBranchEditPending ? "branch" : yield* chooseField(view, focused).pipe(exports_Effect.catchTag("QuitError", () => exports_Effect.succeed("cancel")));
|
|
39200
|
+
isBranchEditPending = false;
|
|
39060
39201
|
focused = action;
|
|
39061
39202
|
if (action === "cancel")
|
|
39062
39203
|
return;
|
|
@@ -39071,8 +39212,8 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39071
39212
|
continue;
|
|
39072
39213
|
}
|
|
39073
39214
|
const clonePlan = current2.success;
|
|
39074
|
-
if (clonePlan.repo !== cloneInput.repo || clonePlan.hostId !== draft.host.hostId) {
|
|
39075
|
-
error2 = clonePlan.hostId !== draft.host.hostId ? "Rex target changed; select the machine again" : `Clone destination changed; edit the destination: ${clonePlan.repo}
|
|
39215
|
+
if (clonePlan.repo !== cloneInput.repo || clonePlan.hostId !== draft.host.hostId || clonePlan.input.checkout !== cloneInput.checkout || clonePlan.input.directory !== cloneInput.directory) {
|
|
39216
|
+
error2 = clonePlan.hostId !== draft.host.hostId ? "Rex target changed; select the machine again" : clonePlan.repo !== cloneInput.repo ? `Clone destination changed; edit the destination: ${clonePlan.repo}` : "Clone helper changed the checkout request; update its plugin and select the machine again";
|
|
39076
39217
|
blocked = true;
|
|
39077
39218
|
continue;
|
|
39078
39219
|
}
|
|
@@ -39104,8 +39245,8 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39104
39245
|
continue;
|
|
39105
39246
|
}
|
|
39106
39247
|
const plan = current.success;
|
|
39107
|
-
if (plan.hostId !== draft.host.hostId || input.path && plan.path !== input.path) {
|
|
39108
|
-
error2 = plan.hostId !== draft.host.hostId ? "Rex target changed; select the machine again" : `Destination changed; select the
|
|
39248
|
+
if (plan.hostId !== draft.host.hostId || input.path && plan.path !== input.path || input.directory && plan.path !== input.directory) {
|
|
39249
|
+
error2 = plan.hostId !== draft.host.hostId ? "Rex target changed; select the machine again" : `Destination changed; select the worktree again: ${plan.path}`;
|
|
39109
39250
|
blocked = true;
|
|
39110
39251
|
continue;
|
|
39111
39252
|
}
|
|
@@ -39170,84 +39311,73 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39170
39311
|
} else if (action === "destination") {
|
|
39171
39312
|
if (!draft.host || !(draft.project || draft.clone))
|
|
39172
39313
|
return yield* exports_Effect.fail(new AppError({ message: "Select a project and machine before choosing a worktree" }));
|
|
39173
|
-
|
|
39174
|
-
|
|
39175
|
-
|
|
39176
|
-
|
|
39177
|
-
|
|
39178
|
-
|
|
39179
|
-
|
|
39180
|
-
|
|
39181
|
-
|
|
39182
|
-
|
|
39183
|
-
|
|
39184
|
-
|
|
39185
|
-
|
|
39186
|
-
|
|
39187
|
-
|
|
39188
|
-
return yield* exports_Effect.fail(new AppError({ message: "Clone destination must be an absolute path on this machine" }));
|
|
39189
|
-
draft = { ...draft, clone: { ...clone, repo } };
|
|
39190
|
-
} else {
|
|
39191
|
-
const found = yield* inspectWorktrees(draft.host, command, draft.project.vcs === "jj" ? draft.sourcePath ?? draft.project.path : draft.project.path);
|
|
39192
|
-
const trees = found.worktrees.filter((tree) => tree.vcs === "jj" || !tree.bare && !tree.prunable);
|
|
39193
|
-
const git2 = draft.project.vcs === "git";
|
|
39194
|
-
const picked = yield* inputChoice({
|
|
39195
|
-
message: git2 ? "Checkout (select exact worktree or branch, or type new branch)" : "Workspace (select existing, Clone this project, or type new workspace name)",
|
|
39196
|
-
choices: [
|
|
39197
|
-
...trees.map((tree) => ({
|
|
39198
|
-
value: tree,
|
|
39199
|
-
title: tree.vcs === "jj" ? tree.name : tree.path.split("/").filter(Boolean).at(-1) ?? tree.path,
|
|
39200
|
-
description: tree.vcs === "jj" ? tree.present && tree.path ? `${tree.changeId.slice(0, 12)} \xB7 ${tree.path}` : `Unavailable \xB7 ${tree.path ?? "location unknown"}` : `${tree.branch ?? "Detached HEAD"} \xB7 ${tree.path}`
|
|
39201
|
-
})),
|
|
39202
|
-
...git2 ? found.branches.map((branch) => ({
|
|
39203
|
-
value: { kind: "branch", value: branch },
|
|
39204
|
-
title: `Branch: ${branch}`,
|
|
39205
|
-
description: trees.find((tree) => tree.vcs === "git" && tree.branch === branch)?.path ?? "Free branch \u2014 attach new checkout"
|
|
39206
|
-
})) : [],
|
|
39207
|
-
...draft.projectChoice?.source ? [{
|
|
39208
|
-
value: "clone",
|
|
39209
|
-
title: "Clone this project\u2026",
|
|
39210
|
-
description: clonePath(draft.projectChoice) ? `Propose ${clonePath(draft.projectChoice)} \xB7 only pushed history transfers` : "Choose an absolute clone destination \xB7 only pushed history transfers"
|
|
39211
|
-
}] : []
|
|
39212
|
-
]
|
|
39314
|
+
const jj2 = (draft.clone?.vcs ?? draft.project?.vcs) === "jj";
|
|
39315
|
+
const found = draft.clone ? undefined : yield* inspectWorktrees(draft.host, command, jj2 ? draft.sourcePath ?? draft.project.path : draft.project.path);
|
|
39316
|
+
const trees = found?.worktrees.filter((tree) => tree.vcs === "jj" || !tree.bare && !tree.prunable) ?? [];
|
|
39317
|
+
const choices = trees.map((tree) => ({
|
|
39318
|
+
value: tree,
|
|
39319
|
+
selected: tree.path === draft.destination?.path,
|
|
39320
|
+
title: tree.vcs === "jj" ? `${tree.present ? "" : "Unavailable: "}${tree.name}` : path.basename(tree.path),
|
|
39321
|
+
description: tree.vcs === "jj" ? tree.present && tree.path ? `${tree.changeId.slice(0, 12)} \xB7 ${tree.path}` : `Unavailable \xB7 ${tree.path ?? "location unknown"}` : `${tree.branch ?? "Detached HEAD"} \xB7 ${tree.path}`
|
|
39322
|
+
}));
|
|
39323
|
+
if (draft.clone)
|
|
39324
|
+
choices.push({
|
|
39325
|
+
value: "primary",
|
|
39326
|
+
selected: !draft.isCreating,
|
|
39327
|
+
title: "Project checkout (after clone)",
|
|
39328
|
+
description: draft.clone.repo
|
|
39213
39329
|
});
|
|
39214
|
-
|
|
39215
|
-
|
|
39216
|
-
|
|
39217
|
-
|
|
39218
|
-
|
|
39219
|
-
|
|
39220
|
-
|
|
39221
|
-
|
|
39222
|
-
|
|
39223
|
-
|
|
39224
|
-
|
|
39225
|
-
|
|
39226
|
-
|
|
39227
|
-
|
|
39228
|
-
|
|
39229
|
-
|
|
39230
|
-
|
|
39231
|
-
|
|
39232
|
-
|
|
39233
|
-
|
|
39234
|
-
|
|
39330
|
+
choices.push({
|
|
39331
|
+
value: "create",
|
|
39332
|
+
selected: !!draft.isCreating,
|
|
39333
|
+
title: jj2 ? "Create new workspace\u2026" : "Create new worktree\u2026",
|
|
39334
|
+
description: jj2 ? "Choose starting revision and directory" : "Choose branch and directory"
|
|
39335
|
+
});
|
|
39336
|
+
const picked = yield* choose(jj2 ? "Workspace (select existing or create new)" : "Worktree (select existing or create new)", choices);
|
|
39337
|
+
if (picked === "primary") {
|
|
39338
|
+
const clone = draft.clone;
|
|
39339
|
+
draft = {
|
|
39340
|
+
...draft,
|
|
39341
|
+
isCreating: false,
|
|
39342
|
+
directory: undefined,
|
|
39343
|
+
worktreeName: undefined,
|
|
39344
|
+
destination: clone.vcs === "git" && clone.branch ? { branch: clone.branch, label: clone.branch } : undefined
|
|
39345
|
+
};
|
|
39346
|
+
} else if (picked === "create") {
|
|
39347
|
+
let name = "workspace";
|
|
39348
|
+
if (jj2)
|
|
39349
|
+
for (let suffix = 2;trees.some((tree) => tree.vcs === "jj" && tree.name === name); suffix++)
|
|
39350
|
+
name = `workspace-${suffix}`;
|
|
39351
|
+
const mainline = (draft.clone?.vcs === "jj" ? draft.clone.revisions : found?.revisions)?.find((choice) => choice.expression === "trunk()");
|
|
39352
|
+
draft = {
|
|
39353
|
+
...draft,
|
|
39354
|
+
isCreating: true,
|
|
39355
|
+
directory: undefined,
|
|
39356
|
+
worktreeName: jj2 ? name : undefined,
|
|
39357
|
+
worktreeRoot: found ? found.worktreeRoot : draft.worktreeRoot,
|
|
39358
|
+
destination: jj2 && mainline ? { revision: mainline.revision.commitId, label: mainline.label } : { label: jj2 ? "Create new workspace\u2026" : "Create new worktree\u2026" }
|
|
39359
|
+
};
|
|
39360
|
+
isBranchEditPending = !jj2;
|
|
39361
|
+
} else
|
|
39362
|
+
draft = selectWorktree(draft, picked);
|
|
39235
39363
|
} else if (action === "checkoutName") {
|
|
39364
|
+
const proposed = draft.clone && !draft.isCreating && draft.projectChoice ? clonePath(draft.projectChoice) : directoryFor({ ...draft, directory: undefined });
|
|
39236
39365
|
const picked = yield* inputChoice({
|
|
39237
|
-
message:
|
|
39238
|
-
choices: [
|
|
39239
|
-
{ value: null, title: "Use default", description: "No separate custom name" },
|
|
39240
|
-
...draft.worktreeName ? [{ value: draft.worktreeName, title: "Current custom name" }] : []
|
|
39241
|
-
]
|
|
39366
|
+
message: "Directory (absolute path on selected machine)",
|
|
39367
|
+
choices: proposed ? [{ value: proposed, title: "Use proposed directory", description: proposed }] : []
|
|
39242
39368
|
});
|
|
39243
|
-
|
|
39244
|
-
|
|
39245
|
-
|
|
39246
|
-
|
|
39247
|
-
|
|
39248
|
-
|
|
39249
|
-
|
|
39250
|
-
|
|
39369
|
+
const text = (picked.kind === "selected" ? picked.value : picked.text).trim();
|
|
39370
|
+
if (!path.isAbsolute(text) || /[\p{ASCII}&&\p{Cc}]/v.test(text) || path.dirname(path.resolve(text)) === path.resolve(text))
|
|
39371
|
+
return yield* exports_Effect.fail(new AppError({ message: "Directory must be an absolute non-root path on this machine" }));
|
|
39372
|
+
const directory = path.resolve(text);
|
|
39373
|
+
if (draft.clone && !draft.isCreating)
|
|
39374
|
+
draft = { ...draft, clone: { ...draft.clone, repo: directory } };
|
|
39375
|
+
else
|
|
39376
|
+
draft = {
|
|
39377
|
+
...draft,
|
|
39378
|
+
directory,
|
|
39379
|
+
...(draft.clone?.vcs ?? draft.project?.vcs) === "jj" ? { worktreeName: path.basename(directory) } : {}
|
|
39380
|
+
};
|
|
39251
39381
|
} else if (action === "branch") {
|
|
39252
39382
|
if (!draft.host || !(draft.project || draft.clone))
|
|
39253
39383
|
return yield* exports_Effect.fail(new AppError({ message: "Select a project and machine before choosing a base or branch" }));
|
|
@@ -39297,18 +39427,28 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39297
39427
|
if (jjClone)
|
|
39298
39428
|
draft = { ...draft, clone: { ...jjClone, revision: choice.revision } };
|
|
39299
39429
|
}
|
|
39300
|
-
} else
|
|
39430
|
+
} else {
|
|
39431
|
+
const clone = draft.clone?.vcs === "git" ? draft.clone : undefined;
|
|
39432
|
+
const found = clone ? undefined : yield* inspectWorktrees(draft.host, command, draft.project.path);
|
|
39433
|
+
const occupied = new Set;
|
|
39434
|
+
for (const tree of found?.worktrees ?? [])
|
|
39435
|
+
if (tree.vcs === "git" && tree.branch)
|
|
39436
|
+
occupied.add(tree.branch);
|
|
39437
|
+
if (clone && draft.isCreating && clone.branch)
|
|
39438
|
+
occupied.add(clone.branch);
|
|
39301
39439
|
const picked = yield* inputChoice({
|
|
39302
|
-
message: "Branch (select
|
|
39303
|
-
choices:
|
|
39440
|
+
message: "Branch (select unused or type new name)",
|
|
39441
|
+
choices: (clone?.branches ?? found?.branches ?? []).filter((branch2) => !occupied.has(branch2)).map((branch2) => ({
|
|
39304
39442
|
value: branch2,
|
|
39305
39443
|
title: branch2,
|
|
39306
|
-
description: "
|
|
39444
|
+
description: clone ? "Published branch" : "Existing branch \xB7 new worktree"
|
|
39307
39445
|
}))
|
|
39308
39446
|
});
|
|
39309
39447
|
const branch = picked.kind === "selected" ? picked.value : picked.text.trim();
|
|
39310
39448
|
if (!branch || branch.startsWith("-") || /[\p{ASCII}&&\p{Cc}]/v.test(branch))
|
|
39311
39449
|
return yield* exports_Effect.fail(new AppError({ message: "Branch name must be a valid Git branch" }));
|
|
39450
|
+
if (occupied.has(branch))
|
|
39451
|
+
return yield* exports_Effect.fail(new AppError({ message: `Branch ${branch} is already checked out; select its existing worktree instead` }));
|
|
39312
39452
|
draft = { ...draft, destination: { branch, label: branch } };
|
|
39313
39453
|
}
|
|
39314
39454
|
} else if (action === "session") {
|
|
@@ -39341,7 +39481,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39341
39481
|
}
|
|
39342
39482
|
}
|
|
39343
39483
|
}).pipe(exports_Effect.catchCause((cause) => exports_Cause.hasInterrupts(cause) || launchAcknowledged ? exports_Effect.failCause(cause) : acknowledge("Could not open worktrees", [exports_Cause.pretty(cause)], "error").pipe(exports_Effect.andThen(exports_Effect.failCause(cause)))), exports_Effect.provideServiceEffect(exports_Terminal.Terminal, exports_Effect.gen(function* () {
|
|
39344
|
-
const terminal = yield*
|
|
39484
|
+
const terminal = yield* exports_BunTerminal.make(({ key: key5 }) => key5.ctrl && (key5.name === "c" || key5.name === "d"));
|
|
39345
39485
|
const input = yield* terminal.readInput;
|
|
39346
39486
|
return { ...terminal, readInput: exports_Effect.succeed(input) };
|
|
39347
39487
|
})));
|