rex-worktrees 0.3.0 → 0.3.2

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 CHANGED
@@ -65,7 +65,7 @@ For a manual Lua installation, supply an absolute executable path with `require(
65
65
  The chooser is one flat form: **Project**, **Machine**, **Checkout** (or **Workspace**), **Session**, and **Mode** for an ordinary open. Only applicable fields appear; there is no Options menu. Machine is always explicit:
66
66
 
67
67
  - **Project:** select a known Git or JJ project, type a project name, or enter an absolute repository path. Linked checkouts appear under their canonical project. After an explicit project selection, the inspected checkout on the chosen machine is selected by default when available; a same-named directory on another host is never assumed to be that checkout.
68
- - **Machine:** select this machine or an existing Rex host. Changing machines keeps the logical project choice but clears host-bound checkout, base, clone destination, and session bindings; select or enter an actual project directory on the destination.
68
+ - **Machine:** select this machine or an existing Rex host. Changing machines keeps the logical project choice but clears host-bound checkout, base, clone destination, and session bindings; select or enter an actual project directory on the destination. The selected machine appears immediately with a disabled loading form while its connection and project choices are fetched; previous-machine checkout and session choices are not available during the wait.
69
69
  - **Checkout / Workspace:** Git offers exact existing checkout paths and branches together. Selecting a checkout opens that path; typing a branch name attaches a free branch or creates that branch and its checkout, while an occupied branch opens its existing checkout. Typed branch text is never a directory name. For a new Git branch, the form also shows **Directory**, an independent optional checkout directory name; select **Use default** to clear a custom name. JJ offers registered workspaces, including unavailable locations (visible but not openable), or a name for a new workspace. New JJ workspaces show **Start from**; an existing JJ workspace opens unchanged without it.
70
70
  - **Clone to:** when cloning a project, the form displays the literal absolute destination path; editing it changes only that destination. **Branch** (Git) or **Start from** (JJ) and an optional separate **Directory** (Git) or **Workspace** (JJ) name are visible on the same form. A Git clone without a default branch requires a branch choice. Select **Use default** to clear the optional checkout name; typing `none` is a literal name, not a clearing command. A project name unsafe as a directory requires an absolute destination. Destination collisions and writability errors appear on review without opening a task, and the destination remains editable.
71
71
  - **Session:** select an existing session by its exact ID, or type a name to create a new session on the selected machine. A typed name remains new even if an existing session has the same label; review shows **New: NAME** before confirmation. An empty session list still permits typing a name. Names must be nonblank, at most 128 characters, and contain no ASCII control characters.
@@ -94,7 +94,7 @@ Configuration is optional and belongs on the **execution machine** at `${XDG_CON
94
94
 
95
95
  `projects` explicitly registers paths; optional `roots` scans two directory levels for projects. Without either, the originating Rex pane's directory (or the CLI caller's directory) can suggest its Git or JJ project, but no parent directory is scanned. A local directory suggestion is not sent to another machine: paths typed in the form are interpreted on the selected destination. For a known project missing there, the proposed clone directory uses that machine's first configured root, otherwise the parent of its last successful clone, otherwise the one common parent of discovered projects, otherwise its home directory. This default never scans the home directory and can be changed in **Clone to**. A successful clone remembers its destination parent; editing or reviewing one does not. Git and JJ, not configuration, determine their existing checkouts and branches/revisions. Existing valid directories continue through ordinary open.
96
96
 
97
- For a popup launched from a Rex pane on this machine, the chooser checks that exact pane's reported directory (a local OSC 7 `file://` URI or absolute path). If Rex has not reported one, it uses the same pane's foreground process `cwd` when available. A remote pane or foreign URI is never treated as a local path. Context can legitimately be absent if the pane has no usable local directory, or the directory is not inside a Git or JJ repository; select or enter a project in that case. `--no-context` explicitly disables origin discovery.
97
+ For a popup launched from a Rex pane on this machine, the chooser checks that exact pane's reported directory (a local OSC 7 `file://` URI or absolute path). If that directory is absent or its URI is not trusted as local, it uses the same verified pane's foreground process `cwd` when available. A remote pane or foreign URI is never treated as a local path. Context can legitimately be absent if the pane has no usable local directory, or the directory is not inside a Git or JJ repository; select or enter a project in that case. `--no-context` explicitly disables origin discovery.
98
98
 
99
99
  New checkout location follows this order: a project's `worktreeRoot/<name>`, the global `worktreeRoot/<primary-project-name>/<name>`, or, by default, a sibling `<main-checkout>.worktrees/<name>`. `~` refers to the destination user's home; relative configuration paths resolve against the config file's directory. Checkout locations must be outside existing checkouts and version-control metadata. Collisions and escaping paths are rejected rather than renamed. JJ's own `git.colocate` setting governs whether its workspace also has Git metadata; the helper does not emulate colocation.
100
100
 
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/rex-worktrees
3
3
  size: 64491792 bytes
4
- sha256: d043082785f076f1f892aadd944d1c654cca875e242978532a633e67146221bf
4
+ sha256: 9c94640c23e084e68e802c271ca0c4bb2bbd63a1a3c8a3ff888315ad31b06555
@@ -34599,8 +34599,9 @@ var originDirectory = exports_Effect.fnUntraced(function* (sessionId, blockId) {
34599
34599
  return;
34600
34600
  const raw = yield* rex(["block", "call", "-s", sessionId, "-b", blockId, "pwd"]);
34601
34601
  const result4 = yield* parse3(RexDirectorySchema, raw);
34602
- if (result4.pwd)
34603
- return localDirectoryUri(result4.pwd);
34602
+ const directory = result4.pwd ? localDirectoryUri(result4.pwd) : undefined;
34603
+ if (directory !== undefined)
34604
+ return directory;
34604
34605
  const processInfo = yield* parse3(RexProcessSchema, yield* rex(["block", "call", "-s", sessionId, "-b", blockId, "process"]));
34605
34606
  const cwd = processInfo.foreground?.cwd;
34606
34607
  return cwd?.startsWith("/") && !cwd.includes("\x00") ? cwd : undefined;
@@ -35485,27 +35486,35 @@ var connectMachine = exports_Effect.fnUntraced(function* (machine) {
35485
35486
  yield* exports_Schema.decodeUnknownEffect(RexHelperArgsSchema)(helper.args);
35486
35487
  return { ...current, hostId: identity3.host_id };
35487
35488
  });
35488
- var request3 = exports_Effect.fnUntraced(function* (host, command, body) {
35489
+ var connectedRequest = exports_Effect.fnUntraced(function* (host, command, body) {
35489
35490
  const encoded = { version: 4, hostId: host.hostId, ...body };
35490
- let response;
35491
- if (host.local) {
35492
- response = yield* dispatchHost(encoded, command);
35493
- } else {
35491
+ const response = host.local ? yield* dispatchHost(encoded, command) : yield* exports_Schema.decodeUnknownEffect(RexWorktreesResponseSchema)(yield* remoteRex(host.selector, ["do", "worktrees_request", "--args", JSON.stringify({ request: JSON.stringify(encoded) }), "--json"]));
35492
+ if (response.hostId !== host.hostId || response.version !== 4 || response.kind !== body.kind && !(body.kind === "project" && response.kind === "project-missing" && response.path === body.path))
35493
+ return yield* fail20(`Unexpected Rex host/protocol response from ${host.label}; update rex-worktrees on that machine, run setup, and reload its Rex config`);
35494
+ return response;
35495
+ });
35496
+ var request3 = exports_Effect.fnUntraced(function* (host, command, body) {
35497
+ if (!host.local) {
35494
35498
  const current = yield* connectMachine(host);
35495
35499
  if (current.hostId !== host.hostId)
35496
35500
  return yield* fail20(`Rex host identity changed for ${host.label}; reconnect before continuing`);
35497
- const raw = yield* remoteRex(current.selector, ["do", "worktrees_request", "--args", JSON.stringify({ request: JSON.stringify(encoded) }), "--json"]);
35498
- response = yield* exports_Schema.decodeUnknownEffect(RexWorktreesResponseSchema)(raw);
35501
+ host = current;
35499
35502
  }
35500
- if (response.hostId !== host.hostId || response.version !== 4 || response.kind !== body.kind && !(body.kind === "project" && response.kind === "project-missing" && response.path === body.path))
35501
- return yield* fail20(`Unexpected Rex host/protocol response from ${host.label}; update rex-worktrees on that machine, run setup, and reload its Rex config`);
35502
- return response;
35503
+ return yield* connectedRequest(host, command, body);
35503
35504
  });
35505
+ var discovery = (result4) => ({ sessions: result4.sessions, clients: result4.clients, projects: result4.projects, roots: result4.roots ?? [], cloneRoot: result4.cloneRoot, ...result4.checkout ? { checkout: result4.checkout } : {} });
35504
35506
  var discover = exports_Effect.fnUntraced(function* (host, command, context3) {
35505
35507
  const result4 = yield* request3(host, command, { kind: "discover", ...host.local && context3 ? { context: context3 } : {} });
35506
35508
  if (result4.kind !== "discover")
35507
35509
  return yield* fail20("Unexpected discovery response");
35508
- return { sessions: result4.sessions, clients: result4.clients, projects: result4.projects, roots: result4.roots ?? [], cloneRoot: result4.cloneRoot, ...result4.checkout ? { checkout: result4.checkout } : {} };
35510
+ return discovery(result4);
35511
+ });
35512
+ var connectAndDiscover = exports_Effect.fnUntraced(function* (machine, command, context3) {
35513
+ const host = yield* connectMachine(machine);
35514
+ const result4 = yield* connectedRequest(host, command, { kind: "discover", ...host.local && context3 ? { context: context3 } : {} });
35515
+ if (result4.kind !== "discover")
35516
+ return yield* fail20("Unexpected discovery response");
35517
+ return { host, ...discovery(result4) };
35509
35518
  });
35510
35519
  var inspectProject = exports_Effect.fnUntraced(function* (host, command, path) {
35511
35520
  const result4 = yield* request3(host, command, { kind: "project", path });
@@ -38619,7 +38628,6 @@ var inputFor = (draft) => {
38619
38628
  return draft.destination.path ? { ...common, vcs: "jj", path: draft.destination.path } : draft.worktreeName && draft.destination.revision ? { ...common, vcs: "jj", worktreeName: draft.worktreeName, revision: draft.destination.revision } : undefined;
38620
38629
  return draft.destination.branch ? { ...common, vcs: "git", branch: draft.destination.branch, ...draft.worktreeName ? { worktreeName: draft.worktreeName } : {} } : { ...common, vcs: "git", path: draft.destination.path };
38621
38630
  };
38622
- var changeMachine = (draft, machine) => draft.machine?.key === machine.key ? { ...draft, machine } : { machine, projectChoice: draft.projectChoice, mode: draft.mode };
38623
38631
  var changeProjectChoice = (draft, projectChoice) => ({
38624
38632
  ...draft,
38625
38633
  projectChoice,
@@ -38896,61 +38904,53 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
38896
38904
  return yield* exports_Effect.fail(new AppError({ message: "Project directory changed; select the exact project directory again" }));
38897
38905
  return inspected.success;
38898
38906
  });
38899
- const activate2 = exports_Effect.fnUntraced(function* (machine) {
38907
+ const activate2 = exports_Effect.fnUntraced(function* (machine, showLoading = false) {
38908
+ const previous = draft;
38900
38909
  const previousHostId = draft.host?.hostId;
38901
- draft = changeMachine(draft, machine);
38910
+ draft = { machine, projectChoice: draft.projectChoice, mode: draft.mode };
38911
+ sessions = [];
38912
+ plan = undefined;
38913
+ clonePlan = undefined;
38914
+ cloneRoot = "";
38915
+ cloneRoots = [];
38916
+ error2 = undefined;
38902
38917
  const discoveredContext = machine.local ? contextPath : undefined;
38903
38918
  contextPath = undefined;
38904
- const connected = yield* exports_Effect.result(connectMachine(machine));
38919
+ if (showLoading) {
38920
+ const pending = { ...formView(true), notice: `Connecting to ${machine.label}\u2026` };
38921
+ activeView = pending;
38922
+ yield* terminal.display(`\x1B[H\x1B[2J${renderFormFrame(pending, "machine", false, yield* terminal.columns, yield* terminal.rows)}`);
38923
+ }
38924
+ const connected = yield* exports_Effect.result(connectAndDiscover(machine, command, discoveredContext));
38905
38925
  if (exports_Result.isFailure(connected)) {
38906
- draft = { machine, projectChoice: draft.projectChoice, mode: draft.mode };
38907
- sessions = [];
38908
- plan = undefined;
38909
- clonePlan = undefined;
38910
- cloneRoot = "";
38911
- cloneRoots = [];
38912
38926
  error2 = problem(connected.failure);
38913
38927
  return;
38914
38928
  }
38915
- if (previousHostId && previousHostId !== connected.success.hostId) {
38916
- draft = { machine, projectChoice: draft.projectChoice, mode: draft.mode };
38917
- sessions = [];
38918
- plan = undefined;
38919
- clonePlan = undefined;
38920
- }
38921
- draft = { ...draft, host: connected.success };
38922
- const discovered = yield* exports_Effect.result(discover(connected.success, command, discoveredContext));
38923
- if (exports_Result.isFailure(discovered)) {
38924
- draft = { machine, projectChoice: draft.projectChoice, mode: draft.mode };
38925
- sessions = [];
38926
- plan = undefined;
38927
- clonePlan = undefined;
38928
- cloneRoot = "";
38929
- cloneRoots = [];
38930
- error2 = problem(discovered.failure);
38931
- return;
38932
- }
38933
- const found = discovered.success;
38929
+ const { host, ...found } = connected.success;
38930
+ if (previous.machine?.key === machine.key && previousHostId === host.hostId)
38931
+ draft = { ...previous, machine, host };
38932
+ else
38933
+ draft = { ...draft, host };
38934
38934
  cloneRoot = found.cloneRoot;
38935
38935
  cloneRoots = found.roots;
38936
38936
  projects = [
38937
- ...projects.filter((item) => item.source?.machineKey !== machine.key || item.source.hostId !== connected.success.hostId),
38938
- ...found.projects.map((repo) => known(connected.success, repo, found.checkout))
38937
+ ...projects.filter((item) => item.source?.machineKey !== machine.key || item.source.hostId !== host.hostId),
38938
+ ...found.projects.map((repo) => known(host, repo, found.checkout))
38939
38939
  ];
38940
38940
  sessions = found.sessions;
38941
38941
  draft = {
38942
38942
  ...draft,
38943
- session: draft.session?.kind === "new" ? draft.session : sessions.some((item) => item.id === (draft.session?.kind === "existing" ? draft.session.id : undefined)) ? draft.session : connected.success.local && origin2.sessionId && sessions.some((item) => item.id === origin2.sessionId) ? { kind: "existing", id: origin2.sessionId } : sessions.length === 1 ? { kind: "existing", id: sessions[0].id } : undefined,
38943
+ session: draft.session?.kind === "new" ? draft.session : sessions.some((item) => item.id === (draft.session?.kind === "existing" ? draft.session.id : undefined)) ? draft.session : host.local && origin2.sessionId && sessions.some((item) => item.id === origin2.sessionId) ? { kind: "existing", id: origin2.sessionId } : sessions.length === 1 ? { kind: "existing", id: sessions[0].id } : undefined,
38944
38944
  clientId: focusClient(found.clients)
38945
38945
  };
38946
38946
  if (!draft.projectChoice && found.checkout && discoveredContext) {
38947
- const inspected = yield* exports_Effect.result(inspectProject(connected.success, command, found.checkout.path));
38947
+ const inspected = yield* exports_Effect.result(inspectProject(host, command, found.checkout.path));
38948
38948
  if (exports_Result.isFailure(inspected)) {
38949
38949
  error2 = problem(inspected.failure);
38950
38950
  return;
38951
38951
  }
38952
38952
  if (exports_Result.isSuccess(inspected)) {
38953
- draft = changeProjectChoice(draft, known(connected.success, inspected.success.project, inspected.success.checkout));
38953
+ draft = changeProjectChoice(draft, known(host, inspected.success.project, inspected.success.checkout));
38954
38954
  draft = changeProject(draft, inspected.success.project);
38955
38955
  if (inspected.success.checkout.vcs === "jj")
38956
38956
  draft = { ...draft, sourcePath: inspected.success.checkout.path };
@@ -38959,7 +38959,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
38959
38959
  draft = selectWorktree(draft, tree);
38960
38960
  }
38961
38961
  } else if (draft.projectChoice) {
38962
- const inspected = yield* exports_Effect.result(bindProject(draft.projectChoice, connected.success, found.projects));
38962
+ const inspected = yield* exports_Effect.result(bindProject(draft.projectChoice, host, found.projects));
38963
38963
  if (exports_Result.isFailure(inspected)) {
38964
38964
  if (!exports_Terminal.isQuitError(inspected.failure))
38965
38965
  error2 = problem(inspected.failure);
@@ -39152,7 +39152,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
39152
39152
  if (!machines.length)
39153
39153
  return yield* exports_Effect.fail(new AppError({ message: error2 ?? "No Rex machines available" }));
39154
39154
  const machine = yield* choose("Execution machine", machines.map((item) => selected(item, item.key === draft.machine?.key, item.label, item.local ? "This machine" : `Rex host \xB7 ${item.selector}`)));
39155
- yield* activate2(machine);
39155
+ yield* activate2(machine, true);
39156
39156
  } else if (action === "project") {
39157
39157
  const choices = projects.map((item) => ({
39158
39158
  value: item,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rex-worktrees",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Git worktrees and Jujutsu workspaces for Rex",
5
5
  "license": "MIT",
6
6
  "author": "Samuel Ho",