mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
fix(claude): keep each account's newest groveChoiceSeenAt during profile state sync (#40381)
Refreshing a managed Claude profile copied the personal ~/.claude.json groveChoiceSeenAt map over the profile's map, dropping the profile account's Consumer Terms confirmation. Every new terminal then made Claude wait on a network check before starting. Merge groveChoiceSeenAt per account like projects and mcpServers, and keep whichever timestamp is newer for accounts present on both sides. Fixes #40380 Co-authored-by: Neil <neil@stably.ai>
This commit is contained in:
@@ -150,6 +150,7 @@ describe('Claude profile refresh from the default home', () => {
|
||||
firstStartTime: 'source-start',
|
||||
firstStartVersion: '1.0.0',
|
||||
groveConfigCache: { a: 1 },
|
||||
groveChoiceSeenAt: { 'account-a': 99, 'account-b': 10 },
|
||||
cachedArtifactRoster: [],
|
||||
clientDataCacheSlots: {},
|
||||
passesEligibilityCache: {},
|
||||
@@ -163,7 +164,10 @@ describe('Claude profile refresh from the default home', () => {
|
||||
subscriptionNoticeCount: 2
|
||||
})
|
||||
expect((await provision(f)).surfaces['.claude.json']).toBe('synced')
|
||||
expect(f.read(join(f.profileHome, '.claude.json'))).toEqual(shared)
|
||||
expect(f.read(join(f.profileHome, '.claude.json'))).toEqual({
|
||||
...shared,
|
||||
groveChoiceSeenAt: { 'account-a': 99, 'account-b': 10 }
|
||||
})
|
||||
expect(fs.readdirSync(f.profileHome).filter((name) => name.endsWith('.tmp'))).toEqual([])
|
||||
expect(fs.existsSync(join(f.profileHome, '.credentials.json'))).toBe(false)
|
||||
|
||||
@@ -172,6 +176,7 @@ describe('Claude profile refresh from the default home', () => {
|
||||
oauthAccount: { emailAddress: 'profile@example.com' },
|
||||
userID: 'profile-id',
|
||||
groveConfigCache: { b: 2 },
|
||||
groveChoiceSeenAt: { 'account-a': 120, 'account-b': 5 },
|
||||
theme: 'light',
|
||||
onlyHere: true
|
||||
})
|
||||
@@ -180,6 +185,7 @@ describe('Claude profile refresh from the default home', () => {
|
||||
oauthAccount: { emailAddress: 'profile@example.com' },
|
||||
userID: 'profile-id',
|
||||
groveConfigCache: { b: 2 },
|
||||
groveChoiceSeenAt: { 'account-a': 120, 'account-b': 10 },
|
||||
onlyHere: true,
|
||||
...shared
|
||||
})
|
||||
|
||||
@@ -153,8 +153,12 @@ function isAccountBoundState(key: string): boolean {
|
||||
)
|
||||
}
|
||||
|
||||
// Preserve account-only project and server entries during merging.
|
||||
const MERGED_BY_ENTRY: ReadonlySet<string> = new Set(['projects', 'mcpServers'])
|
||||
// Merge per entry so a profile keeps its own projects, servers, and Grove confirmations.
|
||||
const MERGED_BY_ENTRY: ReadonlySet<string> = new Set([
|
||||
'projects',
|
||||
'mcpServers',
|
||||
'groveChoiceSeenAt'
|
||||
])
|
||||
|
||||
function isPlainRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||
@@ -174,6 +178,15 @@ function mergeEntries(key: string, current: unknown, source: unknown): unknown {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (key === 'groveChoiceSeenAt') {
|
||||
// Claude trusts a confirmation only while it is fresh, so keep each account's newest one.
|
||||
for (const [account, seenAt] of Object.entries(current)) {
|
||||
const theirs = source[account]
|
||||
if (typeof seenAt === 'number' && (typeof theirs !== 'number' || seenAt > theirs)) {
|
||||
merged[account] = seenAt
|
||||
}
|
||||
}
|
||||
}
|
||||
return merged
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user