Keep migrated mobile shortcut order canonical (#4349)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo Hong
2026-05-31 20:48:34 -07:00
committed by GitHub
co-authored by Orca
parent a34a6bec7e
commit b555e66598
2 changed files with 12 additions and 7 deletions
@@ -105,16 +105,16 @@ describe('terminal accessory layout', () => {
).toEqual(['escape'])
})
it('migrates Space into old personalized layouts without reordering existing visible keys', () => {
it('migrates Space into old personalized layouts using current built-in order', () => {
const oldBuiltInIds = oldBuiltInIdsBeforeSpace()
expect(
normalizeTerminalAccessoryLayoutPreference({
version: 1,
visibleBuiltInIds: ['tab', 'enter', 'shiftTab'],
visibleBuiltInIds: ['escape', 'tab', 'enter', 'shiftTab', 'backspace', 'delete'],
knownBuiltInIds: oldBuiltInIds
}).visibleBuiltInIds
).toEqual(['tab', 'enter', 'shiftTab', 'space'])
).toEqual(['escape', 'tab', 'enter', 'shiftTab', 'space', 'backspace', 'delete'])
})
it('shows Space once for an all-hidden old layout', () => {
@@ -38,6 +38,11 @@ function dedupeKnownIds(ids: string[], builtInSet: Set<string>): string[] {
return out
}
function orderBuiltInIds(ids: Set<string>, currentBuiltInIds: string[]): string[] {
// Why: migrated terminal bars should match the Settings -> Terminal order.
return currentBuiltInIds.filter((id) => ids.has(id))
}
export function getDefaultTerminalAccessoryBuiltInIds(): string[] {
return builtInIds()
}
@@ -60,17 +65,17 @@ export function normalizeTerminalAccessoryLayoutPreference(
const builtInSet = new Set(currentBuiltInIds)
const knownInputSet = new Set(knownInput.filter((id) => builtInSet.has(id)))
const visibleBuiltInIds = dedupeKnownIds(visibleInput, builtInSet)
const visibleBuiltInSet = new Set(dedupeKnownIds(visibleInput, builtInSet))
for (const id of currentBuiltInIds) {
if (!knownInputSet.has(id) && !visibleBuiltInIds.includes(id)) {
visibleBuiltInIds.push(id)
if (!knownInputSet.has(id)) {
visibleBuiltInSet.add(id)
}
}
return {
version: 1,
visibleBuiltInIds,
visibleBuiltInIds: orderBuiltInIds(visibleBuiltInSet, currentBuiltInIds),
knownBuiltInIds: [...currentBuiltInIds]
}
}