rex-worktrees 0.3.1 → 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.
@@ -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: 235ebfe826805f6c2bc6bce787c14f1dbed9d38d1d05c7d9e9401319719705fe
4
+ sha256: 9c94640c23e084e68e802c271ca0c4bb2bbd63a1a3c8a3ff888315ad31b06555
@@ -35486,27 +35486,35 @@ var connectMachine = exports_Effect.fnUntraced(function* (machine) {
35486
35486
  yield* exports_Schema.decodeUnknownEffect(RexHelperArgsSchema)(helper.args);
35487
35487
  return { ...current, hostId: identity3.host_id };
35488
35488
  });
35489
- var request3 = exports_Effect.fnUntraced(function* (host, command, body) {
35489
+ var connectedRequest = exports_Effect.fnUntraced(function* (host, command, body) {
35490
35490
  const encoded = { version: 4, hostId: host.hostId, ...body };
35491
- let response;
35492
- if (host.local) {
35493
- response = yield* dispatchHost(encoded, command);
35494
- } 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) {
35495
35498
  const current = yield* connectMachine(host);
35496
35499
  if (current.hostId !== host.hostId)
35497
35500
  return yield* fail20(`Rex host identity changed for ${host.label}; reconnect before continuing`);
35498
- const raw = yield* remoteRex(current.selector, ["do", "worktrees_request", "--args", JSON.stringify({ request: JSON.stringify(encoded) }), "--json"]);
35499
- response = yield* exports_Schema.decodeUnknownEffect(RexWorktreesResponseSchema)(raw);
35501
+ host = current;
35500
35502
  }
35501
- if (response.hostId !== host.hostId || response.version !== 4 || response.kind !== body.kind && !(body.kind === "project" && response.kind === "project-missing" && response.path === body.path))
35502
- return yield* fail20(`Unexpected Rex host/protocol response from ${host.label}; update rex-worktrees on that machine, run setup, and reload its Rex config`);
35503
- return response;
35503
+ return yield* connectedRequest(host, command, body);
35504
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 } : {} });
35505
35506
  var discover = exports_Effect.fnUntraced(function* (host, command, context3) {
35506
35507
  const result4 = yield* request3(host, command, { kind: "discover", ...host.local && context3 ? { context: context3 } : {} });
35507
35508
  if (result4.kind !== "discover")
35508
35509
  return yield* fail20("Unexpected discovery response");
35509
- 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) };
35510
35518
  });
35511
35519
  var inspectProject = exports_Effect.fnUntraced(function* (host, command, path) {
35512
35520
  const result4 = yield* request3(host, command, { kind: "project", path });
@@ -38620,7 +38628,6 @@ var inputFor = (draft) => {
38620
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;
38621
38629
  return draft.destination.branch ? { ...common, vcs: "git", branch: draft.destination.branch, ...draft.worktreeName ? { worktreeName: draft.worktreeName } : {} } : { ...common, vcs: "git", path: draft.destination.path };
38622
38630
  };
38623
- var changeMachine = (draft, machine) => draft.machine?.key === machine.key ? { ...draft, machine } : { machine, projectChoice: draft.projectChoice, mode: draft.mode };
38624
38631
  var changeProjectChoice = (draft, projectChoice) => ({
38625
38632
  ...draft,
38626
38633
  projectChoice,
@@ -38897,61 +38904,53 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
38897
38904
  return yield* exports_Effect.fail(new AppError({ message: "Project directory changed; select the exact project directory again" }));
38898
38905
  return inspected.success;
38899
38906
  });
38900
- const activate2 = exports_Effect.fnUntraced(function* (machine) {
38907
+ const activate2 = exports_Effect.fnUntraced(function* (machine, showLoading = false) {
38908
+ const previous = draft;
38901
38909
  const previousHostId = draft.host?.hostId;
38902
- 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;
38903
38917
  const discoveredContext = machine.local ? contextPath : undefined;
38904
38918
  contextPath = undefined;
38905
- 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));
38906
38925
  if (exports_Result.isFailure(connected)) {
38907
- draft = { machine, projectChoice: draft.projectChoice, mode: draft.mode };
38908
- sessions = [];
38909
- plan = undefined;
38910
- clonePlan = undefined;
38911
- cloneRoot = "";
38912
- cloneRoots = [];
38913
38926
  error2 = problem(connected.failure);
38914
38927
  return;
38915
38928
  }
38916
- if (previousHostId && previousHostId !== connected.success.hostId) {
38917
- draft = { machine, projectChoice: draft.projectChoice, mode: draft.mode };
38918
- sessions = [];
38919
- plan = undefined;
38920
- clonePlan = undefined;
38921
- }
38922
- draft = { ...draft, host: connected.success };
38923
- const discovered = yield* exports_Effect.result(discover(connected.success, command, discoveredContext));
38924
- if (exports_Result.isFailure(discovered)) {
38925
- draft = { machine, projectChoice: draft.projectChoice, mode: draft.mode };
38926
- sessions = [];
38927
- plan = undefined;
38928
- clonePlan = undefined;
38929
- cloneRoot = "";
38930
- cloneRoots = [];
38931
- error2 = problem(discovered.failure);
38932
- return;
38933
- }
38934
- 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 };
38935
38934
  cloneRoot = found.cloneRoot;
38936
38935
  cloneRoots = found.roots;
38937
38936
  projects = [
38938
- ...projects.filter((item) => item.source?.machineKey !== machine.key || item.source.hostId !== connected.success.hostId),
38939
- ...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))
38940
38939
  ];
38941
38940
  sessions = found.sessions;
38942
38941
  draft = {
38943
38942
  ...draft,
38944
- 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,
38945
38944
  clientId: focusClient(found.clients)
38946
38945
  };
38947
38946
  if (!draft.projectChoice && found.checkout && discoveredContext) {
38948
- 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));
38949
38948
  if (exports_Result.isFailure(inspected)) {
38950
38949
  error2 = problem(inspected.failure);
38951
38950
  return;
38952
38951
  }
38953
38952
  if (exports_Result.isSuccess(inspected)) {
38954
- draft = changeProjectChoice(draft, known(connected.success, inspected.success.project, inspected.success.checkout));
38953
+ draft = changeProjectChoice(draft, known(host, inspected.success.project, inspected.success.checkout));
38955
38954
  draft = changeProject(draft, inspected.success.project);
38956
38955
  if (inspected.success.checkout.vcs === "jj")
38957
38956
  draft = { ...draft, sourcePath: inspected.success.checkout.path };
@@ -38960,7 +38959,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
38960
38959
  draft = selectWorktree(draft, tree);
38961
38960
  }
38962
38961
  } else if (draft.projectChoice) {
38963
- 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));
38964
38963
  if (exports_Result.isFailure(inspected)) {
38965
38964
  if (!exports_Terminal.isQuitError(inspected.failure))
38966
38965
  error2 = problem(inspected.failure);
@@ -39153,7 +39152,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
39153
39152
  if (!machines.length)
39154
39153
  return yield* exports_Effect.fail(new AppError({ message: error2 ?? "No Rex machines available" }));
39155
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}`)));
39156
- yield* activate2(machine);
39155
+ yield* activate2(machine, true);
39157
39156
  } else if (action === "project") {
39158
39157
  const choices = projects.map((item) => ({
39159
39158
  value: item,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rex-worktrees",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Git worktrees and Jujutsu workspaces for Rex",
5
5
  "license": "MIT",
6
6
  "author": "Samuel Ho",