Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tui/apply/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ export async function runApplyTUI(

case 'personality':
if (key.name === 'return' && activeSelect) {
const idx = activeSelect.selectedIndex;
const idx = activeSelect.getSelectedIndex();
const speciesDefault = DEFAULT_PERSONALITIES[desired.species] ?? null;
const values = speciesDefault ? ['keep', 'default', 'custom'] : ['keep', 'custom'];
const choice = values[idx];
Expand Down
27 changes: 26 additions & 1 deletion src/tui/commands/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,30 @@ import {
getMinSaltCount,
} from '@/patcher/salt-ops.js';
import { patchBinary } from '@/patcher/patch.js';
import { loadPetConfig } from '@/config/index.js';
import {
loadPetConfig,
loadPetConfigV2,
renameCompanion,
setCompanionPersonality,
} from '@/config/index.js';
import { warnCodesign } from '../display.ts';

function restoreProfileIdentity(salt: string): void {
const configV2 = loadPetConfigV2();
const profile = configV2?.profiles[salt];
if (!profile) return;
try {
if (profile.name) renameCompanion(profile.name);
} catch {
/* companion may not be hatched yet */
}
try {
if (profile.personality) setCompanionPersonality(profile.personality);
} catch {
/* companion may not be hatched yet */
}
}

export async function runApply({ silent = false } = {}): Promise<void> {
const config = loadPetConfig();
if (!config?.salt) {
Expand All @@ -29,6 +50,7 @@ export async function runApply({ silent = false } = {}): Promise<void> {
const check = verifySalt(binaryPath, config.salt);
if (check.found >= getMinSaltCount(binaryPath)) {
if (!silent) console.log(chalk.green(' Pet already applied.'));
restoreProfileIdentity(config.salt);
return;
}

Expand All @@ -44,6 +66,7 @@ export async function runApply({ silent = false } = {}): Promise<void> {
console.log(chalk.green(` Re-patched (${result.replacements} replacements).`));
}
warnCodesign(result, binaryPath);
restoreProfileIdentity(config.salt);
return;
}
}
Expand All @@ -54,6 +77,7 @@ export async function runApply({ silent = false } = {}): Promise<void> {
console.log(chalk.green(` Patched after update (${result.replacements} replacements).`));
}
warnCodesign(result, binaryPath);
restoreProfileIdentity(config.salt);
return;
}
if (!silent)
Expand All @@ -71,4 +95,5 @@ export async function runApply({ silent = false } = {}): Promise<void> {
console.log(chalk.yellow(' Restart Claude Code for the change to take effect.'));
}
}
restoreProfileIdentity(config.salt);
}
Loading