rex-worktrees 0.4.5 → 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 +15 -9
- package/dist/rex-worktrees +2 -2
- package/dist/rex-worktrees.js +307 -205
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Rex Worktrees
|
|
2
2
|
|
|
3
|
-
A keyboard-driven [Rex](https://www.superlogical.com/rex/docs) plugin for opening and creating **Git worktrees** and **Jujutsu (JJ) workspaces**. Pick a project, machine,
|
|
3
|
+
A keyboard-driven [Rex](https://www.superlogical.com/rex/docs) plugin for opening and creating **Git worktrees** and **Jujutsu (JJ) workspaces**. Pick a project, machine, session, and worktree; it opens a shell there. No agent or model required.
|
|
4
4
|
|
|
5
5
|
<img width="693" height="236" alt="image" src="https://github.com/user-attachments/assets/fadd8e3c-30fc-4f94-98ca-41132a23ff36" />
|
|
6
6
|
|
|
@@ -34,15 +34,21 @@ Open **Open Worktree…** from the Rex palette, or run:
|
|
|
34
34
|
rex do worktrees_open
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
The popup detects the source terminal's project, current worktree, branch or revision, and full directory path. Git worktrees are separate checkout directories sharing one repository—not separate repositories or branch names.
|
|
38
|
+
|
|
37
39
|
1. **Project:** select a discovered project or type an absolute repository path.
|
|
38
40
|
2. **Machine:** choose this machine or an existing Rex host.
|
|
39
|
-
3. **
|
|
40
|
-
4. **
|
|
41
|
-
5.
|
|
41
|
+
3. **Session:** select an existing session, or type a name to create one.
|
|
42
|
+
4. **Worktree / Workspace:** select an existing one, or choose **Create new worktree… / Create new workspace…**. This list contains worktrees, not branches or clone actions.
|
|
43
|
+
5. **Branch:** **Create new worktree…** opens the branch editor directly, without another click on the form. Select an unused existing branch or type a new branch name. JJ uses **Start from** instead; a valid `trunk()` is selected automatically.
|
|
44
|
+
6. **Directory:** new worktrees get a proposed absolute path; change it only if needed. A new JJ workspace takes its name from the directory's final component.
|
|
45
|
+
7. Choose **Open worktree / Create worktree & open**, or press **Ctrl+S** from the form. Accepting a field only updates the form; creation happens on submission.
|
|
46
|
+
|
|
47
|
+
**Mode** reuses a matching tab by default; choose a new tab or split instead.
|
|
42
48
|
|
|
43
|
-
**
|
|
49
|
+
For an **existing worktree**, Branch (or Revision) and Directory describe the detected checkout. They remain readable and **read-only—not disabled**; Tab skips them. Select a different worktree to open another checkout. For a **new worktree**, Branch and Directory are editable.
|
|
44
50
|
|
|
45
|
-
The underlined `REX / WORKTREES` header and
|
|
51
|
+
The underlined `REX / WORKTREES` header, fields, and footer keep fixed positions. Editors and messages reuse the same details area, so only choice lists and long details scroll.
|
|
46
52
|
|
|
47
53
|
Shells and interactive Git/JJ clones stay attached to the destination terminal. The shell comes from `$SHELL`, falling back to `/bin/sh`.
|
|
48
54
|
|
|
@@ -52,7 +58,7 @@ Shells and interactive Git/JJ clones stay attached to the destination terminal.
|
|
|
52
58
|
| ↑ / ↓ | Navigate fields or choices |
|
|
53
59
|
| Enter | Edit a field, accept its value, or activate a focused button |
|
|
54
60
|
| Ctrl+S | Submit the form; inside an editor, only accept that field |
|
|
55
|
-
| Esc |
|
|
61
|
+
| Esc | Return from an editor to the form; from the form, close the popup |
|
|
56
62
|
| PageUp / PageDown | Scroll long details |
|
|
57
63
|
|
|
58
64
|
Optional shortcut—add outside the managed section of your Rex config, then reload:
|
|
@@ -78,11 +84,11 @@ Both settings are optional. `projects` lists repositories explicitly; `roots` di
|
|
|
78
84
|
|
|
79
85
|
Install and run setup on each execution machine, with matching plugin versions and local Git/JJ tools. Connect the host through Rex first. Paths and configuration belong to the selected machine.
|
|
80
86
|
|
|
81
|
-
The
|
|
87
|
+
If the selected machine lacks the project, the form proposes cloning it and shows the repository destination explicitly. **Directory** edits that path, and submission becomes **Clone & open**. Changing a field never starts a clone. The Worktree picker can also create a separate worktree after cloning; Directory then controls that worktree's path. Cloning opens a new tab. Only pushed history transfers—not uncommitted work, unpublished changes, or credentials. Cross-host execution and cloning are experimental; live remote Linux destinations have not been verified.
|
|
82
88
|
|
|
83
89
|
## Safety
|
|
84
90
|
|
|
85
|
-
- Existing checkouts open unchanged. The plugin
|
|
91
|
+
- Existing checkouts open unchanged. The plugin never switches, resets, stashes, cleans, or deletes an existing checkout.
|
|
86
92
|
- **Creating a JJ workspace runs `jj workspace add`, which may snapshot its source workspace.**
|
|
87
93
|
- Closing the chooser or a tab does not delete a checkout or stop an already-submitted task.
|
|
88
94
|
- If a launch times out or says **needs inspection**, inspect the destination and session before retrying; a task may already exist.
|
package/dist/rex-worktrees
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/dist/rex-worktrees
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 64508304 bytes
|
|
4
|
+
sha256: c869f674c2632f77c9316460b8dd1ea66b585d5cafc407046d5851cd90cb8bd4
|
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 }),
|
|
@@ -34011,14 +34024,14 @@ var originDefaultHead = exports_Effect.fnUntraced(function* (repoPath) {
|
|
|
34011
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")));
|
|
34012
34025
|
return (yield* git(repoPath, "rev-parse", "--verify", `${ref.trim()}^{commit}`)).trim();
|
|
34013
34026
|
});
|
|
34014
|
-
var cloneRepository = exports_Effect.fnUntraced(function* (url, destination) {
|
|
34027
|
+
var cloneRepository = exports_Effect.fnUntraced(function* (url, destination, branch) {
|
|
34015
34028
|
const spawner = yield* exports_ChildProcessSpawner.ChildProcessSpawner;
|
|
34016
34029
|
const env = {};
|
|
34017
34030
|
for (const [key5, value3] of Object.entries(process.env))
|
|
34018
34031
|
if (!key5.startsWith("GIT_") && value3 !== undefined)
|
|
34019
34032
|
env[key5] = value3;
|
|
34020
34033
|
env.GIT_TERMINAL_PROMPT = "1";
|
|
34021
|
-
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], {
|
|
34022
34035
|
env,
|
|
34023
34036
|
detached: false,
|
|
34024
34037
|
stdin: "inherit",
|
|
@@ -34029,6 +34042,9 @@ var cloneRepository = exports_Effect.fnUntraced(function* (url, destination) {
|
|
|
34029
34042
|
if (code !== 0)
|
|
34030
34043
|
return yield* fail17(`Git clone failed (exit ${code}); destination retained at ${destination}`);
|
|
34031
34044
|
}, exports_Effect.scoped);
|
|
34045
|
+
var createPrimaryBranch = exports_Effect.fnUntraced(function* (repoPath, branch) {
|
|
34046
|
+
yield* git(repoPath, "switch", "-c", branch);
|
|
34047
|
+
});
|
|
34032
34048
|
var validCloneBranch = exports_Effect.fnUntraced(function* (branch, worktreeName) {
|
|
34033
34049
|
if (!branch || branch.startsWith("-") || branch.split("/").some((part) => !part || part === "." || part === "..") || /[\p{ASCII}&&\p{Cc}]/v.test(branch))
|
|
34034
34050
|
return yield* fail17("Invalid clone branch");
|
|
@@ -34825,6 +34841,11 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34825
34841
|
const repo = yield* repository3(input.repo);
|
|
34826
34842
|
if (repo.vcs !== input.vcs)
|
|
34827
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");
|
|
34828
34849
|
let path;
|
|
34829
34850
|
let checkout;
|
|
34830
34851
|
let branch = null;
|
|
@@ -34838,9 +34859,11 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34838
34859
|
return yield* fail19("Select exactly one branch or existing worktree path");
|
|
34839
34860
|
if (input.path && input.worktreeName !== undefined)
|
|
34840
34861
|
return yield* fail19("Worktree name only applies to a branch checkout");
|
|
34841
|
-
worktreeRoot = input.branch ? yield* resolveWorktreeRoot(repo.path) : undefined;
|
|
34862
|
+
worktreeRoot = input.branch ? input.directory ? pathService.dirname(input.directory) : yield* resolveWorktreeRoot(repo.path) : undefined;
|
|
34842
34863
|
if (input.branch) {
|
|
34843
|
-
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");
|
|
34844
34867
|
path = destination.path;
|
|
34845
34868
|
branch = input.branch;
|
|
34846
34869
|
checkout = destination.existing ? "existing" : (yield* listBranches(repo.path)).includes(branch) ? "attach" : "create";
|
|
@@ -34868,7 +34891,9 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34868
34891
|
workspaceName = tree.name;
|
|
34869
34892
|
checkout = "existing";
|
|
34870
34893
|
} else {
|
|
34871
|
-
|
|
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);
|
|
34872
34897
|
const planned = yield* planWorkspace(repo.path, input.worktreeName, input.revision, worktreeRoot);
|
|
34873
34898
|
path = planned.path;
|
|
34874
34899
|
workspaceName = planned.workspaceName;
|
|
@@ -34917,7 +34942,7 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34917
34942
|
return {
|
|
34918
34943
|
...common,
|
|
34919
34944
|
vcs: "git",
|
|
34920
|
-
input: { ...input, repo: repo.path, ...input.path ? { path } : {} },
|
|
34945
|
+
input: { ...input, repo: repo.path, ...input.path ? { path } : {}, ...input.directory ? { worktreeName: pathService.basename(input.directory) } : {} },
|
|
34921
34946
|
branch,
|
|
34922
34947
|
checkout,
|
|
34923
34948
|
...gitBase ? { base: gitBase } : {},
|
|
@@ -34933,7 +34958,7 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34933
34958
|
label: action === "focus" ? "Focus existing tab" : checkout === "create" ? "Create workspace & open" : action === "split" ? "Open pane" : "Open tab"
|
|
34934
34959
|
};
|
|
34935
34960
|
});
|
|
34936
|
-
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);
|
|
34937
34962
|
var launch = exports_Effect.fnUntraced(function* (input, command, reviewed, expectedHostId) {
|
|
34938
34963
|
const pathService = yield* exports_Path.Path;
|
|
34939
34964
|
if (!command[0] || !pathService.isAbsolute(command[0]))
|
|
@@ -35145,12 +35170,26 @@ var checkCloneParent = exports_Effect.fnUntraced(function* (destination) {
|
|
|
35145
35170
|
catch: (cause) => new AppError({ message: `Cannot create clone destination ${destination}: ${ancestor} is not writable; choose another destination or fix its permissions`, cause })
|
|
35146
35171
|
});
|
|
35147
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
|
+
});
|
|
35148
35186
|
var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
35149
35187
|
const host = yield* localHost;
|
|
35150
35188
|
if (expectedHostId && host.id !== expectedHostId)
|
|
35151
35189
|
return yield* fail19("Wrong Rex clone host");
|
|
35152
35190
|
if (input.vcs !== input.source.vcs)
|
|
35153
35191
|
return yield* fail19("Clone source backend does not match request");
|
|
35192
|
+
yield* validateCloneDestination(input);
|
|
35154
35193
|
yield* exports_Schema.decodeUnknownEffect(SessionSelectionSchema)(input.session);
|
|
35155
35194
|
if (input.session.kind === "existing") {
|
|
35156
35195
|
const sessionId = input.session.id;
|
|
@@ -35174,6 +35213,8 @@ var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
35174
35213
|
if (commonDir === undefined)
|
|
35175
35214
|
yield* checkCloneParent(input.repo);
|
|
35176
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");
|
|
35177
35218
|
let gitBase;
|
|
35178
35219
|
let base;
|
|
35179
35220
|
if (input.vcs === "git") {
|
|
@@ -35192,9 +35233,14 @@ var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
35192
35233
|
}
|
|
35193
35234
|
if (input.vcs === "jj" && existing && !base)
|
|
35194
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
|
+
}
|
|
35195
35241
|
const clientId = input.clientId ?? (clients.length === 1 ? clients[0]?.id : undefined);
|
|
35196
35242
|
const warning = !clientId && clients.length > 1 ? "Multiple Rex apps are connected; select the intended app" : undefined;
|
|
35197
|
-
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;
|
|
35198
35244
|
const common = {
|
|
35199
35245
|
hostId: host.id,
|
|
35200
35246
|
...clientId ? { clientId } : {},
|
|
@@ -35219,7 +35265,7 @@ var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
35219
35265
|
...base ? { base } : {}
|
|
35220
35266
|
};
|
|
35221
35267
|
});
|
|
35222
|
-
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));
|
|
35223
35269
|
var launchClone = exports_Effect.fnUntraced(function* (input, command, reviewed, expectedHostId) {
|
|
35224
35270
|
const path = yield* exports_Path.Path;
|
|
35225
35271
|
if (!command[0] || !path.isAbsolute(command[0]))
|
|
@@ -35242,6 +35288,9 @@ var launchClone = exports_Effect.fnUntraced(function* (input, command, reviewed,
|
|
|
35242
35288
|
return result4;
|
|
35243
35289
|
});
|
|
35244
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");
|
|
35245
35294
|
if (plan.vcs === "git")
|
|
35246
35295
|
yield* validCloneBranch(plan.input.branch, plan.input.worktreeName);
|
|
35247
35296
|
const url = yield* exports_Effect.try({
|
|
@@ -35273,7 +35322,7 @@ var prepareCloneCheckout = exports_Effect.fnUntraced(function* (plan) {
|
|
|
35273
35322
|
if ((yield* fs.realPath(parent)) !== parent || (yield* fs.realPath(plan.repo)) !== plan.repo)
|
|
35274
35323
|
return yield* fail19(`Clone path changed; reserved destination retained at ${plan.repo}`);
|
|
35275
35324
|
if (plan.vcs === "git")
|
|
35276
|
-
yield* cloneRepository(url, plan.repo);
|
|
35325
|
+
yield* cloneRepository(url, plan.repo, plan.input.checkout === "primary" && plan.input.branchMode === "existing" ? plan.input.branch : undefined);
|
|
35277
35326
|
else
|
|
35278
35327
|
yield* cloneRepository2(url, plan.repo);
|
|
35279
35328
|
}
|
|
@@ -35286,11 +35335,18 @@ var prepareCloneCheckout = exports_Effect.fnUntraced(function* (plan) {
|
|
|
35286
35335
|
if (plan.vcs === "jj") {
|
|
35287
35336
|
const base = plan.base ?? (yield* resolveRevision(repo.path, "@-"));
|
|
35288
35337
|
let cwd2;
|
|
35289
|
-
|
|
35290
|
-
|
|
35291
|
-
|
|
35292
|
-
|
|
35293
|
-
|
|
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);
|
|
35294
35350
|
if (!created.path || !created.present || created.path !== planned.path)
|
|
35295
35351
|
return yield* fail19(`JJ workspace registration changed; clone retained at ${plan.repo}`);
|
|
35296
35352
|
cwd2 = created.path;
|
|
@@ -35307,16 +35363,32 @@ var prepareCloneCheckout = exports_Effect.fnUntraced(function* (plan) {
|
|
|
35307
35363
|
const local = yield* listBranches(repo.path);
|
|
35308
35364
|
const remote = yield* remoteBranches(repo.path);
|
|
35309
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;
|
|
35310
35381
|
let cwd;
|
|
35311
35382
|
if (branchMode === "existing") {
|
|
35312
35383
|
if (!local.includes(branch) && !remote.includes(branch))
|
|
35313
35384
|
return yield* fail19(`Branch ${branch} was not pushed to origin; clone retained at ${plan.repo}`);
|
|
35314
|
-
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");
|
|
35315
35388
|
if (local.includes(branch)) {
|
|
35316
|
-
|
|
35317
|
-
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;
|
|
35318
35390
|
} else {
|
|
35319
|
-
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;
|
|
35320
35392
|
}
|
|
35321
35393
|
} else {
|
|
35322
35394
|
if (local.includes(branch) || remote.includes(branch))
|
|
@@ -35324,7 +35396,7 @@ var prepareCloneCheckout = exports_Effect.fnUntraced(function* (plan) {
|
|
|
35324
35396
|
const base = plan.existing ? plan.base : (yield* repositoryHead(repo.path)).head;
|
|
35325
35397
|
if (!base)
|
|
35326
35398
|
return yield* fail19("Origin default branch changed since review");
|
|
35327
|
-
cwd = (yield* createWorktree(repo.path, branch, { startPoint: base, worktreeRoot
|
|
35399
|
+
cwd = (yield* createWorktree(repo.path, branch, { startPoint: base, worktreeRoot, worktreeName })).path;
|
|
35328
35400
|
}
|
|
35329
35401
|
return { repo, cwd: yield* fs.realPath(cwd) };
|
|
35330
35402
|
});
|
|
@@ -35406,7 +35478,8 @@ var dispatchHost = exports_Effect.fnUntraced(function* (request3, command) {
|
|
|
35406
35478
|
const inventory2 = yield* exports_Effect.all({
|
|
35407
35479
|
worktrees: canonical2.vcs === "git" ? listWorktrees(canonical2.path) : listWorkspaces(canonical2.path),
|
|
35408
35480
|
branches: canonical2.vcs === "git" ? listBranches(canonical2.path) : exports_Effect.succeed([]),
|
|
35409
|
-
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)
|
|
35410
35483
|
}, { concurrency: 4 });
|
|
35411
35484
|
result4 = {
|
|
35412
35485
|
...identity3,
|
|
@@ -35431,7 +35504,8 @@ var dispatchHost = exports_Effect.fnUntraced(function* (request3, command) {
|
|
|
35431
35504
|
const inventory2 = yield* exports_Effect.all({
|
|
35432
35505
|
worktrees: repo.vcs === "git" ? listWorktrees(repo.path) : listWorkspaces(repo.path),
|
|
35433
35506
|
branches: repo.vcs === "git" ? listBranches(repo.path) : exports_Effect.succeed([]),
|
|
35434
|
-
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)
|
|
35435
35509
|
}, { concurrency: 4 });
|
|
35436
35510
|
result4 = {
|
|
35437
35511
|
...identity3,
|
|
@@ -35542,13 +35616,13 @@ var inspectProject = exports_Effect.fnUntraced(function* (host, command, path) {
|
|
|
35542
35616
|
return yield* fail20(`Project directory does not exist: ${result4.path}`);
|
|
35543
35617
|
if (result4.kind !== "project")
|
|
35544
35618
|
return yield* fail20("Unexpected project response");
|
|
35545
|
-
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 };
|
|
35546
35620
|
});
|
|
35547
35621
|
var inspectWorktrees = exports_Effect.fnUntraced(function* (host, command, repo) {
|
|
35548
35622
|
const result4 = yield* request3(host, command, { kind: "worktrees", repo });
|
|
35549
35623
|
if (result4.kind !== "worktrees")
|
|
35550
35624
|
return yield* fail20("Unexpected worktree response");
|
|
35551
|
-
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 };
|
|
35552
35626
|
});
|
|
35553
35627
|
var inspectRevision = exports_Effect.fnUntraced(function* (host, command, repo, revision) {
|
|
35554
35628
|
const result4 = yield* request3(host, command, { kind: "revision", repo, revision });
|
|
@@ -38556,10 +38630,10 @@ var pad = (text, width2) => text + " ".repeat(Math.max(0, width2 - Bun.stringWid
|
|
|
38556
38630
|
var formRows = [
|
|
38557
38631
|
{ id: "project", label: "Project", value: "\u2014", disabled: true },
|
|
38558
38632
|
{ id: "machine", label: "Machine", value: "\u2014", disabled: true },
|
|
38559
|
-
{ id: "
|
|
38633
|
+
{ id: "session", label: "Session", value: "\u2014", disabled: true },
|
|
38634
|
+
{ id: "destination", label: "Worktree", value: "\u2014", disabled: true },
|
|
38560
38635
|
{ id: "branch", label: "Branch", value: "\u2014", disabled: true },
|
|
38561
38636
|
{ id: "checkoutName", label: "Directory", value: "\u2014", disabled: true },
|
|
38562
|
-
{ id: "session", label: "Session", value: "\u2014", disabled: true },
|
|
38563
38637
|
{ id: "mode", label: "Mode", value: "\u2014", disabled: true }
|
|
38564
38638
|
];
|
|
38565
38639
|
var choiceCount = popupSize.rows - formRows.length - 6;
|
|
@@ -38668,7 +38742,18 @@ var acknowledge = (title, lines2, tone, view = { rows: [], submitLabel: "Close"
|
|
|
38668
38742
|
})).pipe(exports_Effect.catch(() => exports_Effect.void));
|
|
38669
38743
|
var problem = (error2) => error2 instanceof AppError ? error2.message : exports_Cause.pretty(exports_Cause.fail(error2));
|
|
38670
38744
|
var selected = (value3, current, title, description) => ({ value: value3, selected: current, title, description });
|
|
38671
|
-
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";
|
|
38672
38757
|
var inputFor = (draft) => {
|
|
38673
38758
|
if (!draft.host || !draft.project || !draft.projectChoice || !draft.destination || !draft.session)
|
|
38674
38759
|
return;
|
|
@@ -38680,9 +38765,20 @@ var inputFor = (draft) => {
|
|
|
38680
38765
|
additional: draft.mode === "new-tab",
|
|
38681
38766
|
split: draft.mode === "split"
|
|
38682
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;
|
|
38683
38773
|
if (draft.project.vcs === "jj")
|
|
38684
|
-
return draft.
|
|
38685
|
-
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;
|
|
38686
38782
|
};
|
|
38687
38783
|
var changeProjectChoice = (draft, projectChoice) => ({
|
|
38688
38784
|
...draft,
|
|
@@ -38691,20 +38787,30 @@ var changeProjectChoice = (draft, projectChoice) => ({
|
|
|
38691
38787
|
clone: undefined,
|
|
38692
38788
|
destination: undefined,
|
|
38693
38789
|
worktreeName: undefined,
|
|
38790
|
+
directory: undefined,
|
|
38791
|
+
worktreeRoot: undefined,
|
|
38792
|
+
isCreating: false,
|
|
38694
38793
|
sourcePath: undefined
|
|
38695
38794
|
});
|
|
38696
|
-
var changeProject = (draft, candidate) =>
|
|
38697
|
-
|
|
38698
|
-
|
|
38699
|
-
|
|
38700
|
-
|
|
38701
|
-
|
|
38702
|
-
|
|
38703
|
-
|
|
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
|
+
};
|
|
38704
38808
|
var changeDestination = (draft, candidate, worktreeName) => ({
|
|
38705
38809
|
...draft,
|
|
38706
38810
|
destination: candidate,
|
|
38707
|
-
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
|
|
38708
38814
|
});
|
|
38709
38815
|
var selectWorktree = (draft, tree) => {
|
|
38710
38816
|
if (!tree.path || tree.vcs === "jj" && !tree.present)
|
|
@@ -38712,6 +38818,7 @@ var selectWorktree = (draft, tree) => {
|
|
|
38712
38818
|
return {
|
|
38713
38819
|
...changeDestination(draft, {
|
|
38714
38820
|
path: tree.path,
|
|
38821
|
+
worktree: tree,
|
|
38715
38822
|
label: tree.vcs === "jj" ? tree.name : tree.path.split("/").filter(Boolean).at(-1) ?? tree.path
|
|
38716
38823
|
}),
|
|
38717
38824
|
...tree.vcs === "jj" ? {
|
|
@@ -38720,15 +38827,14 @@ var selectWorktree = (draft, tree) => {
|
|
|
38720
38827
|
} : {}
|
|
38721
38828
|
};
|
|
38722
38829
|
};
|
|
38723
|
-
var typeWorktreeName = (draft, name, mainline) => ({
|
|
38724
|
-
...draft,
|
|
38725
|
-
worktreeName: name,
|
|
38726
|
-
destination: draft.destination && !draft.destination.path ? draft.destination : draft.project?.vcs === "jj" && !draft.clone && mainline ? { revision: mainline.revision.commitId, label: mainline.label } : undefined
|
|
38727
|
-
});
|
|
38728
38830
|
var selectRevision = (draft, choice) => changeDestination(draft, { revision: choice.revision.commitId, label: choice.label }, draft.worktreeName);
|
|
38729
38831
|
var cloneInputFor = (draft) => {
|
|
38730
38832
|
if (!draft.host || !draft.clone || !draft.session || !draft.clone.repo.startsWith("/"))
|
|
38731
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;
|
|
38732
38838
|
if (draft.clone.vcs === "jj") {
|
|
38733
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;
|
|
38734
38840
|
return {
|
|
@@ -38743,8 +38849,10 @@ var cloneInputFor = (draft) => {
|
|
|
38743
38849
|
repo: draft.clone.repo,
|
|
38744
38850
|
session: draft.session,
|
|
38745
38851
|
clientId: draft.clientId,
|
|
38852
|
+
checkout,
|
|
38853
|
+
directory,
|
|
38746
38854
|
name: generatedName(draft),
|
|
38747
|
-
...draft.worktreeName ? { worktreeName: draft.worktreeName } : {},
|
|
38855
|
+
...draft.isCreating && draft.worktreeName ? { worktreeName: draft.worktreeName } : {},
|
|
38748
38856
|
...draft.destination?.revision ? { revision: draft.destination.revision } : {}
|
|
38749
38857
|
};
|
|
38750
38858
|
}
|
|
@@ -38762,25 +38870,28 @@ var cloneInputFor = (draft) => {
|
|
|
38762
38870
|
repo: draft.clone.repo,
|
|
38763
38871
|
session: draft.session,
|
|
38764
38872
|
clientId: draft.clientId,
|
|
38873
|
+
checkout,
|
|
38874
|
+
directory,
|
|
38765
38875
|
name: generatedName(draft),
|
|
38766
38876
|
branch: draft.destination.branch,
|
|
38767
38877
|
branchMode: draft.clone.branches.includes(draft.destination.branch) ? "existing" : "create",
|
|
38768
|
-
...draft.worktreeName ? { worktreeName: draft.worktreeName } : {}
|
|
38878
|
+
...draft.isCreating && draft.worktreeName ? { worktreeName: draft.worktreeName } : {}
|
|
38769
38879
|
};
|
|
38770
38880
|
};
|
|
38771
38881
|
var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effect.scoped(exports_Effect.suspend(() => {
|
|
38772
38882
|
let launchAcknowledged = false;
|
|
38773
38883
|
return exports_Effect.gen(function* () {
|
|
38774
38884
|
const terminal = yield* exports_Terminal.Terminal;
|
|
38885
|
+
const path = yield* exports_Path.Path;
|
|
38775
38886
|
yield* exports_Effect.acquireRelease(terminal.display("\x1B[?1049h\x1B[?25l"), () => terminal.display("\x1B[?25h\x1B[?1049l").pipe(exports_Effect.orDie));
|
|
38776
38887
|
let machines = [];
|
|
38777
38888
|
let draft = { mode: "auto" };
|
|
38778
38889
|
let sessions = [];
|
|
38779
38890
|
let focused = "project";
|
|
38891
|
+
let isBranchEditPending = false;
|
|
38780
38892
|
let error2;
|
|
38781
38893
|
let blocked = false;
|
|
38782
38894
|
let cloneRoot = "";
|
|
38783
|
-
let cloneRoots = [];
|
|
38784
38895
|
let contextPath;
|
|
38785
38896
|
let activeView;
|
|
38786
38897
|
const resizeEvents = exports_Effect.gen(function* () {
|
|
@@ -38792,7 +38903,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38792
38903
|
const chooseField = exports_Effect.fnUntraced(function* (view, initialFocus) {
|
|
38793
38904
|
let detailOffset = 0;
|
|
38794
38905
|
let visibleRows = popupSize.rows;
|
|
38795
|
-
const fields = [...formRows.filter((slot) => view.rows.some((row) => row.id === slot.id)).map((row) => row.id), "submit", "cancel"];
|
|
38906
|
+
const fields = [...formRows.filter((slot) => view.rows.some((row) => row.id === slot.id && !row.disabled && !row.isReadOnly)).map((row) => row.id), "submit", "cancel"];
|
|
38796
38907
|
const initial = Math.max(0, fields.indexOf(initialFocus));
|
|
38797
38908
|
const prompt = exports_Prompt.Custom(initial, yield* resizeEvents, {
|
|
38798
38909
|
render: (index2, action) => action._tag === "Submit" ? exports_Effect.succeed("") : exports_Effect.gen(function* () {
|
|
@@ -38818,7 +38929,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38818
38929
|
return exports_Effect.succeed(view.submitDisabled ? { _tag: "Beep" } : { _tag: "Submit", value: "submit" });
|
|
38819
38930
|
if (key5.name === "enter" || key5.name === "return") {
|
|
38820
38931
|
const selected2 = fields[index2];
|
|
38821
|
-
return exports_Effect.succeed(selected2 === "submit" && view.submitDisabled
|
|
38932
|
+
return exports_Effect.succeed(selected2 === "submit" && view.submitDisabled ? { _tag: "Beep" } : { _tag: "Submit", value: selected2 });
|
|
38822
38933
|
}
|
|
38823
38934
|
const backward = key5.name === "up" || key5.name === "k" && !key5.ctrl || key5.name === "backtab" || key5.name === "tab" && key5.shift;
|
|
38824
38935
|
const forward = key5.name === "down" || key5.name === "j" && !key5.ctrl || key5.name === "tab";
|
|
@@ -38902,59 +39013,48 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38902
39013
|
projectChoice: choice,
|
|
38903
39014
|
host,
|
|
38904
39015
|
project: undefined,
|
|
39016
|
+
sourcePath: undefined,
|
|
38905
39017
|
clone: { ...source, repo },
|
|
38906
39018
|
destination: source.vcs === "git" && source.branch ? { branch: source.branch, label: source.branch } : undefined,
|
|
38907
|
-
worktreeName: undefined
|
|
39019
|
+
worktreeName: undefined,
|
|
39020
|
+
directory: undefined,
|
|
39021
|
+
worktreeRoot: undefined,
|
|
39022
|
+
isCreating: false
|
|
38908
39023
|
};
|
|
38909
39024
|
});
|
|
38910
|
-
const cloneDestination2 = exports_Effect.fnUntraced(function* (choice, host) {
|
|
38911
|
-
let repo = clonePath(choice);
|
|
38912
|
-
if (!repo) {
|
|
38913
|
-
const picked = yield* inputChoice({
|
|
38914
|
-
message: "Project name is not a safe clone directory; type an absolute clone destination",
|
|
38915
|
-
choices: []
|
|
38916
|
-
});
|
|
38917
|
-
repo = picked.kind === "selected" ? picked.value : picked.text.trim();
|
|
38918
|
-
}
|
|
38919
|
-
if (!repo.startsWith("/"))
|
|
38920
|
-
return yield* exports_Effect.fail(new AppError({ message: "Clone destination must be an absolute path on this machine" }));
|
|
38921
|
-
yield* proposeClone(choice, host, repo);
|
|
38922
|
-
});
|
|
38923
39025
|
const bindProject = exports_Effect.fnUntraced(function* (choice, host, available) {
|
|
38924
39026
|
const source = choice.source;
|
|
38925
|
-
|
|
38926
|
-
|
|
38927
|
-
|
|
38928
|
-
if (
|
|
38929
|
-
|
|
38930
|
-
|
|
38931
|
-
|
|
38932
|
-
|
|
38933
|
-
|
|
38934
|
-
|
|
38935
|
-
|
|
38936
|
-
|
|
38937
|
-
|
|
38938
|
-
|
|
38939
|
-
});
|
|
38940
|
-
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" }));
|
|
38941
39041
|
}
|
|
38942
|
-
if (!path.
|
|
39042
|
+
if (!path.isAbsolute(directory))
|
|
38943
39043
|
return yield* exports_Effect.fail(new AppError({ message: "Project directory must be an absolute path on this machine" }));
|
|
38944
|
-
const inspected = yield* exports_Effect.result(inspectProject(host, command,
|
|
39044
|
+
const inspected = yield* exports_Effect.result(inspectProject(host, command, directory));
|
|
38945
39045
|
if (exports_Result.isFailure(inspected)) {
|
|
38946
|
-
if (
|
|
38947
|
-
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);
|
|
38948
39048
|
return;
|
|
38949
39049
|
}
|
|
38950
39050
|
return yield* exports_Effect.fail(inspected.failure);
|
|
38951
39051
|
}
|
|
38952
|
-
if (
|
|
39052
|
+
if (sameHost && (inspected.success.project.vcs !== source.repository.vcs || inspected.success.project.commonDir !== source.repository.commonDir))
|
|
38953
39053
|
return yield* exports_Effect.fail(new AppError({ message: "Project directory changed; select the exact project directory again" }));
|
|
38954
39054
|
return inspected.success;
|
|
38955
39055
|
});
|
|
38956
39056
|
const useProject = (found) => {
|
|
38957
|
-
draft = changeProject(draft, found.project);
|
|
39057
|
+
draft = { ...changeProject(draft, found.project), worktreeRoot: found.worktreeRoot };
|
|
38958
39058
|
if (found.checkout.vcs === "jj" && !draft.sourcePath)
|
|
38959
39059
|
draft = { ...draft, sourcePath: found.checkout.path };
|
|
38960
39060
|
if (!draft.destination) {
|
|
@@ -38969,7 +39069,6 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38969
39069
|
draft = { machine, projectChoice: draft.projectChoice, mode: draft.mode };
|
|
38970
39070
|
sessions = [];
|
|
38971
39071
|
cloneRoot = "";
|
|
38972
|
-
cloneRoots = [];
|
|
38973
39072
|
error2 = undefined;
|
|
38974
39073
|
const discoveredContext = machine.local ? contextPath : undefined;
|
|
38975
39074
|
contextPath = undefined;
|
|
@@ -38989,7 +39088,6 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38989
39088
|
else
|
|
38990
39089
|
draft = { ...draft, host };
|
|
38991
39090
|
cloneRoot = found.cloneRoot;
|
|
38992
|
-
cloneRoots = found.roots;
|
|
38993
39091
|
projects = [
|
|
38994
39092
|
...projects.filter((item) => item.source?.machineKey !== machine.key || item.source.hostId !== host.hostId),
|
|
38995
39093
|
...found.projects.map((repo) => known(host, repo, found.checkout))
|
|
@@ -39021,6 +39119,10 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39021
39119
|
error2 = undefined;
|
|
39022
39120
|
});
|
|
39023
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);
|
|
39024
39126
|
const rows2 = [
|
|
39025
39127
|
{ id: "project", label: "Project", value: draft.projectChoice?.name ?? "Choose a project" },
|
|
39026
39128
|
{
|
|
@@ -39029,50 +39131,50 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39029
39131
|
value: draft.machine?.label ?? "Choose Rex host",
|
|
39030
39132
|
detail: draft.host ? `Host ID: ${draft.host.hostId}` : draft.machine?.selector
|
|
39031
39133
|
},
|
|
39032
|
-
{
|
|
39033
|
-
id: "destination",
|
|
39034
|
-
label: draft.clone ? "Clone to" : draft.project?.vcs === "jj" ? "Workspace" : "Checkout",
|
|
39035
|
-
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"),
|
|
39036
|
-
detail: draft.clone?.repo ?? draft.destination?.path,
|
|
39037
|
-
disabled: !draft.host || !(draft.project || draft.clone)
|
|
39038
|
-
},
|
|
39039
39134
|
{
|
|
39040
39135
|
id: "session",
|
|
39041
39136
|
label: "Session",
|
|
39042
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"),
|
|
39043
39138
|
detail: draft.session?.kind === "existing" ? draft.session.id : draft.session?.kind === "new" ? "Create on submit" : undefined,
|
|
39044
39139
|
disabled: !draft.host
|
|
39045
|
-
}
|
|
39046
|
-
|
|
39047
|
-
|
|
39048
|
-
|
|
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
|
+
{
|
|
39049
39149
|
id: "branch",
|
|
39050
|
-
label: "Start from",
|
|
39051
|
-
value: draft.destination?.revision ? draft.destination.label : draft.clone ? "Cloned default" : "Select or type
|
|
39052
|
-
|
|
39053
|
-
|
|
39054
|
-
|
|
39055
|
-
|
|
39056
|
-
|
|
39057
|
-
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
|
+
{
|
|
39058
39157
|
id: "checkoutName",
|
|
39059
|
-
label:
|
|
39060
|
-
value:
|
|
39061
|
-
|
|
39062
|
-
|
|
39063
|
-
|
|
39064
|
-
|
|
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
|
+
{
|
|
39065
39165
|
id: "mode",
|
|
39066
39166
|
label: "Mode",
|
|
39067
|
-
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,
|
|
39068
39169
|
disabled: !draft.host
|
|
39069
|
-
}
|
|
39170
|
+
}
|
|
39171
|
+
];
|
|
39070
39172
|
return {
|
|
39071
39173
|
rows: rows2.map((row) => ({ ...row, disabled: initializing || row.disabled })),
|
|
39072
|
-
submitLabel: draft.clone ? "Clone &
|
|
39174
|
+
submitLabel: draft.clone ? "Clone & open" : tree ? jj2 ? "Open workspace" : "Open worktree" : jj2 ? "Create workspace & open" : "Create worktree & open",
|
|
39073
39175
|
submitDisabled: initializing || blocked || !draft.host || !(cloneInputFor(draft) || inputFor(draft)),
|
|
39074
|
-
notice: draft.clone ? "Only pushed history transfers
|
|
39075
|
-
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)
|
|
39076
39178
|
};
|
|
39077
39179
|
};
|
|
39078
39180
|
const initialView = { ...formView(true), notice: "Discovering projects and Rex sessions\u2026" };
|
|
@@ -39094,7 +39196,8 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39094
39196
|
while (true) {
|
|
39095
39197
|
const view = formView();
|
|
39096
39198
|
activeView = view;
|
|
39097
|
-
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;
|
|
39098
39201
|
focused = action;
|
|
39099
39202
|
if (action === "cancel")
|
|
39100
39203
|
return;
|
|
@@ -39109,8 +39212,8 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39109
39212
|
continue;
|
|
39110
39213
|
}
|
|
39111
39214
|
const clonePlan = current2.success;
|
|
39112
|
-
if (clonePlan.repo !== cloneInput.repo || clonePlan.hostId !== draft.host.hostId) {
|
|
39113
|
-
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";
|
|
39114
39217
|
blocked = true;
|
|
39115
39218
|
continue;
|
|
39116
39219
|
}
|
|
@@ -39142,8 +39245,8 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39142
39245
|
continue;
|
|
39143
39246
|
}
|
|
39144
39247
|
const plan = current.success;
|
|
39145
|
-
if (plan.hostId !== draft.host.hostId || input.path && plan.path !== input.path) {
|
|
39146
|
-
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}`;
|
|
39147
39250
|
blocked = true;
|
|
39148
39251
|
continue;
|
|
39149
39252
|
}
|
|
@@ -39208,84 +39311,73 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39208
39311
|
} else if (action === "destination") {
|
|
39209
39312
|
if (!draft.host || !(draft.project || draft.clone))
|
|
39210
39313
|
return yield* exports_Effect.fail(new AppError({ message: "Select a project and machine before choosing a worktree" }));
|
|
39211
|
-
|
|
39212
|
-
|
|
39213
|
-
|
|
39214
|
-
|
|
39215
|
-
|
|
39216
|
-
|
|
39217
|
-
|
|
39218
|
-
|
|
39219
|
-
|
|
39220
|
-
|
|
39221
|
-
|
|
39222
|
-
|
|
39223
|
-
|
|
39224
|
-
|
|
39225
|
-
|
|
39226
|
-
return yield* exports_Effect.fail(new AppError({ message: "Clone destination must be an absolute path on this machine" }));
|
|
39227
|
-
draft = { ...draft, clone: { ...clone, repo } };
|
|
39228
|
-
} else {
|
|
39229
|
-
const found = yield* inspectWorktrees(draft.host, command, draft.project.vcs === "jj" ? draft.sourcePath ?? draft.project.path : draft.project.path);
|
|
39230
|
-
const trees = found.worktrees.filter((tree) => tree.vcs === "jj" || !tree.bare && !tree.prunable);
|
|
39231
|
-
const git2 = draft.project.vcs === "git";
|
|
39232
|
-
const picked = yield* inputChoice({
|
|
39233
|
-
message: git2 ? "Checkout (select exact worktree or branch, or type new branch)" : "Workspace (select existing, Clone this project, or type new workspace name)",
|
|
39234
|
-
choices: [
|
|
39235
|
-
...trees.map((tree) => ({
|
|
39236
|
-
value: tree,
|
|
39237
|
-
title: tree.vcs === "jj" ? tree.name : tree.path.split("/").filter(Boolean).at(-1) ?? tree.path,
|
|
39238
|
-
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}`
|
|
39239
|
-
})),
|
|
39240
|
-
...git2 ? found.branches.map((branch) => ({
|
|
39241
|
-
value: { kind: "branch", value: branch },
|
|
39242
|
-
title: `Branch: ${branch}`,
|
|
39243
|
-
description: trees.find((tree) => tree.vcs === "git" && tree.branch === branch)?.path ?? "Free branch \u2014 attach new checkout"
|
|
39244
|
-
})) : [],
|
|
39245
|
-
...draft.projectChoice?.source ? [{
|
|
39246
|
-
value: "clone",
|
|
39247
|
-
title: "Clone this project\u2026",
|
|
39248
|
-
description: clonePath(draft.projectChoice) ? `Propose ${clonePath(draft.projectChoice)} \xB7 only pushed history transfers` : "Choose an absolute clone destination \xB7 only pushed history transfers"
|
|
39249
|
-
}] : []
|
|
39250
|
-
]
|
|
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
|
|
39251
39329
|
});
|
|
39252
|
-
|
|
39253
|
-
|
|
39254
|
-
|
|
39255
|
-
|
|
39256
|
-
|
|
39257
|
-
|
|
39258
|
-
|
|
39259
|
-
|
|
39260
|
-
|
|
39261
|
-
|
|
39262
|
-
|
|
39263
|
-
|
|
39264
|
-
|
|
39265
|
-
|
|
39266
|
-
|
|
39267
|
-
|
|
39268
|
-
|
|
39269
|
-
|
|
39270
|
-
|
|
39271
|
-
|
|
39272
|
-
|
|
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);
|
|
39273
39363
|
} else if (action === "checkoutName") {
|
|
39364
|
+
const proposed = draft.clone && !draft.isCreating && draft.projectChoice ? clonePath(draft.projectChoice) : directoryFor({ ...draft, directory: undefined });
|
|
39274
39365
|
const picked = yield* inputChoice({
|
|
39275
|
-
message:
|
|
39276
|
-
choices: [
|
|
39277
|
-
{ value: null, title: "Use default", description: "No separate custom name" },
|
|
39278
|
-
...draft.worktreeName ? [{ value: draft.worktreeName, title: "Current custom name" }] : []
|
|
39279
|
-
]
|
|
39366
|
+
message: "Directory (absolute path on selected machine)",
|
|
39367
|
+
choices: proposed ? [{ value: proposed, title: "Use proposed directory", description: proposed }] : []
|
|
39280
39368
|
});
|
|
39281
|
-
|
|
39282
|
-
|
|
39283
|
-
|
|
39284
|
-
|
|
39285
|
-
|
|
39286
|
-
|
|
39287
|
-
|
|
39288
|
-
|
|
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
|
+
};
|
|
39289
39381
|
} else if (action === "branch") {
|
|
39290
39382
|
if (!draft.host || !(draft.project || draft.clone))
|
|
39291
39383
|
return yield* exports_Effect.fail(new AppError({ message: "Select a project and machine before choosing a base or branch" }));
|
|
@@ -39335,18 +39427,28 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39335
39427
|
if (jjClone)
|
|
39336
39428
|
draft = { ...draft, clone: { ...jjClone, revision: choice.revision } };
|
|
39337
39429
|
}
|
|
39338
|
-
} 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);
|
|
39339
39439
|
const picked = yield* inputChoice({
|
|
39340
|
-
message: "Branch (select
|
|
39341
|
-
choices:
|
|
39440
|
+
message: "Branch (select unused or type new name)",
|
|
39441
|
+
choices: (clone?.branches ?? found?.branches ?? []).filter((branch2) => !occupied.has(branch2)).map((branch2) => ({
|
|
39342
39442
|
value: branch2,
|
|
39343
39443
|
title: branch2,
|
|
39344
|
-
description: "
|
|
39444
|
+
description: clone ? "Published branch" : "Existing branch \xB7 new worktree"
|
|
39345
39445
|
}))
|
|
39346
39446
|
});
|
|
39347
39447
|
const branch = picked.kind === "selected" ? picked.value : picked.text.trim();
|
|
39348
39448
|
if (!branch || branch.startsWith("-") || /[\p{ASCII}&&\p{Cc}]/v.test(branch))
|
|
39349
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` }));
|
|
39350
39452
|
draft = { ...draft, destination: { branch, label: branch } };
|
|
39351
39453
|
}
|
|
39352
39454
|
} else if (action === "session") {
|
|
@@ -39379,7 +39481,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39379
39481
|
}
|
|
39380
39482
|
}
|
|
39381
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* () {
|
|
39382
|
-
const terminal = yield*
|
|
39484
|
+
const terminal = yield* exports_BunTerminal.make(({ key: key5 }) => key5.ctrl && (key5.name === "c" || key5.name === "d"));
|
|
39383
39485
|
const input = yield* terminal.readInput;
|
|
39384
39486
|
return { ...terminal, readInput: exports_Effect.succeed(input) };
|
|
39385
39487
|
})));
|