rex-worktrees 0.2.0 → 0.3.0
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 +12 -9
- package/dist/rex-worktrees +1 -1
- package/dist/rex-worktrees.js +364 -262
- package/package.json +1 -1
package/dist/rex-worktrees.js
CHANGED
|
@@ -33541,6 +33541,13 @@ var AssociationSchema = exports_Schema.Struct({
|
|
|
33541
33541
|
blockId: BlockIdSchema
|
|
33542
33542
|
});
|
|
33543
33543
|
var SessionTargetSchema = exports_Schema.Struct({ id: SessionIdSchema, label: exports_Schema.String });
|
|
33544
|
+
var SessionSelectionSchema = exports_Schema.Union([
|
|
33545
|
+
exports_Schema.Struct({ kind: exports_Schema.Literal("existing"), id: SessionIdSchema }),
|
|
33546
|
+
exports_Schema.Struct({
|
|
33547
|
+
kind: exports_Schema.Literal("new"),
|
|
33548
|
+
name: exports_Schema.String.pipe(exports_Schema.check(exports_Schema.isMaxLength(128), exports_Schema.isPattern(/^(?=.*\S)(?!.*[\p{ASCII}&&\p{Cc}]).*$/v)))
|
|
33549
|
+
})
|
|
33550
|
+
]);
|
|
33544
33551
|
var ClientTargetSchema = exports_Schema.Struct({ id: ClientIdSchema, label: exports_Schema.String });
|
|
33545
33552
|
var MachineSchema = exports_Schema.Struct({ key: exports_Schema.Union([exports_Schema.Literal("local"), RegisteredHostIdSchema]), label: exports_Schema.String, local: exports_Schema.Boolean, selector: exports_Schema.String });
|
|
33546
33553
|
var DestinationHostSchema = exports_Schema.Struct({ ...MachineSchema.fields, hostId: ServerHostIdSchema });
|
|
@@ -33563,7 +33570,7 @@ var GitCloneInputSchema = exports_Schema.Struct({
|
|
|
33563
33570
|
vcs: exports_Schema.Literal("git"),
|
|
33564
33571
|
source: GitCloneSourceSchema,
|
|
33565
33572
|
repo: exports_Schema.String,
|
|
33566
|
-
|
|
33573
|
+
session: SessionSelectionSchema,
|
|
33567
33574
|
clientId: exports_Schema.optional(ClientIdSchema),
|
|
33568
33575
|
name: exports_Schema.String,
|
|
33569
33576
|
branch: exports_Schema.String,
|
|
@@ -33574,7 +33581,7 @@ var JjCloneInputSchema = exports_Schema.Struct({
|
|
|
33574
33581
|
vcs: exports_Schema.Literal("jj"),
|
|
33575
33582
|
source: JjCloneSourceSchema,
|
|
33576
33583
|
repo: exports_Schema.String,
|
|
33577
|
-
|
|
33584
|
+
session: SessionSelectionSchema,
|
|
33578
33585
|
clientId: exports_Schema.optional(ClientIdSchema),
|
|
33579
33586
|
name: exports_Schema.String,
|
|
33580
33587
|
worktreeName: exports_Schema.optional(exports_Schema.String),
|
|
@@ -33583,7 +33590,6 @@ var JjCloneInputSchema = exports_Schema.Struct({
|
|
|
33583
33590
|
var CloneInputSchema = exports_Schema.Union([GitCloneInputSchema, JjCloneInputSchema]);
|
|
33584
33591
|
var ClonePlanFields = {
|
|
33585
33592
|
hostId: ServerHostIdSchema,
|
|
33586
|
-
sessionId: SessionIdSchema,
|
|
33587
33593
|
clientId: exports_Schema.optional(ClientIdSchema),
|
|
33588
33594
|
repo: exports_Schema.String,
|
|
33589
33595
|
existing: exports_Schema.Boolean,
|
|
@@ -33614,10 +33620,10 @@ var CloneLaunchResultSchema = exports_Schema.Struct({
|
|
|
33614
33620
|
pending: exports_Schema.Literal(true),
|
|
33615
33621
|
warning: exports_Schema.optional(exports_Schema.String)
|
|
33616
33622
|
});
|
|
33617
|
-
var CloneTaskRequestSchema = exports_Schema.Struct({ plan: ClonePlanSchema, rexBinDir: exports_Schema.optional(exports_Schema.String), rexLocalEndpoint: exports_Schema.optional(exports_Schema.String) });
|
|
33623
|
+
var CloneTaskRequestSchema = exports_Schema.Struct({ plan: ClonePlanSchema, sessionId: SessionIdSchema, rexBinDir: exports_Schema.optional(exports_Schema.String), rexLocalEndpoint: exports_Schema.optional(exports_Schema.String) });
|
|
33618
33624
|
var LaunchInputFields = {
|
|
33619
33625
|
repo: exports_Schema.String,
|
|
33620
|
-
|
|
33626
|
+
session: SessionSelectionSchema,
|
|
33621
33627
|
name: exports_Schema.String,
|
|
33622
33628
|
clientId: exports_Schema.optional(ClientIdSchema),
|
|
33623
33629
|
additional: exports_Schema.optional(exports_Schema.Boolean),
|
|
@@ -33640,7 +33646,6 @@ var JjLaunchInputSchema = exports_Schema.Struct({
|
|
|
33640
33646
|
var LaunchInputSchema = exports_Schema.Union([GitLaunchInputSchema, JjLaunchInputSchema]);
|
|
33641
33647
|
var LaunchPlanFields = {
|
|
33642
33648
|
hostId: ServerHostIdSchema,
|
|
33643
|
-
sessionId: SessionIdSchema,
|
|
33644
33649
|
clientId: exports_Schema.optional(ClientIdSchema),
|
|
33645
33650
|
path: exports_Schema.String,
|
|
33646
33651
|
worktreeRoot: exports_Schema.optional(exports_Schema.String),
|
|
@@ -33705,26 +33710,24 @@ var JjTaskRequestSchema = exports_Schema.Struct({
|
|
|
33705
33710
|
base: exports_Schema.optional(JjRevisionSchema)
|
|
33706
33711
|
});
|
|
33707
33712
|
var TaskRequestSchema = exports_Schema.Union([GitTaskRequestSchema, JjTaskRequestSchema]);
|
|
33708
|
-
var RequestIdentitySchema = exports_Schema.Struct({ version: exports_Schema.Literal(
|
|
33713
|
+
var RequestIdentitySchema = exports_Schema.Struct({ version: exports_Schema.Literal(4), hostId: ServerHostIdSchema });
|
|
33709
33714
|
var RequestSchema = exports_Schema.Union([
|
|
33710
33715
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("discover"), context: exports_Schema.optional(exports_Schema.String) }),
|
|
33711
33716
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("clone-source"), repo: exports_Schema.String }),
|
|
33712
33717
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("project"), path: exports_Schema.String }),
|
|
33713
33718
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("worktrees"), repo: exports_Schema.String }),
|
|
33714
33719
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("revision"), repo: exports_Schema.String, revision: exports_Schema.String }),
|
|
33715
|
-
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("branch"), repo: exports_Schema.String, branch: exports_Schema.String, worktreeName: exports_Schema.optional(exports_Schema.String) }),
|
|
33716
33720
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("plan"), input: LaunchInputSchema }),
|
|
33717
33721
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("clone-plan"), input: CloneInputSchema }),
|
|
33718
33722
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("clone-launch"), input: CloneInputSchema, reviewed: ClonePlanSchema }),
|
|
33719
33723
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("launch"), input: LaunchInputSchema, reviewed: LaunchPlanSchema })
|
|
33720
33724
|
]);
|
|
33721
33725
|
var ResponseSchema = exports_Schema.Union([
|
|
33722
|
-
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)), checkout: exports_Schema.optional(RepositorySchema) }),
|
|
33726
|
+
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) }),
|
|
33723
33727
|
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) }),
|
|
33724
33728
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("project-missing"), path: exports_Schema.String }),
|
|
33725
33729
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("clone-source"), source: CloneSourceSchema }),
|
|
33726
33730
|
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) }),
|
|
33727
|
-
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("branch"), path: exports_Schema.String, branch: exports_Schema.String, existing: exports_Schema.Boolean }),
|
|
33728
33731
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("revision"), revision: JjRevisionSchema }),
|
|
33729
33732
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("plan"), plan: LaunchPlanSchema }),
|
|
33730
33733
|
exports_Schema.Struct({ ...RequestIdentitySchema.fields, kind: exports_Schema.Literal("clone-plan"), plan: ClonePlanSchema }),
|
|
@@ -33737,25 +33740,33 @@ var PopupSizeSchema = exports_Schema.Struct({ columns: exports_Schema.Number, ro
|
|
|
33737
33740
|
var PopupBoundsSchema = exports_Schema.Tuple([exports_Schema.Number, exports_Schema.Number, exports_Schema.Number, exports_Schema.Number]);
|
|
33738
33741
|
var RexIdentitySchema = exports_Schema.Struct({ host_id: ServerHostIdSchema, endpoint: exports_Schema.String, principal: exports_Schema.Struct({ transport: exports_Schema.String }) });
|
|
33739
33742
|
var RexSessionsSchema = exports_Schema.Struct({ sessions: exports_Schema.Array(exports_Schema.Struct({ session_id: SessionIdSchema, label: exports_Schema.String })) });
|
|
33740
|
-
var
|
|
33741
|
-
|
|
33742
|
-
|
|
33743
|
-
|
|
33744
|
-
|
|
33745
|
-
|
|
33746
|
-
|
|
33747
|
-
|
|
33748
|
-
|
|
33749
|
-
|
|
33750
|
-
|
|
33751
|
-
|
|
33752
|
-
|
|
33753
|
-
layer_id: exports_Schema.NullOr(LayerIdSchema),
|
|
33754
|
-
kind: exports_Schema.String,
|
|
33755
|
-
bounds: exports_Schema.optional(exports_Schema.NullOr(PopupBoundsSchema)),
|
|
33756
|
-
blocks: exports_Schema.Array(exports_Schema.Struct({ block_id: BlockIdSchema, owner: exports_Schema.optional(exports_Schema.NullOr(ClientIdSchema)) }))
|
|
33743
|
+
var RexSessionCreatedSchema = exports_Schema.Struct({ session_id: SessionIdSchema });
|
|
33744
|
+
var RexClientsSchema = exports_Schema.Struct({
|
|
33745
|
+
clients: exports_Schema.Array(exports_Schema.Struct({
|
|
33746
|
+
client_id: ClientIdSchema,
|
|
33747
|
+
info: exports_Schema.optional(exports_Schema.Struct({ kind: exports_Schema.String, label: exports_Schema.optional(exports_Schema.String) })),
|
|
33748
|
+
connection_state: exports_Schema.optional(exports_Schema.String)
|
|
33749
|
+
}))
|
|
33750
|
+
});
|
|
33751
|
+
var RexWindowsSchema = exports_Schema.Struct({
|
|
33752
|
+
windows: exports_Schema.Array(exports_Schema.Struct({
|
|
33753
|
+
window_id: WindowIdSchema,
|
|
33754
|
+
label: exports_Schema.String,
|
|
33755
|
+
layers: exports_Schema.Array(exports_Schema.Struct({ blocks: exports_Schema.optional(exports_Schema.Array(exports_Schema.Struct({ block_id: BlockIdSchema, host_id: ServerHostIdSchema }))) }))
|
|
33757
33756
|
}))
|
|
33758
|
-
})
|
|
33757
|
+
});
|
|
33758
|
+
var RexViewSchema = exports_Schema.Struct({
|
|
33759
|
+
active_window_id: exports_Schema.NullOr(WindowIdSchema),
|
|
33760
|
+
windows: exports_Schema.Array(exports_Schema.Struct({
|
|
33761
|
+
window_id: WindowIdSchema,
|
|
33762
|
+
layers: exports_Schema.Array(exports_Schema.Struct({
|
|
33763
|
+
layer_id: exports_Schema.NullOr(LayerIdSchema),
|
|
33764
|
+
kind: exports_Schema.String,
|
|
33765
|
+
bounds: exports_Schema.optional(exports_Schema.NullOr(PopupBoundsSchema)),
|
|
33766
|
+
blocks: exports_Schema.Array(exports_Schema.Struct({ block_id: BlockIdSchema, owner: exports_Schema.optional(exports_Schema.NullOr(ClientIdSchema)) }))
|
|
33767
|
+
}))
|
|
33768
|
+
}))
|
|
33769
|
+
});
|
|
33759
33770
|
var RexResizedSchema = exports_Schema.Struct({ revision: exports_Schema.Number });
|
|
33760
33771
|
var RexTerminalSizeSchema = exports_Schema.Struct({ ...PopupSizeSchema.fields, owner: exports_Schema.NullOr(ClientIdSchema) });
|
|
33761
33772
|
var RexCreatedSchema = exports_Schema.Struct({ window_id: exports_Schema.optional(WindowIdSchema), block_ids: exports_Schema.Array(BlockIdSchema) });
|
|
@@ -34377,6 +34388,70 @@ var discoverProjects = exports_Effect.fnUntraced(function* (roots, explicitProje
|
|
|
34377
34388
|
return found;
|
|
34378
34389
|
});
|
|
34379
34390
|
|
|
34391
|
+
// src/state.ts
|
|
34392
|
+
import { randomUUID } from "crypto";
|
|
34393
|
+
import { homedir } from "os";
|
|
34394
|
+
var cloneRootFile = exports_Effect.fnUntraced(function* (stateRoot) {
|
|
34395
|
+
const path = yield* exports_Path.Path;
|
|
34396
|
+
const root = stateRoot ?? (process.env.XDG_STATE_HOME || path.join(homedir(), ".local", "state"));
|
|
34397
|
+
if (!path.isAbsolute(root))
|
|
34398
|
+
return yield* new AppError({ message: "State home must be absolute" });
|
|
34399
|
+
return path.join(root, "rex-worktrees", "clone-root.json");
|
|
34400
|
+
});
|
|
34401
|
+
var CloneRootSchema = exports_Schema.Struct({ cloneRoot: exports_Schema.String });
|
|
34402
|
+
var rememberedCloneRoot = exports_Effect.fnUntraced(function* (stateRoot) {
|
|
34403
|
+
const fs = yield* exports_FileSystem.FileSystem;
|
|
34404
|
+
const path = yield* exports_Path.Path;
|
|
34405
|
+
const filename = yield* cloneRootFile(stateRoot);
|
|
34406
|
+
const raw = yield* fs.readFileString(filename).pipe(exports_Effect.catchIf((error2) => exports_PlatformError.isPlatformError(error2) && error2.reason._tag === "NotFound", () => exports_Effect.succeed(undefined)));
|
|
34407
|
+
if (raw === undefined)
|
|
34408
|
+
return;
|
|
34409
|
+
const record2 = yield* exports_Schema.decodeUnknownEffect(exports_Schema.fromJsonString(CloneRootSchema))(raw).pipe(exports_Effect.catch(() => exports_Effect.succeed(undefined)));
|
|
34410
|
+
return record2 && path.isAbsolute(record2.cloneRoot) && path.resolve(record2.cloneRoot) === record2.cloneRoot ? record2.cloneRoot : undefined;
|
|
34411
|
+
});
|
|
34412
|
+
var rememberCloneRoot = exports_Effect.fnUntraced(function* (parent, stateRoot) {
|
|
34413
|
+
const fs = yield* exports_FileSystem.FileSystem;
|
|
34414
|
+
const path = yield* exports_Path.Path;
|
|
34415
|
+
if (!path.isAbsolute(parent) || path.resolve(parent) !== parent)
|
|
34416
|
+
return yield* new AppError({ message: "Clone parent must be normalized and absolute" });
|
|
34417
|
+
const filename = yield* cloneRootFile(stateRoot);
|
|
34418
|
+
yield* fs.makeDirectory(path.dirname(filename), { recursive: true, mode: 448 });
|
|
34419
|
+
const temporary = `${filename}.${randomUUID()}.tmp`;
|
|
34420
|
+
yield* fs.writeFileString(temporary, JSON.stringify({ cloneRoot: parent }), { flag: "wx", mode: 384 });
|
|
34421
|
+
yield* fs.rename(temporary, filename).pipe(exports_Effect.ensuring(fs.remove(temporary, { force: true }).pipe(exports_Effect.ignore)));
|
|
34422
|
+
});
|
|
34423
|
+
var saveAssociation = exports_Effect.fnUntraced(function* (association) {
|
|
34424
|
+
const fs = yield* exports_FileSystem.FileSystem;
|
|
34425
|
+
const path = yield* exports_Path.Path;
|
|
34426
|
+
const root = process.env.XDG_STATE_HOME || path.join(homedir(), ".local", "state");
|
|
34427
|
+
const directory = path.join(root, "rex-worktrees", "associations");
|
|
34428
|
+
yield* fs.makeDirectory(directory, { recursive: true, mode: 448 });
|
|
34429
|
+
const id2 = randomUUID();
|
|
34430
|
+
const temporary = path.join(directory, `${id2}.tmp`);
|
|
34431
|
+
const destination = path.join(directory, `${id2}.json`);
|
|
34432
|
+
yield* fs.writeFileString(temporary, JSON.stringify(association), { flag: "wx", mode: 384 });
|
|
34433
|
+
yield* fs.rename(temporary, destination).pipe(exports_Effect.ensuring(fs.remove(temporary, { force: true }).pipe(exports_Effect.ignore)));
|
|
34434
|
+
});
|
|
34435
|
+
var associations = exports_Effect.gen(function* () {
|
|
34436
|
+
const fs = yield* exports_FileSystem.FileSystem;
|
|
34437
|
+
const path = yield* exports_Path.Path;
|
|
34438
|
+
const directory = path.join(process.env.XDG_STATE_HOME || path.join(homedir(), ".local", "state"), "rex-worktrees", "associations");
|
|
34439
|
+
const result4 = [];
|
|
34440
|
+
if (!(yield* fs.exists(directory)))
|
|
34441
|
+
return result4;
|
|
34442
|
+
for (const name of yield* fs.readDirectory(directory)) {
|
|
34443
|
+
if (!name.endsWith(".json"))
|
|
34444
|
+
continue;
|
|
34445
|
+
const raw = yield* exports_Effect.catchIf(fs.readFileString(path.join(directory, name)), (error2) => exports_PlatformError.isPlatformError(error2) && error2.reason._tag === "NotFound", () => exports_Effect.succeed(undefined));
|
|
34446
|
+
if (raw === undefined)
|
|
34447
|
+
continue;
|
|
34448
|
+
const record2 = yield* exports_Schema.decodeUnknownEffect(exports_Schema.fromJsonString(AssociationSchema))(raw).pipe(exports_Effect.catch(() => exports_Effect.succeed(undefined)));
|
|
34449
|
+
if (record2)
|
|
34450
|
+
result4.push(record2);
|
|
34451
|
+
}
|
|
34452
|
+
return result4;
|
|
34453
|
+
});
|
|
34454
|
+
|
|
34380
34455
|
// src/config.ts
|
|
34381
34456
|
var loadConfig = exports_Effect.gen(function* () {
|
|
34382
34457
|
const fs = yield* exports_FileSystem.FileSystem;
|
|
@@ -34402,6 +34477,21 @@ var loadConfig = exports_Effect.gen(function* () {
|
|
|
34402
34477
|
};
|
|
34403
34478
|
return config;
|
|
34404
34479
|
});
|
|
34480
|
+
var resolveCloneRoot = exports_Effect.fnUntraced(function* (roots, projects, stateRoot) {
|
|
34481
|
+
const path = yield* exports_Path.Path;
|
|
34482
|
+
if (roots[0])
|
|
34483
|
+
return roots[0];
|
|
34484
|
+
const remembered = yield* rememberedCloneRoot(stateRoot);
|
|
34485
|
+
if (remembered)
|
|
34486
|
+
return remembered;
|
|
34487
|
+
const parents = new Set(projects.map((project4) => path.dirname(project4.path)));
|
|
34488
|
+
if (parents.size === 1)
|
|
34489
|
+
return [...parents][0];
|
|
34490
|
+
const home = process.env.HOME;
|
|
34491
|
+
if (!home || !path.isAbsolute(home))
|
|
34492
|
+
return yield* new AppError({ message: "Target HOME must be an absolute directory" });
|
|
34493
|
+
return home;
|
|
34494
|
+
});
|
|
34405
34495
|
var resolveWorktreeRoot = exports_Effect.fnUntraced(function* (repoPath) {
|
|
34406
34496
|
const config = yield* loadConfig;
|
|
34407
34497
|
const target = yield* project3(repoPath);
|
|
@@ -34490,6 +34580,10 @@ var listSessions = exports_Effect.gen(function* () {
|
|
|
34490
34580
|
const result4 = yield* parse3(RexSessionsSchema, yield* rex(["ls", "--json"]));
|
|
34491
34581
|
return result4.sessions.map((session) => ({ id: session.session_id, label: session.label }));
|
|
34492
34582
|
});
|
|
34583
|
+
var createSession = exports_Effect.fnUntraced(function* (name) {
|
|
34584
|
+
const result4 = yield* parse3(RexSessionCreatedSchema, yield* rex(["api", "call", "session.create", JSON.stringify({ label: name })]));
|
|
34585
|
+
return result4.session_id;
|
|
34586
|
+
});
|
|
34493
34587
|
var listClients = exports_Effect.gen(function* () {
|
|
34494
34588
|
const result4 = yield* parse3(RexClientsSchema, yield* rex(["client", "ls", "--json"]));
|
|
34495
34589
|
return result4.clients.filter((client) => client.info?.kind === "app" && client.connection_state === "connected").map((client) => ({ id: client.client_id, label: client.info?.label ?? client.client_id }));
|
|
@@ -34673,43 +34767,11 @@ var closeManagedPopup = exports_Effect.gen(function* () {
|
|
|
34673
34767
|
yield* localRex(["block", "close", "-s", sessionId, blockId]);
|
|
34674
34768
|
});
|
|
34675
34769
|
|
|
34676
|
-
// src/state.ts
|
|
34677
|
-
import { randomUUID } from "crypto";
|
|
34678
|
-
import { homedir } from "os";
|
|
34679
|
-
var saveAssociation = exports_Effect.fnUntraced(function* (association) {
|
|
34680
|
-
const fs = yield* exports_FileSystem.FileSystem;
|
|
34681
|
-
const path = yield* exports_Path.Path;
|
|
34682
|
-
const root = process.env.XDG_STATE_HOME || path.join(homedir(), ".local", "state");
|
|
34683
|
-
const directory = path.join(root, "rex-worktrees", "associations");
|
|
34684
|
-
yield* fs.makeDirectory(directory, { recursive: true, mode: 448 });
|
|
34685
|
-
const id2 = randomUUID();
|
|
34686
|
-
const temporary = path.join(directory, `${id2}.tmp`);
|
|
34687
|
-
const destination = path.join(directory, `${id2}.json`);
|
|
34688
|
-
yield* fs.writeFileString(temporary, JSON.stringify(association), { flag: "wx", mode: 384 });
|
|
34689
|
-
yield* fs.rename(temporary, destination).pipe(exports_Effect.ensuring(fs.remove(temporary, { force: true }).pipe(exports_Effect.ignore)));
|
|
34690
|
-
});
|
|
34691
|
-
var associations = exports_Effect.gen(function* () {
|
|
34692
|
-
const fs = yield* exports_FileSystem.FileSystem;
|
|
34693
|
-
const path = yield* exports_Path.Path;
|
|
34694
|
-
const directory = path.join(process.env.XDG_STATE_HOME || path.join(homedir(), ".local", "state"), "rex-worktrees", "associations");
|
|
34695
|
-
const result4 = [];
|
|
34696
|
-
if (!(yield* fs.exists(directory)))
|
|
34697
|
-
return result4;
|
|
34698
|
-
for (const name of yield* fs.readDirectory(directory)) {
|
|
34699
|
-
if (!name.endsWith(".json"))
|
|
34700
|
-
continue;
|
|
34701
|
-
const raw = yield* exports_Effect.catchIf(fs.readFileString(path.join(directory, name)), (error2) => exports_PlatformError.isPlatformError(error2) && error2.reason._tag === "NotFound", () => exports_Effect.succeed(undefined));
|
|
34702
|
-
if (raw === undefined)
|
|
34703
|
-
continue;
|
|
34704
|
-
const record2 = yield* exports_Schema.decodeUnknownEffect(exports_Schema.fromJsonString(AssociationSchema))(raw).pipe(exports_Effect.catch(() => exports_Effect.succeed(undefined)));
|
|
34705
|
-
if (record2)
|
|
34706
|
-
result4.push(record2);
|
|
34707
|
-
}
|
|
34708
|
-
return result4;
|
|
34709
|
-
});
|
|
34710
|
-
|
|
34711
34770
|
// src/worktrees.ts
|
|
34771
|
+
import { constants as constants2 } from "fs";
|
|
34772
|
+
import { access as access3 } from "fs/promises";
|
|
34712
34773
|
var fail19 = (message) => exports_Effect.fail(new AppError({ message }));
|
|
34774
|
+
var sameSession = (a, b) => a.kind === b.kind && (a.kind === "existing" && b.kind === "existing" ? a.id === b.id : a.kind === "new" && b.kind === "new" && a.name === b.name);
|
|
34713
34775
|
var canonical = exports_Effect.fnUntraced(function* (path) {
|
|
34714
34776
|
const fs = yield* exports_FileSystem.FileSystem;
|
|
34715
34777
|
return yield* fs.realPath(path);
|
|
@@ -34748,8 +34810,12 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34748
34810
|
const host = yield* localHost;
|
|
34749
34811
|
if (expectedHostId && host.id !== expectedHostId)
|
|
34750
34812
|
return yield* fail19(`Wrong Rex host: expected ${expectedHostId}, got ${host.id}`);
|
|
34751
|
-
|
|
34752
|
-
|
|
34813
|
+
yield* exports_Schema.decodeUnknownEffect(SessionSelectionSchema)(input.session);
|
|
34814
|
+
if (input.session.kind === "existing") {
|
|
34815
|
+
const sessionId = input.session.id;
|
|
34816
|
+
if (!(yield* listSessions).some((item) => item.id === sessionId))
|
|
34817
|
+
return yield* fail19(`Rex session ${sessionId} does not exist locally`);
|
|
34818
|
+
}
|
|
34753
34819
|
const clients = yield* listClients;
|
|
34754
34820
|
if (input.clientId && !clients.some((item) => item.id === input.clientId))
|
|
34755
34821
|
return yield* fail19(`Rex app client ${input.clientId} is not connected locally`);
|
|
@@ -34817,7 +34883,7 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34817
34883
|
warning = [warning, "Multiple Rex apps are connected; select the session in the intended app"].filter(Boolean).join("; ");
|
|
34818
34884
|
let target;
|
|
34819
34885
|
for (const entry of records) {
|
|
34820
|
-
if (entry.vcs !== repo.vcs || entry.hostId !== host.id || entry.commonDir !== repo.commonDir || entry.path !== path || entry.sessionId !== input.
|
|
34886
|
+
if (entry.vcs !== repo.vcs || entry.hostId !== host.id || entry.commonDir !== repo.commonDir || entry.path !== path || input.session.kind !== "existing" || entry.sessionId !== input.session.id)
|
|
34821
34887
|
continue;
|
|
34822
34888
|
const label = yield* liveBlock(entry.sessionId, entry.windowId, entry.blockId, host.id, path);
|
|
34823
34889
|
if (label !== false) {
|
|
@@ -34835,7 +34901,6 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34835
34901
|
detail = [detail, `Creating a JJ workspace snapshots ${repo.path}; its working-copy commit and colocated Git index intent-to-add entries may change.`].filter(Boolean).join(" ");
|
|
34836
34902
|
const common = {
|
|
34837
34903
|
hostId: host.id,
|
|
34838
|
-
sessionId: input.sessionId,
|
|
34839
34904
|
...clientId ? { clientId } : {},
|
|
34840
34905
|
path,
|
|
34841
34906
|
...worktreeRoot ? { worktreeRoot } : {},
|
|
@@ -34866,7 +34931,7 @@ var planLaunch = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
34866
34931
|
label: action === "focus" ? "Focus existing tab" : checkout === "create" ? "Create workspace & open" : action === "split" ? "Open pane" : "Open tab"
|
|
34867
34932
|
};
|
|
34868
34933
|
});
|
|
34869
|
-
var sameLaunchPlan = (a, b) => a.vcs === b.vcs && a.input.vcs === b.input.vcs && a.hostId === b.hostId && a.worktreeRoot === b.worktreeRoot && a.
|
|
34934
|
+
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);
|
|
34870
34935
|
var launch = exports_Effect.fnUntraced(function* (input, command, reviewed, expectedHostId) {
|
|
34871
34936
|
const pathService = yield* exports_Path.Path;
|
|
34872
34937
|
if (!command[0] || !pathService.isAbsolute(command[0]))
|
|
@@ -34876,12 +34941,13 @@ var launch = exports_Effect.fnUntraced(function* (input, command, reviewed, expe
|
|
|
34876
34941
|
return yield* fail19("Launch plan changed since review; inspect the destination before submitting again");
|
|
34877
34942
|
if (plan.action === "focus") {
|
|
34878
34943
|
const target2 = plan.target;
|
|
34879
|
-
if (!target2)
|
|
34944
|
+
if (!target2 || plan.input.session.kind !== "existing")
|
|
34880
34945
|
return yield* fail19("The reviewed focus target is no longer available");
|
|
34881
|
-
const
|
|
34946
|
+
const sessionId2 = plan.input.session.id;
|
|
34947
|
+
const warning2 = [plan.warning, yield* focus(sessionId2, target2.windowId, plan.clientId, target2.blockId)].filter(Boolean).join("; ") || undefined;
|
|
34882
34948
|
const result5 = {
|
|
34883
34949
|
hostId: plan.hostId,
|
|
34884
|
-
sessionId:
|
|
34950
|
+
sessionId: sessionId2,
|
|
34885
34951
|
windowId: target2.windowId,
|
|
34886
34952
|
blockId: target2.blockId,
|
|
34887
34953
|
path: plan.path,
|
|
@@ -34894,11 +34960,12 @@ var launch = exports_Effect.fnUntraced(function* (input, command, reviewed, expe
|
|
|
34894
34960
|
const repo = yield* repository3(plan.input.repo);
|
|
34895
34961
|
if (repo.vcs !== plan.vcs)
|
|
34896
34962
|
return yield* fail19("Repository backend changed since review");
|
|
34963
|
+
const sessionId = plan.input.session.kind === "existing" ? plan.input.session.id : yield* createSession(plan.input.session.name);
|
|
34897
34964
|
const common = {
|
|
34898
34965
|
repo: repo.path,
|
|
34899
34966
|
path: plan.path,
|
|
34900
34967
|
commonDir: repo.commonDir,
|
|
34901
|
-
sessionId
|
|
34968
|
+
sessionId,
|
|
34902
34969
|
hostId: plan.hostId,
|
|
34903
34970
|
...process.env.REX_BIN_DIR ? { rexBinDir: process.env.REX_BIN_DIR } : {},
|
|
34904
34971
|
...process.env.REX_WORKTREES_LOCAL_ENDPOINT ? { rexLocalEndpoint: process.env.REX_WORKTREES_LOCAL_ENDPOINT } : {},
|
|
@@ -34923,11 +34990,11 @@ var launch = exports_Effect.fnUntraced(function* (input, command, reviewed, expe
|
|
|
34923
34990
|
const name = plan.name;
|
|
34924
34991
|
if (!name)
|
|
34925
34992
|
return yield* fail19("The reviewed Rex tab name is no longer available");
|
|
34926
|
-
const created = plan.action === "split" ? target ? yield* createSplit(
|
|
34927
|
-
const warning = [plan.warning, yield* focus(
|
|
34993
|
+
const created = plan.action === "split" ? target ? yield* createSplit(sessionId, target.windowId, target.blockId, name, plan.path, argv) : yield* fail19("The reviewed split target is no longer available") : yield* createTab(sessionId, name, plan.checkout === "existing" ? plan.path : repo.path, argv);
|
|
34994
|
+
const warning = [plan.warning, yield* focus(sessionId, created.windowId, plan.clientId, created.blockId)].filter(Boolean).join("; ") || undefined;
|
|
34928
34995
|
const result4 = {
|
|
34929
34996
|
hostId: plan.hostId,
|
|
34930
|
-
sessionId
|
|
34997
|
+
sessionId,
|
|
34931
34998
|
windowId: created.windowId,
|
|
34932
34999
|
blockId: created.blockId,
|
|
34933
35000
|
path: plan.path,
|
|
@@ -35064,14 +35131,29 @@ var cloneDestination = exports_Effect.fnUntraced(function* (destination, url, vc
|
|
|
35064
35131
|
}
|
|
35065
35132
|
return;
|
|
35066
35133
|
});
|
|
35134
|
+
var checkCloneParent = exports_Effect.fnUntraced(function* (destination) {
|
|
35135
|
+
const fs = yield* exports_FileSystem.FileSystem;
|
|
35136
|
+
const path = yield* exports_Path.Path;
|
|
35137
|
+
let ancestor = path.dirname(destination);
|
|
35138
|
+
while (!(yield* fs.lstat(ancestor).pipe(exports_Effect.map(() => true), exports_Effect.catchIf(missing3, () => exports_Effect.succeed(false)))))
|
|
35139
|
+
ancestor = path.dirname(ancestor);
|
|
35140
|
+
yield* exports_Effect.tryPromise({
|
|
35141
|
+
try: () => access3(ancestor, constants2.W_OK | constants2.X_OK),
|
|
35142
|
+
catch: (cause) => new AppError({ message: `Cannot create clone destination ${destination}: ${ancestor} is not writable; choose another destination or fix its permissions`, cause })
|
|
35143
|
+
});
|
|
35144
|
+
});
|
|
35067
35145
|
var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
35068
35146
|
const host = yield* localHost;
|
|
35069
35147
|
if (expectedHostId && host.id !== expectedHostId)
|
|
35070
35148
|
return yield* fail19("Wrong Rex clone host");
|
|
35071
35149
|
if (input.vcs !== input.source.vcs)
|
|
35072
35150
|
return yield* fail19("Clone source backend does not match request");
|
|
35073
|
-
|
|
35074
|
-
|
|
35151
|
+
yield* exports_Schema.decodeUnknownEffect(SessionSelectionSchema)(input.session);
|
|
35152
|
+
if (input.session.kind === "existing") {
|
|
35153
|
+
const sessionId = input.session.id;
|
|
35154
|
+
if (!(yield* listSessions).some((item) => item.id === sessionId))
|
|
35155
|
+
return yield* fail19("Requested Rex session does not exist");
|
|
35156
|
+
}
|
|
35075
35157
|
const clients = yield* listClients;
|
|
35076
35158
|
if (input.clientId && !clients.some((item) => item.id === input.clientId))
|
|
35077
35159
|
return yield* fail19("Requested Rex app client is not connected");
|
|
@@ -35086,6 +35168,8 @@ var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
35086
35168
|
catch: () => new AppError({ message: "Clone source URL is unsafe or local to another Rex host" })
|
|
35087
35169
|
});
|
|
35088
35170
|
const commonDir = yield* cloneDestination(input.repo, url, input.vcs, host.id);
|
|
35171
|
+
if (commonDir === undefined)
|
|
35172
|
+
yield* checkCloneParent(input.repo);
|
|
35089
35173
|
const existing = commonDir !== undefined;
|
|
35090
35174
|
let gitBase;
|
|
35091
35175
|
let base;
|
|
@@ -35110,7 +35194,6 @@ var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
35110
35194
|
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;
|
|
35111
35195
|
const common = {
|
|
35112
35196
|
hostId: host.id,
|
|
35113
|
-
sessionId: input.sessionId,
|
|
35114
35197
|
...clientId ? { clientId } : {},
|
|
35115
35198
|
repo: input.repo,
|
|
35116
35199
|
existing,
|
|
@@ -35133,7 +35216,7 @@ var planClone = exports_Effect.fnUntraced(function* (input, expectedHostId) {
|
|
|
35133
35216
|
...base ? { base } : {}
|
|
35134
35217
|
};
|
|
35135
35218
|
});
|
|
35136
|
-
var sameClonePlan = (a, b) => a.vcs === b.vcs && a.input.vcs === b.input.vcs && a.hostId === b.hostId && a.
|
|
35219
|
+
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));
|
|
35137
35220
|
var launchClone = exports_Effect.fnUntraced(function* (input, command, reviewed, expectedHostId) {
|
|
35138
35221
|
const path = yield* exports_Path.Path;
|
|
35139
35222
|
if (!command[0] || !path.isAbsolute(command[0]))
|
|
@@ -35141,17 +35224,18 @@ var launchClone = exports_Effect.fnUntraced(function* (input, command, reviewed,
|
|
|
35141
35224
|
const plan = yield* planClone(input, expectedHostId);
|
|
35142
35225
|
if (reviewed && !sameClonePlan(reviewed, plan))
|
|
35143
35226
|
return yield* fail19("Clone plan changed since review; inspect before submitting again");
|
|
35227
|
+
const home = process.env.HOME;
|
|
35228
|
+
if (!home || !path.isAbsolute(home))
|
|
35229
|
+
return yield* fail19("Target HOME must be an absolute directory");
|
|
35144
35230
|
const request3 = {
|
|
35145
35231
|
plan,
|
|
35232
|
+
sessionId: plan.input.session.kind === "existing" ? plan.input.session.id : yield* createSession(plan.input.session.name),
|
|
35146
35233
|
...process.env.REX_BIN_DIR ? { rexBinDir: process.env.REX_BIN_DIR } : {},
|
|
35147
35234
|
...process.env.REX_WORKTREES_LOCAL_ENDPOINT ? { rexLocalEndpoint: process.env.REX_WORKTREES_LOCAL_ENDPOINT } : {}
|
|
35148
35235
|
};
|
|
35149
|
-
const
|
|
35150
|
-
|
|
35151
|
-
|
|
35152
|
-
const created = yield* createTab(plan.sessionId, input.name, home, [...command, "clone-task", JSON.stringify(request3)]);
|
|
35153
|
-
const warning = [plan.warning, yield* focus(plan.sessionId, created.windowId, plan.clientId, created.blockId)].filter(Boolean).join("; ") || undefined;
|
|
35154
|
-
const result4 = { hostId: plan.hostId, sessionId: plan.sessionId, windowId: created.windowId, blockId: created.blockId, repo: plan.repo, pending: true, ...warning ? { warning } : {} };
|
|
35236
|
+
const created = yield* createTab(request3.sessionId, input.name, home, [...command, "clone-task", JSON.stringify(request3)]);
|
|
35237
|
+
const warning = [plan.warning, yield* focus(request3.sessionId, created.windowId, plan.clientId, created.blockId)].filter(Boolean).join("; ") || undefined;
|
|
35238
|
+
const result4 = { hostId: plan.hostId, sessionId: request3.sessionId, windowId: created.windowId, blockId: created.blockId, repo: plan.repo, pending: true, ...warning ? { warning } : {} };
|
|
35155
35239
|
return result4;
|
|
35156
35240
|
});
|
|
35157
35241
|
var prepareCloneCheckout = exports_Effect.fnUntraced(function* (plan) {
|
|
@@ -35251,16 +35335,19 @@ var cloneTask = exports_Effect.fnUntraced(function* (request3) {
|
|
|
35251
35335
|
if (request3.rexLocalEndpoint)
|
|
35252
35336
|
process.env.REX_WORKTREES_LOCAL_ENDPOINT = request3.rexLocalEndpoint;
|
|
35253
35337
|
const { plan } = request3;
|
|
35254
|
-
if (process.env.REX_SESSION !==
|
|
35338
|
+
if (process.env.REX_SESSION !== request3.sessionId || !process.env.REX_BLOCK)
|
|
35255
35339
|
return yield* fail19("Clone task must run in its requested Rex terminal");
|
|
35256
35340
|
const blockId = yield* exports_Schema.decodeUnknownEffect(BlockIdSchema)(process.env.REX_BLOCK);
|
|
35341
|
+
if (!(yield* listSessions).some((item) => item.id === request3.sessionId))
|
|
35342
|
+
return yield* fail19("Requested Rex session no longer exists");
|
|
35257
35343
|
if (!sameClonePlan(plan, yield* planClone(plan.input, plan.hostId)))
|
|
35258
35344
|
return yield* fail19("Clone target changed since launch; destination left untouched");
|
|
35259
35345
|
const { repo, cwd } = yield* prepareCloneCheckout(plan);
|
|
35260
|
-
|
|
35346
|
+
yield* rememberCloneRoot((yield* exports_Path.Path).dirname(repo.path)).pipe(exports_Effect.catch((error2) => exports_Effect.sync(() => console.error(`Checkout ${cwd} is available; clone parent not remembered: ${exports_Cause.pretty(exports_Cause.fail(error2))}`))));
|
|
35347
|
+
const windows = yield* windowList(request3.sessionId).pipe(exports_Effect.catch(() => exports_Effect.succeed([])));
|
|
35261
35348
|
const window = windows.find((entry) => entry.layers.some((layer12) => layer12.blocks?.some((block) => block.block_id === blockId && block.host_id === plan.hostId)));
|
|
35262
35349
|
if (window)
|
|
35263
|
-
yield* saveAssociation({ vcs: repo.vcs, hostId: plan.hostId, commonDir: repo.commonDir, path: cwd, sessionId:
|
|
35350
|
+
yield* saveAssociation({ vcs: repo.vcs, hostId: plan.hostId, commonDir: repo.commonDir, path: cwd, sessionId: request3.sessionId, windowId: window.window_id, blockId }).pipe(exports_Effect.catch((error2) => exports_Effect.sync(() => console.error(`Checkout ${cwd} is available; association not saved: ${exports_Cause.pretty(exports_Cause.fail(error2))}`))));
|
|
35264
35351
|
else
|
|
35265
35352
|
console.error(`Checkout ${cwd} is available; Rex block could not be associated`);
|
|
35266
35353
|
yield* shell(cwd);
|
|
@@ -35275,7 +35362,7 @@ var dispatchHost = exports_Effect.fnUntraced(function* (request3, command) {
|
|
|
35275
35362
|
const paths = request3.kind === "discover" ? request3.context ? [request3.context] : [] : request3.kind === "project" ? [request3.path] : request3.kind === "clone-plan" || request3.kind === "clone-launch" ? [request3.input.repo] : request3.kind === "plan" || request3.kind === "launch" ? [request3.input.repo, ...request3.input.path ? [request3.input.path] : []] : [request3.repo];
|
|
35276
35363
|
if (paths.some((value3) => !path.isAbsolute(value3)))
|
|
35277
35364
|
return yield* exports_Effect.fail(new AppError({ message: "Destination repository and worktree paths must be absolute" }));
|
|
35278
|
-
const identity3 = { version:
|
|
35365
|
+
const identity3 = { version: 4, hostId: host.id };
|
|
35279
35366
|
let result4;
|
|
35280
35367
|
switch (request3.kind) {
|
|
35281
35368
|
case "discover": {
|
|
@@ -35287,7 +35374,16 @@ var dispatchHost = exports_Effect.fnUntraced(function* (request3, command) {
|
|
|
35287
35374
|
clients: listClients,
|
|
35288
35375
|
projects: discoverProjects(config.roots, config.projects, request3.context)
|
|
35289
35376
|
}, { concurrency: 4 });
|
|
35290
|
-
result4 = {
|
|
35377
|
+
result4 = {
|
|
35378
|
+
...identity3,
|
|
35379
|
+
kind: "discover",
|
|
35380
|
+
sessions,
|
|
35381
|
+
clients,
|
|
35382
|
+
projects,
|
|
35383
|
+
roots: config.roots,
|
|
35384
|
+
cloneRoot: yield* resolveCloneRoot(config.roots, projects),
|
|
35385
|
+
...checkout ? { checkout } : {}
|
|
35386
|
+
};
|
|
35291
35387
|
break;
|
|
35292
35388
|
}
|
|
35293
35389
|
case "project": {
|
|
@@ -35312,7 +35408,11 @@ var dispatchHost = exports_Effect.fnUntraced(function* (request3, command) {
|
|
|
35312
35408
|
}
|
|
35313
35409
|
case "clone-source": {
|
|
35314
35410
|
const repo = yield* repository3(request3.repo);
|
|
35315
|
-
result4 = {
|
|
35411
|
+
result4 = {
|
|
35412
|
+
...identity3,
|
|
35413
|
+
kind: "clone-source",
|
|
35414
|
+
source: repo.vcs === "git" ? yield* cloneSource(repo.path, host.id) : yield* cloneSource2(repo.path, host.id)
|
|
35415
|
+
};
|
|
35316
35416
|
break;
|
|
35317
35417
|
}
|
|
35318
35418
|
case "worktrees": {
|
|
@@ -35334,14 +35434,6 @@ var dispatchHost = exports_Effect.fnUntraced(function* (request3, command) {
|
|
|
35334
35434
|
result4 = { ...identity3, kind: "revision", revision: yield* resolveRevision(repo.path, request3.revision) };
|
|
35335
35435
|
break;
|
|
35336
35436
|
}
|
|
35337
|
-
case "branch": {
|
|
35338
|
-
const repo = yield* repository3(request3.repo);
|
|
35339
|
-
if (repo.vcs !== "git")
|
|
35340
|
-
return yield* exports_Effect.fail(new AppError({ message: "Branch checkout requires a Git repository" }));
|
|
35341
|
-
const planned = yield* planWorktree(repo.path, request3.branch, yield* resolveWorktreeRoot(repo.path), request3.worktreeName);
|
|
35342
|
-
result4 = { ...identity3, kind: "branch", path: planned.path, branch: planned.branch, existing: planned.existing };
|
|
35343
|
-
break;
|
|
35344
|
-
}
|
|
35345
35437
|
case "plan":
|
|
35346
35438
|
result4 = { ...identity3, kind: "plan", plan: yield* planLaunch(request3.input, host.id) };
|
|
35347
35439
|
break;
|
|
@@ -35394,7 +35486,7 @@ var connectMachine = exports_Effect.fnUntraced(function* (machine) {
|
|
|
35394
35486
|
return { ...current, hostId: identity3.host_id };
|
|
35395
35487
|
});
|
|
35396
35488
|
var request3 = exports_Effect.fnUntraced(function* (host, command, body) {
|
|
35397
|
-
const encoded = { version:
|
|
35489
|
+
const encoded = { version: 4, hostId: host.hostId, ...body };
|
|
35398
35490
|
let response;
|
|
35399
35491
|
if (host.local) {
|
|
35400
35492
|
response = yield* dispatchHost(encoded, command);
|
|
@@ -35405,7 +35497,7 @@ var request3 = exports_Effect.fnUntraced(function* (host, command, body) {
|
|
|
35405
35497
|
const raw = yield* remoteRex(current.selector, ["do", "worktrees_request", "--args", JSON.stringify({ request: JSON.stringify(encoded) }), "--json"]);
|
|
35406
35498
|
response = yield* exports_Schema.decodeUnknownEffect(RexWorktreesResponseSchema)(raw);
|
|
35407
35499
|
}
|
|
35408
|
-
if (response.hostId !== host.hostId || response.version !==
|
|
35500
|
+
if (response.hostId !== host.hostId || response.version !== 4 || response.kind !== body.kind && !(body.kind === "project" && response.kind === "project-missing" && response.path === body.path))
|
|
35409
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`);
|
|
35410
35502
|
return response;
|
|
35411
35503
|
});
|
|
@@ -35413,7 +35505,7 @@ var discover = exports_Effect.fnUntraced(function* (host, command, context3) {
|
|
|
35413
35505
|
const result4 = yield* request3(host, command, { kind: "discover", ...host.local && context3 ? { context: context3 } : {} });
|
|
35414
35506
|
if (result4.kind !== "discover")
|
|
35415
35507
|
return yield* fail20("Unexpected discovery response");
|
|
35416
|
-
return { sessions: result4.sessions, clients: result4.clients, projects: result4.projects, roots: result4.roots ?? [], ...result4.checkout ? { checkout: result4.checkout } : {} };
|
|
35508
|
+
return { sessions: result4.sessions, clients: result4.clients, projects: result4.projects, roots: result4.roots ?? [], cloneRoot: result4.cloneRoot, ...result4.checkout ? { checkout: result4.checkout } : {} };
|
|
35417
35509
|
});
|
|
35418
35510
|
var inspectProject = exports_Effect.fnUntraced(function* (host, command, path) {
|
|
35419
35511
|
const result4 = yield* request3(host, command, { kind: "project", path });
|
|
@@ -35435,12 +35527,6 @@ var inspectRevision = exports_Effect.fnUntraced(function* (host, command, repo,
|
|
|
35435
35527
|
return yield* fail20("Unexpected revision response");
|
|
35436
35528
|
return result4.revision;
|
|
35437
35529
|
});
|
|
35438
|
-
var inspectBranch = exports_Effect.fnUntraced(function* (host, command, repo, branch, worktreeName) {
|
|
35439
|
-
const result4 = yield* request3(host, command, { kind: "branch", repo, branch, ...worktreeName !== undefined ? { worktreeName } : {} });
|
|
35440
|
-
if (result4.kind !== "branch")
|
|
35441
|
-
return yield* fail20("Unexpected branch response");
|
|
35442
|
-
return { path: result4.path, branch: result4.branch, existing: result4.existing };
|
|
35443
|
-
});
|
|
35444
35530
|
var review = exports_Effect.fnUntraced(function* (host, command, input) {
|
|
35445
35531
|
const result4 = yield* request3(host, command, { kind: "plan", input });
|
|
35446
35532
|
if (result4.kind !== "plan")
|
|
@@ -38377,7 +38463,7 @@ var renderFormFrame = (view, focused, editing, columns, rows2, colors2 = !proces
|
|
|
38377
38463
|
const heading = `${color("REX", "cyan", colors2)} ${color("/ WORKTREES", "bold", colors2)}`;
|
|
38378
38464
|
add4(heading);
|
|
38379
38465
|
screen.push(line("\u251C", "\u2524"));
|
|
38380
|
-
const budget = Math.max(0, rows2 - (editing ? rows2 >= 20 ?
|
|
38466
|
+
const budget = Math.max(0, rows2 - (editing ? rows2 >= 20 ? 10 : 8 : 7));
|
|
38381
38467
|
const body = [];
|
|
38382
38468
|
const addBody = (text) => body.push(border(fit(text, inside)));
|
|
38383
38469
|
const addWrapped = (text, tone, limit = budget) => {
|
|
@@ -38395,7 +38481,7 @@ var renderFormFrame = (view, focused, editing, columns, rows2, colors2 = !proces
|
|
|
38395
38481
|
const room = Math.max(1, inside - 19);
|
|
38396
38482
|
const indicator = active ? color("\u203A", "cyan", colors2) : " ";
|
|
38397
38483
|
addBody(`${indicator} ${color(label, row.disabled ? "muted" : active ? "cyan" : "bold", colors2)} ${color(fit(value3, room), row.disabled ? "muted" : active ? "bold" : "muted", colors2)}`);
|
|
38398
|
-
if (!editing &&
|
|
38484
|
+
if (!editing && row.detail && (row.id === "destination" && row.detail.startsWith("/") || !view.error && active) && body.length < budget - 3)
|
|
38399
38485
|
addWrapped(row.detail, "muted", budget - 3);
|
|
38400
38486
|
}
|
|
38401
38487
|
if (view.error) {
|
|
@@ -38411,13 +38497,13 @@ var renderFormFrame = (view, focused, editing, columns, rows2, colors2 = !proces
|
|
|
38411
38497
|
while (body.length < budget)
|
|
38412
38498
|
addBody("");
|
|
38413
38499
|
screen.push(...body.slice(0, budget));
|
|
38414
|
-
if (!editing)
|
|
38500
|
+
if (!editing) {
|
|
38415
38501
|
screen.push(line("\u251C", "\u2524"));
|
|
38416
|
-
|
|
38417
|
-
|
|
38418
|
-
|
|
38419
|
-
if (!editing)
|
|
38502
|
+
const submit2 = focused === "submit" ? color("\u203A", "cyan", colors2) : " ";
|
|
38503
|
+
const cancel = focused === "cancel" ? color("\u203A", "cyan", colors2) : " ";
|
|
38504
|
+
add4(`${submit2} ${color(fit(safeDisplayText(view.submitLabel), Math.max(1, inside - 19)), view.submitDisabled ? "muted" : "cyan", colors2)} ${cancel} ${color("Cancel", focused === "cancel" ? "cyan" : "muted", colors2)}`);
|
|
38420
38505
|
add4(color(" \u2191\u2193 / jk move \xB7 Tab next \xB7 Enter select \xB7 Ctrl+S submit \xB7 Esc close", "muted", colors2));
|
|
38506
|
+
}
|
|
38421
38507
|
screen.push(line("\u2514", "\u2518"));
|
|
38422
38508
|
return screen.join(`\r
|
|
38423
38509
|
`) + (editing ? `\r
|
|
@@ -38519,11 +38605,11 @@ var problem = (error2) => error2 instanceof AppError ? error2.message : exports_
|
|
|
38519
38605
|
var selected = (value3, current, title, description) => ({ value: value3, selected: current, title, description });
|
|
38520
38606
|
var generatedName = (draft) => draft.worktreeName ?? (draft.clone?.vcs === "jj" ? draft.projectChoice?.name : draft.destination?.label) ?? draft.projectChoice?.name ?? "Worktree";
|
|
38521
38607
|
var inputFor = (draft) => {
|
|
38522
|
-
if (!draft.host || !draft.project || !draft.projectChoice || !draft.destination || !draft.
|
|
38608
|
+
if (!draft.host || !draft.project || !draft.projectChoice || !draft.destination || !draft.session)
|
|
38523
38609
|
return;
|
|
38524
38610
|
const common = {
|
|
38525
38611
|
repo: draft.project.vcs === "jj" ? draft.sourcePath ?? draft.project.path : draft.project.path,
|
|
38526
|
-
|
|
38612
|
+
session: draft.session,
|
|
38527
38613
|
name: generatedName(draft),
|
|
38528
38614
|
clientId: draft.clientId,
|
|
38529
38615
|
additional: draft.mode === "new-tab",
|
|
@@ -38560,7 +38646,10 @@ var selectWorktree = (draft, tree) => {
|
|
|
38560
38646
|
if (!tree.path || tree.vcs === "jj" && !tree.present)
|
|
38561
38647
|
throw new AppError({ message: `Workspace ${tree.vcs === "jj" ? tree.name : tree.path} is unavailable; inspect its registered location before opening` });
|
|
38562
38648
|
return {
|
|
38563
|
-
...changeDestination(draft, {
|
|
38649
|
+
...changeDestination(draft, {
|
|
38650
|
+
path: tree.path,
|
|
38651
|
+
label: tree.vcs === "jj" ? tree.name : tree.path.split("/").filter(Boolean).at(-1) ?? tree.path
|
|
38652
|
+
}),
|
|
38564
38653
|
...tree.vcs === "jj" ? {
|
|
38565
38654
|
sourcePath: tree.path,
|
|
38566
38655
|
projectChoice: draft.projectChoice?.source && draft.projectChoice.source.hostId === draft.host?.hostId ? { ...draft.projectChoice, source: { ...draft.projectChoice.source, checkoutPath: tree.path } } : draft.projectChoice
|
|
@@ -38572,10 +38661,9 @@ var typeWorktreeName = (draft, name, mainline) => ({
|
|
|
38572
38661
|
worktreeName: name,
|
|
38573
38662
|
destination: draft.destination && !draft.destination.path ? draft.destination : draft.project?.vcs === "jj" && !draft.clone && mainline ? { revision: mainline.revision.commitId, label: mainline.label } : undefined
|
|
38574
38663
|
});
|
|
38575
|
-
var resolveBranch = (draft, branch, path, existing) => existing ? changeDestination(draft, { path, label: path.split("/").filter(Boolean).at(-1) ?? path }) : changeDestination(draft, { branch, label: branch }, draft.worktreeName ?? branch);
|
|
38576
38664
|
var selectRevision = (draft, choice) => changeDestination(draft, { revision: choice.revision.commitId, label: choice.label }, draft.worktreeName);
|
|
38577
38665
|
var cloneInputFor = (draft) => {
|
|
38578
|
-
if (!draft.host || !draft.clone || !draft.
|
|
38666
|
+
if (!draft.host || !draft.clone || !draft.session || !draft.clone.repo.startsWith("/"))
|
|
38579
38667
|
return;
|
|
38580
38668
|
if (draft.clone.vcs === "jj")
|
|
38581
38669
|
return {
|
|
@@ -38588,7 +38676,7 @@ var cloneInputFor = (draft) => {
|
|
|
38588
38676
|
...draft.clone.revision ? { revision: draft.clone.revision } : {}
|
|
38589
38677
|
},
|
|
38590
38678
|
repo: draft.clone.repo,
|
|
38591
|
-
|
|
38679
|
+
session: draft.session,
|
|
38592
38680
|
clientId: draft.clientId,
|
|
38593
38681
|
name: generatedName(draft),
|
|
38594
38682
|
...draft.worktreeName ? { worktreeName: draft.worktreeName } : {},
|
|
@@ -38606,7 +38694,7 @@ var cloneInputFor = (draft) => {
|
|
|
38606
38694
|
branch: draft.clone.branch
|
|
38607
38695
|
},
|
|
38608
38696
|
repo: draft.clone.repo,
|
|
38609
|
-
|
|
38697
|
+
session: draft.session,
|
|
38610
38698
|
clientId: draft.clientId,
|
|
38611
38699
|
name: generatedName(draft),
|
|
38612
38700
|
branch: draft.destination.branch,
|
|
@@ -38626,8 +38714,8 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38626
38714
|
let error2;
|
|
38627
38715
|
let plan;
|
|
38628
38716
|
let clonePlan;
|
|
38717
|
+
let cloneRoot = "";
|
|
38629
38718
|
let cloneRoots = [];
|
|
38630
|
-
let submitAfterEdit = false;
|
|
38631
38719
|
let contextPath;
|
|
38632
38720
|
const resizePopup = yield* makePopupSizer;
|
|
38633
38721
|
let activeView;
|
|
@@ -38705,14 +38793,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38705
38793
|
return `\x1B[H\x1B[2J${renderFormFrame(view, focused, true, columns, rows2)}${editor}`;
|
|
38706
38794
|
}),
|
|
38707
38795
|
clear: () => exports_Effect.succeed(""),
|
|
38708
|
-
process: (event, state) => {
|
|
38709
|
-
if (event._tag === "Event")
|
|
38710
|
-
return exports_Effect.succeed({ _tag: "NextFrame", state });
|
|
38711
|
-
const action = advanceInputChoice(state, event.input, options.choices, options.selectionOnly);
|
|
38712
|
-
if (event.input.key.ctrl && event.input.key.name === "s" && action._tag === "Submit" && action.value)
|
|
38713
|
-
submitAfterEdit = true;
|
|
38714
|
-
return exports_Effect.succeed(action);
|
|
38715
|
-
}
|
|
38796
|
+
process: (event, state) => exports_Effect.succeed(event._tag === "Event" ? { _tag: "NextFrame", state } : advanceInputChoice(state, event.input, options.choices, options.selectionOnly))
|
|
38716
38797
|
}));
|
|
38717
38798
|
return result4 === null ? yield* exports_Effect.fail(new exports_Terminal.QuitError({})) : result4;
|
|
38718
38799
|
}, exports_Effect.scoped);
|
|
@@ -38738,31 +38819,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38738
38819
|
error2 = undefined;
|
|
38739
38820
|
}
|
|
38740
38821
|
});
|
|
38741
|
-
const
|
|
38742
|
-
plan = undefined;
|
|
38743
|
-
clonePlan = undefined;
|
|
38744
|
-
if (!draft.host)
|
|
38745
|
-
return;
|
|
38746
|
-
const cloneInput = cloneInputFor(draft);
|
|
38747
|
-
if (cloneInput) {
|
|
38748
|
-
const result5 = yield* exports_Effect.result(reviewClone(draft.host, command, cloneInput));
|
|
38749
|
-
if (exports_Result.isSuccess(result5)) {
|
|
38750
|
-
clonePlan = result5.success;
|
|
38751
|
-
error2 = undefined;
|
|
38752
|
-
} else
|
|
38753
|
-
error2 = problem(result5.failure);
|
|
38754
|
-
return;
|
|
38755
|
-
}
|
|
38756
|
-
const input = inputFor(draft);
|
|
38757
|
-
if (!input)
|
|
38758
|
-
return;
|
|
38759
|
-
const result4 = yield* exports_Effect.result(review(draft.host, command, input));
|
|
38760
|
-
if (exports_Result.isSuccess(result4)) {
|
|
38761
|
-
plan = result4.success;
|
|
38762
|
-
error2 = undefined;
|
|
38763
|
-
} else
|
|
38764
|
-
error2 = problem(result4.failure);
|
|
38765
|
-
});
|
|
38822
|
+
const clonePath = (choice) => choice.name && choice.name !== "." && choice.name !== ".." && !/[/\\\p{Cc}\u202a-\u202e\u2066-\u2069]/u.test(choice.name) ? `${cloneRoot.replace(/\/$/, "")}/${choice.name}` : undefined;
|
|
38766
38823
|
const known = (host, repository4, checkout) => ({
|
|
38767
38824
|
name: repository4.name,
|
|
38768
38825
|
source: {
|
|
@@ -38794,17 +38851,16 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38794
38851
|
};
|
|
38795
38852
|
});
|
|
38796
38853
|
const cloneDestination2 = exports_Effect.fnUntraced(function* (choice, host) {
|
|
38797
|
-
|
|
38798
|
-
|
|
38799
|
-
|
|
38800
|
-
|
|
38801
|
-
|
|
38802
|
-
|
|
38803
|
-
|
|
38804
|
-
}
|
|
38805
|
-
const repo = picked.kind === "selected" ? picked.value : picked.text.trim();
|
|
38854
|
+
let repo = clonePath(choice);
|
|
38855
|
+
if (!repo) {
|
|
38856
|
+
const picked = yield* inputChoice({
|
|
38857
|
+
message: "Project name is not a safe clone directory; type an absolute clone destination",
|
|
38858
|
+
choices: []
|
|
38859
|
+
});
|
|
38860
|
+
repo = picked.kind === "selected" ? picked.value : picked.text.trim();
|
|
38861
|
+
}
|
|
38806
38862
|
if (!repo.startsWith("/"))
|
|
38807
|
-
return yield* exports_Effect.fail(new AppError({ message: "Clone destination must be an absolute path on
|
|
38863
|
+
return yield* exports_Effect.fail(new AppError({ message: "Clone destination must be an absolute path on this machine" }));
|
|
38808
38864
|
yield* proposeClone(choice, host, repo);
|
|
38809
38865
|
});
|
|
38810
38866
|
const bindProject = exports_Effect.fnUntraced(function* (choice, host, available) {
|
|
@@ -38812,17 +38868,17 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38812
38868
|
let path = source?.machineKey === host.key && source.hostId === host.hostId ? source.checkoutPath ?? source.repository.path : undefined;
|
|
38813
38869
|
if (!path && choice.path?.startsWith("/"))
|
|
38814
38870
|
path = choice.path;
|
|
38871
|
+
if (source && (source.machineKey !== host.key || source.hostId !== host.hostId)) {
|
|
38872
|
+
if (path)
|
|
38873
|
+
yield* proposeClone(choice, host, path);
|
|
38874
|
+
else
|
|
38875
|
+
yield* cloneDestination2(choice, host);
|
|
38876
|
+
return;
|
|
38877
|
+
}
|
|
38815
38878
|
if (!path) {
|
|
38816
38879
|
const directory = yield* inputChoice({
|
|
38817
|
-
message: `Project directory on ${host.label} (existing checkout
|
|
38818
|
-
choices:
|
|
38819
|
-
...available.map((repo) => ({ value: repo.path, title: repo.name, description: repo.path })),
|
|
38820
|
-
...cloneRoots.map((root) => ({
|
|
38821
|
-
value: `${root.replace(/\/$/, "")}/${choice.name}`,
|
|
38822
|
-
title: choice.name,
|
|
38823
|
-
description: `${root.replace(/\/$/, "")}/${choice.name} \xB7 configured root suggestion`
|
|
38824
|
-
}))
|
|
38825
|
-
]
|
|
38880
|
+
message: `Project directory on ${host.label} (existing checkout; absolute path)`,
|
|
38881
|
+
choices: available.map((repo) => ({ value: repo.path, title: repo.name, description: repo.path }))
|
|
38826
38882
|
});
|
|
38827
38883
|
path = directory.kind === "selected" ? directory.value : directory.text.trim();
|
|
38828
38884
|
}
|
|
@@ -38851,6 +38907,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38851
38907
|
sessions = [];
|
|
38852
38908
|
plan = undefined;
|
|
38853
38909
|
clonePlan = undefined;
|
|
38910
|
+
cloneRoot = "";
|
|
38854
38911
|
cloneRoots = [];
|
|
38855
38912
|
error2 = problem(connected.failure);
|
|
38856
38913
|
return;
|
|
@@ -38868,11 +38925,13 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38868
38925
|
sessions = [];
|
|
38869
38926
|
plan = undefined;
|
|
38870
38927
|
clonePlan = undefined;
|
|
38928
|
+
cloneRoot = "";
|
|
38871
38929
|
cloneRoots = [];
|
|
38872
38930
|
error2 = problem(discovered.failure);
|
|
38873
38931
|
return;
|
|
38874
38932
|
}
|
|
38875
38933
|
const found = discovered.success;
|
|
38934
|
+
cloneRoot = found.cloneRoot;
|
|
38876
38935
|
cloneRoots = found.roots;
|
|
38877
38936
|
projects = [
|
|
38878
38937
|
...projects.filter((item) => item.source?.machineKey !== machine.key || item.source.hostId !== connected.success.hostId),
|
|
@@ -38881,7 +38940,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38881
38940
|
sessions = found.sessions;
|
|
38882
38941
|
draft = {
|
|
38883
38942
|
...draft,
|
|
38884
|
-
|
|
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,
|
|
38885
38944
|
clientId: focusClient(found.clients)
|
|
38886
38945
|
};
|
|
38887
38946
|
if (!draft.projectChoice && found.checkout && discoveredContext) {
|
|
@@ -38910,10 +38969,15 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38910
38969
|
draft = changeProject(draft, inspected.success.project);
|
|
38911
38970
|
if (inspected.success.checkout.vcs === "jj" && !draft.sourcePath)
|
|
38912
38971
|
draft = { ...draft, sourcePath: inspected.success.checkout.path };
|
|
38972
|
+
if (!draft.destination) {
|
|
38973
|
+
const checkoutPath = inspected.success.checkout.path;
|
|
38974
|
+
const tree = inspected.success.worktrees.find((item) => item.path === checkoutPath && (item.vcs === "jj" ? item.present : !item.bare && !item.prunable));
|
|
38975
|
+
if (tree)
|
|
38976
|
+
draft = selectWorktree(draft, tree);
|
|
38977
|
+
}
|
|
38913
38978
|
}
|
|
38914
38979
|
}
|
|
38915
38980
|
error2 = undefined;
|
|
38916
|
-
yield* refresh;
|
|
38917
38981
|
});
|
|
38918
38982
|
const formView = (initializing = false) => {
|
|
38919
38983
|
const rows2 = [
|
|
@@ -38926,31 +38990,57 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38926
38990
|
},
|
|
38927
38991
|
{
|
|
38928
38992
|
id: "destination",
|
|
38929
|
-
label: draft.
|
|
38930
|
-
value: draft.clone
|
|
38993
|
+
label: draft.clone ? "Clone to" : draft.project?.vcs === "jj" ? "Workspace" : "Checkout",
|
|
38994
|
+
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"),
|
|
38995
|
+
detail: draft.clone?.repo ?? draft.destination?.path,
|
|
38931
38996
|
disabled: !draft.host || !(draft.project || draft.clone)
|
|
38932
38997
|
},
|
|
38933
|
-
{
|
|
38934
|
-
id: "branch",
|
|
38935
|
-
label: draft.project?.vcs === "jj" || draft.clone?.vcs === "jj" ? "Start from" : "Branch",
|
|
38936
|
-
value: draft.project?.vcs === "jj" || draft.clone?.vcs === "jj" ? draft.destination?.revision ? draft.destination.label : draft.clone ? "Cloned default" : "Select or type a revision" : draft.destination?.branch ?? (draft.destination?.path && plan?.vcs === "git" ? plan.branch ?? "Existing checkout" : "Select or type branch"),
|
|
38937
|
-
disabled: !draft.host || !(draft.project || draft.clone) || (draft.project?.vcs === "jj" ? !draft.worktreeName : draft.clone?.vcs === "jj" ? false : !(draft.clone || draft.worktreeName || draft.destination?.path))
|
|
38938
|
-
},
|
|
38939
38998
|
{
|
|
38940
38999
|
id: "session",
|
|
38941
39000
|
label: "Session",
|
|
38942
|
-
value: sessions.find((s) => s.id === draft.
|
|
38943
|
-
detail: draft.
|
|
39001
|
+
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"),
|
|
39002
|
+
detail: draft.session?.kind === "existing" ? draft.session.id : draft.session?.kind === "new" ? "Create on confirmation" : undefined,
|
|
38944
39003
|
disabled: !draft.host
|
|
38945
|
-
}
|
|
38946
|
-
{ id: "mode", label: "Mode", value: draft.clone ? "New tab (clone task)" : draft.mode === "auto" ? "Reuse matching tab, otherwise new tab" : draft.mode === "new-tab" ? "Always new tab" : "Split matching tab, otherwise new tab", disabled: !draft.host || !!draft.clone }
|
|
39004
|
+
}
|
|
38947
39005
|
];
|
|
39006
|
+
if (draft.project?.vcs === "jj" && !draft.destination?.path || draft.clone?.vcs === "jj")
|
|
39007
|
+
rows2.push({
|
|
39008
|
+
id: "branch",
|
|
39009
|
+
label: "Start from",
|
|
39010
|
+
value: draft.destination?.revision ? draft.destination.label : draft.clone ? "Cloned default" : "Select or type revision",
|
|
39011
|
+
disabled: !draft.host || !!draft.project && !draft.worktreeName
|
|
39012
|
+
});
|
|
39013
|
+
if (draft.clone?.vcs === "git")
|
|
39014
|
+
rows2.push({ id: "branch", label: "Branch", value: draft.destination?.branch ?? "Select or type branch", disabled: !draft.host });
|
|
39015
|
+
if (draft.clone || draft.project?.vcs === "git" && draft.destination?.branch && !draft.destination.path)
|
|
39016
|
+
rows2.push({
|
|
39017
|
+
id: "checkoutName",
|
|
39018
|
+
label: draft.clone?.vcs === "jj" ? "Workspace" : "Directory",
|
|
39019
|
+
value: draft.worktreeName ?? (draft.clone?.vcs === "jj" ? "Use cloned default workspace" : "Default (derived from branch)"),
|
|
39020
|
+
disabled: !draft.host
|
|
39021
|
+
});
|
|
39022
|
+
if (!draft.clone)
|
|
39023
|
+
rows2.push({
|
|
39024
|
+
id: "mode",
|
|
39025
|
+
label: "Mode",
|
|
39026
|
+
value: draft.mode === "auto" ? "Reuse matching tab, otherwise new tab" : draft.mode === "new-tab" ? "Always new tab" : "Split matching tab, otherwise new tab",
|
|
39027
|
+
disabled: !draft.host
|
|
39028
|
+
});
|
|
39029
|
+
const safeOpen = !draft.clone && !!draft.destination?.path && draft.session?.kind === "existing";
|
|
38948
39030
|
return {
|
|
38949
|
-
rows: rows2.
|
|
38950
|
-
submitLabel: clonePlan?.label ?? plan?.label ?? (draft.clone ? "
|
|
38951
|
-
submitDisabled: initializing || !draft.host || !(
|
|
38952
|
-
notice: [
|
|
38953
|
-
|
|
39031
|
+
rows: rows2.map((row) => ({ ...row, disabled: initializing || row.disabled })),
|
|
39032
|
+
submitLabel: clonePlan?.label ?? plan?.label ?? (draft.clone ? "Review clone" : safeOpen ? "Open checkout" : "Review & open"),
|
|
39033
|
+
submitDisabled: initializing || !draft.host || !(cloneInputFor(draft) || inputFor(draft)),
|
|
39034
|
+
notice: [
|
|
39035
|
+
clonePlan || plan ? "Review this action; submit again to launch" : draft.clone ? "Only pushed history transfers" : undefined,
|
|
39036
|
+
plan ? `Destination: ${plan.path}` : undefined,
|
|
39037
|
+
clonePlan?.detail,
|
|
39038
|
+
clonePlan?.vcs === "jj" ? `Start from: ${draft.destination?.revision ? `${draft.destination.label} (${draft.destination.revision})` : "cloned default"}` : undefined,
|
|
39039
|
+
clonePlan?.warning,
|
|
39040
|
+
plan?.detail,
|
|
39041
|
+
plan?.warning
|
|
39042
|
+
].filter(Boolean).join(" \xB7 ") || undefined,
|
|
39043
|
+
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" : !(draft.project || draft.clone) ? "Select the exact project directory on this machine" : !draft.destination && draft.project?.vcs !== "jj" && draft.clone?.vcs !== "jj" ? "Select a branch" : draft.project?.vcs === "jj" && (!draft.worktreeName && !draft.destination?.path || !!draft.worktreeName && !draft.destination?.revision) ? "Choose an existing workspace or a new workspace name and starting revision" : !draft.session ? "Choose an existing Rex session or type a new name" : undefined),
|
|
38954
39044
|
fitWarning: activeView?.fitWarning
|
|
38955
39045
|
};
|
|
38956
39046
|
};
|
|
@@ -38969,27 +39059,27 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
38969
39059
|
const initialAction = yield* exports_Effect.raceFirst(initialize, chooseField(initialView, "project").pipe(exports_Effect.catchTag("QuitError", () => exports_Effect.succeed("cancel"))));
|
|
38970
39060
|
if (initialAction === "cancel")
|
|
38971
39061
|
return;
|
|
38972
|
-
let queuedSubmit = false;
|
|
38973
39062
|
while (true) {
|
|
38974
39063
|
const view = formView();
|
|
38975
39064
|
activeView = view;
|
|
38976
|
-
const action =
|
|
38977
|
-
queuedSubmit = false;
|
|
39065
|
+
const action = yield* chooseField(view, focused).pipe(exports_Effect.catchTag("QuitError", () => exports_Effect.succeed("cancel")));
|
|
38978
39066
|
focused = action;
|
|
38979
39067
|
if (action === "cancel")
|
|
38980
39068
|
return;
|
|
38981
39069
|
if (action === "submit") {
|
|
38982
39070
|
const cloneInput = cloneInputFor(draft);
|
|
38983
|
-
if (draft.host
|
|
39071
|
+
if (!draft.host || !(cloneInput || inputFor(draft)))
|
|
39072
|
+
continue;
|
|
39073
|
+
if (cloneInput) {
|
|
38984
39074
|
const current2 = yield* exports_Effect.result(reviewClone(draft.host, command, cloneInput));
|
|
38985
39075
|
if (exports_Result.isFailure(current2)) {
|
|
38986
39076
|
error2 = problem(current2.failure);
|
|
38987
39077
|
clonePlan = undefined;
|
|
38988
39078
|
continue;
|
|
38989
39079
|
}
|
|
38990
|
-
if (!sameClonePlan(current2.success, clonePlan)) {
|
|
39080
|
+
if (!clonePlan || !sameClonePlan(current2.success, clonePlan)) {
|
|
39081
|
+
error2 = clonePlan ? "Clone destination or Rex target changed; review the updated URL and destination before submitting again" : undefined;
|
|
38991
39082
|
clonePlan = current2.success;
|
|
38992
|
-
error2 = "Clone destination or Rex target changed; review the updated URL and destination before submitting again";
|
|
38993
39083
|
continue;
|
|
38994
39084
|
}
|
|
38995
39085
|
const launched2 = yield* exports_Effect.result(submitClone(draft.host, command, cloneInput, clonePlan));
|
|
@@ -39012,7 +39102,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39012
39102
|
return;
|
|
39013
39103
|
}
|
|
39014
39104
|
const input = inputFor(draft);
|
|
39015
|
-
if (!
|
|
39105
|
+
if (!input)
|
|
39016
39106
|
continue;
|
|
39017
39107
|
const current = yield* exports_Effect.result(review(draft.host, command, input));
|
|
39018
39108
|
if (exports_Result.isFailure(current)) {
|
|
@@ -39020,11 +39110,19 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39020
39110
|
plan = undefined;
|
|
39021
39111
|
continue;
|
|
39022
39112
|
}
|
|
39023
|
-
if (!sameLaunchPlan(current.success, plan)) {
|
|
39024
|
-
plan = current.success;
|
|
39113
|
+
if (plan && !sameLaunchPlan(current.success, plan)) {
|
|
39025
39114
|
error2 = "Destination or Rex target changed; review the updated action before submitting again";
|
|
39115
|
+
plan = current.success;
|
|
39026
39116
|
continue;
|
|
39027
39117
|
}
|
|
39118
|
+
if (!plan) {
|
|
39119
|
+
const safeOpen = !!draft.destination?.path && draft.session?.kind === "existing" && current.success.checkout === "existing" && current.success.path === draft.destination.path && safeDisplayText(draft.destination.path) === draft.destination.path && !current.success.detail && !current.success.warning && !view.fitWarning && naturalFormRows(view, yield* terminal.columns) + 1 <= (yield* terminal.rows);
|
|
39120
|
+
plan = current.success;
|
|
39121
|
+
if (!safeOpen) {
|
|
39122
|
+
error2 = undefined;
|
|
39123
|
+
continue;
|
|
39124
|
+
}
|
|
39125
|
+
}
|
|
39028
39126
|
const launched = yield* exports_Effect.result(submit(draft.host, command, input, plan));
|
|
39029
39127
|
if (exports_Result.isFailure(launched)) {
|
|
39030
39128
|
launchAcknowledged = true;
|
|
@@ -39047,7 +39145,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39047
39145
|
}
|
|
39048
39146
|
if (view.rows.find((row) => row.id === action)?.disabled)
|
|
39049
39147
|
continue;
|
|
39050
|
-
|
|
39148
|
+
error2 = undefined;
|
|
39051
39149
|
const editing = yield* exports_Effect.result(exports_Effect.gen(function* () {
|
|
39052
39150
|
if (action === "machine") {
|
|
39053
39151
|
yield* loadMachines;
|
|
@@ -39081,14 +39179,17 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39081
39179
|
draft = changeProject(draft, inspected.project);
|
|
39082
39180
|
if (inspected.checkout.vcs === "jj")
|
|
39083
39181
|
draft = { ...draft, sourcePath: inspected.checkout.path };
|
|
39182
|
+
const tree = inspected.worktrees.find((item) => item.path === inspected.checkout.path && (item.vcs === "jj" ? item.present : !item.bare && !item.prunable));
|
|
39183
|
+
if (tree)
|
|
39184
|
+
draft = selectWorktree(draft, tree);
|
|
39084
39185
|
}
|
|
39085
39186
|
projects = [
|
|
39086
39187
|
...projects.filter((item) => item.source?.machineKey !== host.key || item.source.hostId !== host.hostId),
|
|
39087
39188
|
...found.projects.map((repo) => known(host, repo, found.checkout))
|
|
39088
39189
|
];
|
|
39089
39190
|
sessions = found.sessions;
|
|
39090
|
-
if (!sessions.some((item) => item.id === draft.
|
|
39091
|
-
draft = { ...draft,
|
|
39191
|
+
if (draft.session?.kind === "existing" && !sessions.some((item) => item.id === (draft.session?.kind === "existing" ? draft.session.id : undefined)))
|
|
39192
|
+
draft = { ...draft, session: sessions.length === 1 ? { kind: "existing", id: sessions[0].id } : undefined };
|
|
39092
39193
|
draft = { ...draft, clientId: focusClient(found.clients) };
|
|
39093
39194
|
} else
|
|
39094
39195
|
draft = changeProjectChoice(draft, choice);
|
|
@@ -39098,7 +39199,7 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39098
39199
|
if (draft.clone) {
|
|
39099
39200
|
const clone = draft.clone;
|
|
39100
39201
|
const picked = yield* inputChoice({
|
|
39101
|
-
message:
|
|
39202
|
+
message: "Clone to (absolute destination path on selected machine)",
|
|
39102
39203
|
choices: [
|
|
39103
39204
|
{ value: clone.repo, title: "Current clone destination", description: clone.repo },
|
|
39104
39205
|
...cloneRoots.map((root) => ({
|
|
@@ -39108,57 +39209,73 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39108
39209
|
}))
|
|
39109
39210
|
]
|
|
39110
39211
|
});
|
|
39111
|
-
|
|
39112
|
-
|
|
39113
|
-
|
|
39114
|
-
|
|
39115
|
-
const name = picked.text.trim();
|
|
39116
|
-
if (name === "none")
|
|
39117
|
-
draft = { ...draft, worktreeName: undefined };
|
|
39118
|
-
else {
|
|
39119
|
-
if (!name || /[\p{ASCII}&&\p{Cc}]/v.test(name) || name.split(/[\\/]/).some((part) => !part || part === "." || part === ".."))
|
|
39120
|
-
return yield* exports_Effect.fail(new AppError({ message: "Type an absolute clone destination or valid checkout name (none to clear)" }));
|
|
39121
|
-
draft = { ...draft, worktreeName: name };
|
|
39122
|
-
}
|
|
39123
|
-
}
|
|
39212
|
+
const repo = (picked.kind === "selected" ? picked.value : picked.text).trim();
|
|
39213
|
+
if (!repo.startsWith("/"))
|
|
39214
|
+
return yield* exports_Effect.fail(new AppError({ message: "Clone destination must be an absolute path on this machine" }));
|
|
39215
|
+
draft = { ...draft, clone: { ...clone, repo } };
|
|
39124
39216
|
} else {
|
|
39125
39217
|
const found = yield* inspectWorktrees(draft.host, command, draft.project.vcs === "jj" ? draft.sourcePath ?? draft.project.path : draft.project.path);
|
|
39126
39218
|
const trees = found.worktrees.filter((tree) => tree.vcs === "jj" || !tree.bare && !tree.prunable);
|
|
39219
|
+
const git2 = draft.project.vcs === "git";
|
|
39127
39220
|
const picked = yield* inputChoice({
|
|
39128
|
-
message:
|
|
39221
|
+
message: git2 ? "Checkout (select exact worktree or branch, or type new branch)" : "Workspace (select existing, Clone this project, or type new workspace name)",
|
|
39129
39222
|
choices: [
|
|
39130
39223
|
...trees.map((tree) => ({
|
|
39131
39224
|
value: tree,
|
|
39132
39225
|
title: tree.vcs === "jj" ? tree.name : tree.path.split("/").filter(Boolean).at(-1) ?? tree.path,
|
|
39133
39226
|
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}`
|
|
39134
39227
|
})),
|
|
39228
|
+
...git2 ? found.branches.map((branch) => ({
|
|
39229
|
+
value: { kind: "branch", value: branch },
|
|
39230
|
+
title: `Branch: ${branch}`,
|
|
39231
|
+
description: trees.find((tree) => tree.vcs === "git" && tree.branch === branch)?.path ?? "Free branch \u2014 attach new checkout"
|
|
39232
|
+
})) : [],
|
|
39135
39233
|
...draft.projectChoice?.source ? [{
|
|
39136
39234
|
value: "clone",
|
|
39137
39235
|
title: "Clone this project\u2026",
|
|
39138
|
-
description: "Choose
|
|
39236
|
+
description: clonePath(draft.projectChoice) ? `Propose ${clonePath(draft.projectChoice)} \xB7 only pushed history transfers` : "Choose an absolute clone destination \xB7 only pushed history transfers"
|
|
39139
39237
|
}] : []
|
|
39140
39238
|
]
|
|
39141
39239
|
});
|
|
39142
39240
|
if (picked.kind === "selected") {
|
|
39143
39241
|
if (picked.value === "clone")
|
|
39144
39242
|
yield* cloneDestination2(draft.projectChoice, draft.host);
|
|
39145
|
-
else {
|
|
39243
|
+
else if ("kind" in picked.value) {
|
|
39244
|
+
const branch = picked.value.value;
|
|
39245
|
+
const existing = trees.find((tree) => tree.vcs === "git" && tree.branch === branch);
|
|
39246
|
+
draft = existing ? selectWorktree(draft, existing) : changeDestination(draft, { branch, label: branch }, draft.worktreeName);
|
|
39247
|
+
} else {
|
|
39146
39248
|
if (picked.value.vcs === "jj" && (!picked.value.present || !picked.value.path))
|
|
39147
39249
|
return yield* exports_Effect.fail(new AppError({ message: `Workspace ${picked.value.name} is unavailable; inspect its registered location before opening` }));
|
|
39148
39250
|
draft = selectWorktree(draft, picked.value);
|
|
39149
39251
|
}
|
|
39150
39252
|
} else {
|
|
39151
39253
|
const name = picked.text.trim();
|
|
39152
|
-
if (!name || name.startsWith("
|
|
39153
|
-
return yield* exports_Effect.fail(new AppError({ message: "Invalid workspace
|
|
39154
|
-
|
|
39155
|
-
|
|
39156
|
-
|
|
39157
|
-
draft = resolveBranch(candidate, inspected.branch, inspected.path, inspected.existing);
|
|
39254
|
+
if (!name || name.startsWith("-") && git2 || /[\p{ASCII}&&\p{Cc}]/v.test(name) || !git2 && (name.startsWith("/") || name.split(/[\\/]/).some((part) => !part || part === "." || part === "..")))
|
|
39255
|
+
return yield* exports_Effect.fail(new AppError({ message: git2 ? "Branch name must be a valid Git branch" : "Invalid workspace name" }));
|
|
39256
|
+
if (git2) {
|
|
39257
|
+
const existing = trees.find((tree) => tree.vcs === "git" && tree.branch === name);
|
|
39258
|
+
draft = existing ? selectWorktree(draft, existing) : changeDestination(draft, { branch: name, label: name }, draft.worktreeName);
|
|
39158
39259
|
} else
|
|
39159
|
-
draft =
|
|
39260
|
+
draft = typeWorktreeName(draft, name, found.revisions.find((choice) => choice.expression === "trunk()"));
|
|
39160
39261
|
}
|
|
39161
39262
|
}
|
|
39263
|
+
} else if (action === "checkoutName") {
|
|
39264
|
+
const picked = yield* inputChoice({
|
|
39265
|
+
message: draft.clone?.vcs === "jj" ? "Optional separate workspace name" : "Optional custom checkout directory name",
|
|
39266
|
+
choices: [
|
|
39267
|
+
{ value: null, title: "Use default", description: "No separate custom name" },
|
|
39268
|
+
...draft.worktreeName ? [{ value: draft.worktreeName, title: "Current custom name" }] : []
|
|
39269
|
+
]
|
|
39270
|
+
});
|
|
39271
|
+
if (picked.kind === "selected" && picked.value === null)
|
|
39272
|
+
draft = { ...draft, worktreeName: undefined };
|
|
39273
|
+
else {
|
|
39274
|
+
const name = (picked.kind === "selected" ? picked.value : picked.text).trim();
|
|
39275
|
+
if (!name || /[\p{ASCII}&&\p{Cc}]/v.test(name) || name.split(/[\\/]/).some((part) => !part || part === "." || part === ".."))
|
|
39276
|
+
return yield* exports_Effect.fail(new AppError({ message: "Invalid custom checkout name" }));
|
|
39277
|
+
draft = { ...draft, worktreeName: name };
|
|
39278
|
+
}
|
|
39162
39279
|
} else if (action === "branch") {
|
|
39163
39280
|
if (!draft.host || !(draft.project || draft.clone))
|
|
39164
39281
|
return yield* exports_Effect.fail(new AppError({ message: "Select a project and machine before choosing a base or branch" }));
|
|
@@ -39221,50 +39338,35 @@ var popup = (command, context3, origin2 = {}, preferredMachine) => exports_Effec
|
|
|
39221
39338
|
if (!branch || branch.startsWith("-") || /[\p{ASCII}&&\p{Cc}]/v.test(branch))
|
|
39222
39339
|
return yield* exports_Effect.fail(new AppError({ message: "Branch name must be a valid Git branch" }));
|
|
39223
39340
|
draft = { ...draft, destination: { branch, label: branch } };
|
|
39224
|
-
} else {
|
|
39225
|
-
const found = yield* inspectWorktrees(draft.host, command, draft.project.path);
|
|
39226
|
-
const picked = yield* inputChoice({
|
|
39227
|
-
message: "Branch (select existing or type new branch)",
|
|
39228
|
-
choices: found.branches.map((branch2) => ({
|
|
39229
|
-
value: branch2,
|
|
39230
|
-
title: branch2,
|
|
39231
|
-
description: found.worktrees.find((tree) => tree.vcs === "git" && tree.branch === branch2)?.path ?? "Free branch \u2014 attach new checkout"
|
|
39232
|
-
}))
|
|
39233
|
-
});
|
|
39234
|
-
const branch = picked.kind === "selected" ? picked.value : picked.text;
|
|
39235
|
-
if (!branch.trim())
|
|
39236
|
-
return yield* exports_Effect.fail(new AppError({ message: "Branch name is required" }));
|
|
39237
|
-
const inspected = yield* inspectBranch(draft.host, command, draft.project.path, branch, draft.worktreeName);
|
|
39238
|
-
draft = resolveBranch(draft, inspected.branch, inspected.path, inspected.existing);
|
|
39239
39341
|
}
|
|
39240
39342
|
} else if (action === "session") {
|
|
39241
39343
|
if (!draft.host)
|
|
39242
39344
|
return yield* exports_Effect.fail(new AppError({ message: "Select a machine before choosing a session" }));
|
|
39243
39345
|
const found = yield* discover(draft.host, command);
|
|
39244
39346
|
sessions = found.sessions;
|
|
39245
|
-
if (!sessions.length)
|
|
39246
|
-
return yield* exports_Effect.fail(new AppError({ message: "No Rex sessions available on selected machine" }));
|
|
39247
39347
|
draft = { ...draft, clientId: focusClient(found.clients) };
|
|
39248
|
-
|
|
39348
|
+
const picked = yield* inputChoice({
|
|
39349
|
+
message: "Session (select existing or type new name)",
|
|
39350
|
+
choices: sessions.map((item) => ({ value: item.id, title: item.label, description: item.id }))
|
|
39351
|
+
});
|
|
39352
|
+
draft = { ...draft, session: picked.kind === "selected" ? { kind: "existing", id: picked.value } : { kind: "new", name: picked.text } };
|
|
39249
39353
|
} else if (action === "mode") {
|
|
39250
|
-
draft = {
|
|
39251
|
-
|
|
39252
|
-
|
|
39253
|
-
|
|
39254
|
-
|
|
39354
|
+
draft = {
|
|
39355
|
+
...draft,
|
|
39356
|
+
mode: yield* choose("Open mode", [
|
|
39357
|
+
selected("auto", draft.mode === "auto", "Reuse matching tab", "Focus existing task, otherwise open new tab"),
|
|
39358
|
+
selected("new-tab", draft.mode === "new-tab", "Always new tab"),
|
|
39359
|
+
selected("split", draft.mode === "split", "Split matching task", "Opens new tab when no live target exists")
|
|
39360
|
+
])
|
|
39361
|
+
};
|
|
39255
39362
|
}
|
|
39256
39363
|
}));
|
|
39257
39364
|
if (exports_Result.isFailure(editing)) {
|
|
39258
|
-
submitAfterEdit = false;
|
|
39259
39365
|
if (!exports_Terminal.isQuitError(editing.failure))
|
|
39260
39366
|
error2 = problem(editing.failure);
|
|
39261
39367
|
} else {
|
|
39262
|
-
|
|
39263
|
-
|
|
39264
|
-
yield* refresh;
|
|
39265
|
-
}
|
|
39266
|
-
queuedSubmit = submitAfterEdit && !formView().submitDisabled && (!draft.clone || hadCloneReview);
|
|
39267
|
-
submitAfterEdit = false;
|
|
39368
|
+
plan = undefined;
|
|
39369
|
+
clonePlan = undefined;
|
|
39268
39370
|
}
|
|
39269
39371
|
}
|
|
39270
39372
|
}).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)))));
|
|
@@ -39423,7 +39525,7 @@ Run rex config reload to activate.`}`);
|
|
|
39423
39525
|
input = {
|
|
39424
39526
|
vcs,
|
|
39425
39527
|
repo: repoPath,
|
|
39426
|
-
|
|
39528
|
+
session: { kind: "existing", id: flags["--session"] },
|
|
39427
39529
|
name: flags["--name"],
|
|
39428
39530
|
branch: flags["--branch"],
|
|
39429
39531
|
worktreeName: flags["--worktree-name"],
|
|
@@ -39438,7 +39540,7 @@ Run rex config reload to activate.`}`);
|
|
|
39438
39540
|
input = {
|
|
39439
39541
|
vcs,
|
|
39440
39542
|
repo: repoPath,
|
|
39441
|
-
|
|
39543
|
+
session: { kind: "existing", id: flags["--session"] },
|
|
39442
39544
|
name: flags["--name"],
|
|
39443
39545
|
worktreeName: flags["--worktree-name"],
|
|
39444
39546
|
revision: flags["--revision"],
|