mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-17 22:14:08 +00:00
fix(auth): preserve bare profile behavior across runtime and sync
This commit is contained in:
1 parent
bc9b04444e
commit
8f8684ce85
14 files changed
+355
-34
No files matched your search
@@ -111,6 +111,9 @@ export async function handleCreate(ctx: CommandContext, args: string[]): Promise
|
||||
const previousUnifiedProfile = existsUnified
|
||||
? ctx.registry.getAllAccountsUnified()[profileName]
|
||||
: undefined;
|
||||
const previousBare =
|
||||
previousLegacyProfile?.bare === true || previousUnifiedProfile?.bare === true;
|
||||
const effectiveBare = bare === true || (profileExistedBeforeCreate && previousBare);
|
||||
const previousContextPolicy =
|
||||
profileExistedBeforeCreate && (previousUnifiedProfile || previousLegacyProfile)
|
||||
? resolveAccountContextPolicy(previousUnifiedProfile || previousLegacyProfile)
|
||||
@@ -169,7 +172,9 @@ export async function handleCreate(ctx: CommandContext, args: string[]): Promise
|
||||
|
||||
if (previousContextPolicy) {
|
||||
try {
|
||||
await ctx.instanceMgr.ensureInstance(profileName, previousContextPolicy);
|
||||
await ctx.instanceMgr.ensureInstance(profileName, previousContextPolicy, {
|
||||
bare: previousBare,
|
||||
});
|
||||
} catch {
|
||||
// Best-effort rollback for context mode/group.
|
||||
}
|
||||
@@ -180,7 +185,7 @@ export async function handleCreate(ctx: CommandContext, args: string[]): Promise
|
||||
// Create instance directory
|
||||
console.log(info(`Creating profile: ${profileName}`));
|
||||
const instancePath = await ctx.instanceMgr.ensureInstance(profileName, contextPolicy, {
|
||||
bare: !!bare,
|
||||
bare: effectiveBare,
|
||||
});
|
||||
|
||||
// Create/update profile entry based on config mode
|
||||
@@ -190,13 +195,13 @@ export async function handleCreate(ctx: CommandContext, args: string[]): Promise
|
||||
ctx.registry.updateAccountUnified(profileName, {
|
||||
context_mode: contextMetadata.context_mode,
|
||||
context_group: contextMetadata.context_group,
|
||||
...(bare ? { bare: true } : {}),
|
||||
...(effectiveBare ? { bare: true } : {}),
|
||||
});
|
||||
ctx.registry.touchAccountUnified(profileName);
|
||||
} else {
|
||||
ctx.registry.createAccountUnified(profileName, {
|
||||
...contextMetadata,
|
||||
...(bare ? { bare: true } : {}),
|
||||
...(effectiveBare ? { bare: true } : {}),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -206,14 +211,14 @@ export async function handleCreate(ctx: CommandContext, args: string[]): Promise
|
||||
type: 'account',
|
||||
context_mode: contextMetadata.context_mode,
|
||||
context_group: contextMetadata.context_group,
|
||||
...(bare ? { bare: true } : {}),
|
||||
...(effectiveBare ? { bare: true } : {}),
|
||||
});
|
||||
} else {
|
||||
ctx.registry.createProfile(profileName, {
|
||||
type: 'account',
|
||||
context_mode: contextMetadata.context_mode,
|
||||
context_group: contextMetadata.context_group,
|
||||
...(bare ? { bare: true } : {}),
|
||||
...(effectiveBare ? { bare: true } : {}),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -271,7 +276,7 @@ export async function handleCreate(ctx: CommandContext, args: string[]): Promise
|
||||
`Instance: ${instancePath}\n` +
|
||||
`Type: account\n` +
|
||||
`Context: ${formatAccountContextPolicy(contextPolicy)}` +
|
||||
(bare ? '\nMode: bare (no shared symlinks)' : ''),
|
||||
(effectiveBare ? '\nMode: bare (no shared symlinks)' : ''),
|
||||
'Profile Created'
|
||||
)
|
||||
);
|
||||
|
||||
@@ -146,7 +146,9 @@ export async function resolveProfileContinuityInheritance(
|
||||
isAccountContextMetadata(mappedProfile) ? mappedProfile : undefined
|
||||
);
|
||||
const instanceMgr = new InstanceManager();
|
||||
const instancePath = await instanceMgr.ensureInstance(sourceAccount, contextPolicy);
|
||||
const instancePath = await instanceMgr.ensureInstance(sourceAccount, contextPolicy, {
|
||||
bare: mappedProfile.bare === true,
|
||||
});
|
||||
|
||||
return {
|
||||
sourceAccount,
|
||||
|
||||
@@ -203,6 +203,7 @@ class ProfileDetector {
|
||||
context_mode: account.context_mode,
|
||||
context_group: account.context_group,
|
||||
continuity_mode: account.continuity_mode,
|
||||
bare: account.bare,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ interface CreateMetadata {
|
||||
context_mode?: 'isolated' | 'shared';
|
||||
context_group?: string;
|
||||
continuity_mode?: 'standard' | 'deeper';
|
||||
bare?: boolean;
|
||||
}
|
||||
|
||||
export class ProfileRegistry {
|
||||
@@ -173,6 +174,7 @@ export class ProfileRegistry {
|
||||
context_mode: metadata.context_mode,
|
||||
context_group: metadata.context_group,
|
||||
continuity_mode: metadata.continuity_mode,
|
||||
bare: metadata.bare,
|
||||
});
|
||||
|
||||
// Note: No longer auto-set as default
|
||||
@@ -321,6 +323,7 @@ export class ProfileRegistry {
|
||||
context_mode: metadata.context_mode,
|
||||
context_group: metadata.context_group,
|
||||
continuity_mode: metadata.continuity_mode,
|
||||
bare: metadata.bare,
|
||||
});
|
||||
saveUnifiedConfig(config);
|
||||
}
|
||||
@@ -449,6 +452,7 @@ export class ProfileRegistry {
|
||||
context_mode: account.context_mode,
|
||||
context_group: account.context_group,
|
||||
continuity_mode: account.continuity_mode,
|
||||
bare: account.bare,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user