From 148cb0004fd6731b561e89079d2164c7c646e57f Mon Sep 17 00:00:00 2001 From: escapables Date: Fri, 3 Apr 2026 14:08:42 +0200 Subject: [PATCH] fix: apply wizard personality picker and identity persistence Two bugs in the apply flow: 1. Personality picker read `activeSelect.selectedIndex` (setter-only, returns undefined) instead of `getSelectedIndex()`. Selection was silently ignored. 2. `apply --silent` (SessionStart hook) re-patched the binary after Claude Code updates but never restored the companion's custom name and personality from the saved profile. They reverted to defaults. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/tui/apply/index.ts | 2 +- src/tui/commands/apply.ts | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/tui/apply/index.ts b/src/tui/apply/index.ts index e1ae4f4..2a778b4 100644 --- a/src/tui/apply/index.ts +++ b/src/tui/apply/index.ts @@ -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]; diff --git a/src/tui/commands/apply.ts b/src/tui/commands/apply.ts index 6d4c814..db70983 100644 --- a/src/tui/commands/apply.ts +++ b/src/tui/commands/apply.ts @@ -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 { const config = loadPetConfig(); if (!config?.salt) { @@ -29,6 +50,7 @@ export async function runApply({ silent = false } = {}): Promise { const check = verifySalt(binaryPath, config.salt); if (check.found >= getMinSaltCount(binaryPath)) { if (!silent) console.log(chalk.green(' Pet already applied.')); + restoreProfileIdentity(config.salt); return; } @@ -44,6 +66,7 @@ export async function runApply({ silent = false } = {}): Promise { console.log(chalk.green(` Re-patched (${result.replacements} replacements).`)); } warnCodesign(result, binaryPath); + restoreProfileIdentity(config.salt); return; } } @@ -54,6 +77,7 @@ export async function runApply({ silent = false } = {}): Promise { console.log(chalk.green(` Patched after update (${result.replacements} replacements).`)); } warnCodesign(result, binaryPath); + restoreProfileIdentity(config.salt); return; } if (!silent) @@ -71,4 +95,5 @@ export async function runApply({ silent = false } = {}): Promise { console.log(chalk.yellow(' Restart Claude Code for the change to take effect.')); } } + restoreProfileIdentity(config.salt); }