@junctionpanel/server 0.1.86 → 0.1.88

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.
@@ -2887,6 +2887,12 @@ export class Session {
2887
2887
  }
2888
2888
  }
2889
2889
  toCheckoutError(error) {
2890
+ if (error instanceof SessionRequestError) {
2891
+ if (error.code === DIRTY_WORKTREE_CONFIRMATION_REQUIRED) {
2892
+ return { code: DIRTY_WORKTREE_CONFIRMATION_REQUIRED, message: error.message };
2893
+ }
2894
+ return { code: 'UNKNOWN', message: error.message };
2895
+ }
2890
2896
  if (error instanceof NotGitRepoError) {
2891
2897
  return { code: 'NOT_GIT_REPO', message: error.message };
2892
2898
  }
@@ -5309,6 +5315,7 @@ export class Session {
5309
5315
  const { requestId } = msg;
5310
5316
  let targetPath = msg.worktreePath;
5311
5317
  let repoRoot = msg.repoRoot ?? null;
5318
+ const dirtyWorktreeBehavior = msg.dirtyWorktreeBehavior ?? 'reject';
5312
5319
  try {
5313
5320
  if (!targetPath) {
5314
5321
  if (!repoRoot || !msg.branchName) {
@@ -5344,6 +5351,10 @@ export class Session {
5344
5351
  if (!repoRoot) {
5345
5352
  throw new Error('Unable to resolve repo root for worktree');
5346
5353
  }
5354
+ if (dirtyWorktreeBehavior !== 'discard' &&
5355
+ (await this.hasDirtyWorktreeState(targetPath))) {
5356
+ throw new SessionRequestError(DIRTY_WORKTREE_CONFIRMATION_REQUIRED, 'Archiving this workspace will discard uncommitted or untracked files in the worktree.');
5357
+ }
5347
5358
  const archiveResult = await this.archiveJunctionWorktree({
5348
5359
  targetPath,
5349
5360
  repoRoot,