mirror of
https://github.com/stablyai/orca.git
synced 2026-11-04 11:07:42 +00:00
* Add chat contrast and terminal interface matching * Fix matching chat palettes and contrast controls * Verify rebased appearance settings and preserve slider focus * Memoize chat appearance and narrow settings subscriptions * Wrap native chat tool-run summaries in the terminal font * Use the matched chat foreground for inherited controls * fix(native-chat): bound collapsed tool summaries * Restore code foreground token for matched chat themes * Reset all chat appearance controls through serialized writer * Make terminal matching control chat size and contrast * Verify terminal match controls on Chat settings page * Share native chat appearance store selection * Align matched chat palette test with full-strength foreground * Keep tool-run header marks on the summary's first line A wrapped two-line summary centered the leading icon, failure count, check, and chevron between its lines. The header now top-aligns its items and gives each mark a one-line-tall slot, so marks sit on line 1 and line 2 wraps under the text. * Explain terminal-matched chat controls on hover While Match terminal interface is on, Contrast, Text size and Code text size are disabled. Hovering any of them now shows a tooltip saying the chat is matching the terminal interface and how to change it. Disabled controls drop hover events, so an enabled wrapper carries the tooltip; with matching off the controls render exactly as before. * Name the tool-run alignment test case by summary length
131 lines
4.3 KiB
TypeScript
131 lines
4.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
normalizeNativeChatAppearanceSettings,
|
|
resetNativeChatAppearanceSettings,
|
|
resolveNativeChatAppearanceSettings
|
|
} from './native-chat-appearance-settings'
|
|
|
|
describe('native chat appearance normalization', () => {
|
|
it('preserves unknown future fields while normalizing only known fields', () => {
|
|
const future = {
|
|
futureSetting: { nested: 'keep' }
|
|
}
|
|
expect(
|
|
normalizeNativeChatAppearanceSettings({
|
|
...future,
|
|
contrast: 151,
|
|
matchTerminalInterface: true,
|
|
fontSize: 99,
|
|
codeFontSize: 12,
|
|
width: 'comfortable'
|
|
})
|
|
).toEqual({ ...future, fontSize: 20, contrast: 150, matchTerminalInterface: true })
|
|
expect(normalizeNativeChatAppearanceSettings(future)).toEqual(future)
|
|
})
|
|
|
|
it('preserves future fields without letting known defaults or malformed values survive', () => {
|
|
const future = { futureSetting: { nested: 'keep' } }
|
|
for (const contrast of [100, Number.NaN, Number.POSITIVE_INFINITY, '150', null]) {
|
|
for (const matchTerminalInterface of [false, 'true', null]) {
|
|
expect(
|
|
normalizeNativeChatAppearanceSettings({
|
|
...future,
|
|
contrast,
|
|
matchTerminalInterface
|
|
})
|
|
).toEqual(future)
|
|
}
|
|
}
|
|
})
|
|
|
|
it('derives defaults without storing them', () => {
|
|
expect(
|
|
normalizeNativeChatAppearanceSettings({
|
|
fontSize: 14,
|
|
codeFontSize: 12,
|
|
width: 'comfortable'
|
|
})
|
|
).toBeUndefined()
|
|
expect(resolveNativeChatAppearanceSettings(undefined)).toEqual({
|
|
fontSize: 14,
|
|
codeFontSize: 12,
|
|
width: 'comfortable',
|
|
contrast: 100,
|
|
matchTerminalInterface: false
|
|
})
|
|
})
|
|
it('resets all five known controls while keeping settings from a newer version', () => {
|
|
const fromNewerVersion = {
|
|
fontSize: 18,
|
|
codeFontSize: 16,
|
|
width: 'wide' as const,
|
|
contrast: 151,
|
|
matchTerminalInterface: true,
|
|
futureSetting: { nested: 'keep' }
|
|
}
|
|
expect(resetNativeChatAppearanceSettings(fromNewerVersion)).toEqual({
|
|
futureSetting: { nested: 'keep' }
|
|
})
|
|
expect(resetNativeChatAppearanceSettings({ fontSize: 18 })).toBeUndefined()
|
|
})
|
|
it('clamps and rounds values on read', () => {
|
|
expect(
|
|
resolveNativeChatAppearanceSettings({ fontSize: 99, codeFontSize: 0, width: 'full' })
|
|
).toEqual({
|
|
fontSize: 20,
|
|
codeFontSize: 10,
|
|
width: 'full',
|
|
contrast: 100,
|
|
matchTerminalInterface: false
|
|
})
|
|
expect(
|
|
normalizeNativeChatAppearanceSettings({ fontSize: 15.6, codeFontSize: 13.2, width: 'wide' })
|
|
).toEqual({ fontSize: 16, codeFontSize: 13, width: 'wide' })
|
|
})
|
|
it('falls back safely for malformed persisted data', () => {
|
|
for (const value of [
|
|
null,
|
|
false,
|
|
'large',
|
|
{},
|
|
{ fontSize: Number.NaN, codeFontSize: Number.POSITIVE_INFINITY, width: 'giant' },
|
|
{ fontSize: '20' }
|
|
]) {
|
|
expect(normalizeNativeChatAppearanceSettings(value)).toBeUndefined()
|
|
}
|
|
})
|
|
})
|
|
|
|
describe('chat contrast and terminal interface normalization', () => {
|
|
it('removes default fields and the empty object', () => {
|
|
expect(
|
|
normalizeNativeChatAppearanceSettings({ contrast: 100, matchTerminalInterface: false })
|
|
).toBeUndefined()
|
|
expect(
|
|
normalizeNativeChatAppearanceSettings({
|
|
fontSize: 16,
|
|
contrast: 100,
|
|
matchTerminalInterface: false
|
|
})
|
|
).toEqual({ fontSize: 16 })
|
|
expect(
|
|
normalizeNativeChatAppearanceSettings({
|
|
codeFontSize: 13,
|
|
contrast: 120,
|
|
matchTerminalInterface: true
|
|
})
|
|
).toEqual({ codeFontSize: 13, contrast: 120, matchTerminalInterface: true })
|
|
})
|
|
|
|
it('clamps and rounds persisted contrast, accepting only an explicit true toggle', () => {
|
|
expect(
|
|
resolveNativeChatAppearanceSettings({ contrast: 999, matchTerminalInterface: 'true' })
|
|
).toMatchObject({ contrast: 150, matchTerminalInterface: false })
|
|
expect(normalizeNativeChatAppearanceSettings({ contrast: -5 })).toEqual({ contrast: 50 })
|
|
expect(normalizeNativeChatAppearanceSettings({ contrast: 120.6 })).toEqual({ contrast: 121 })
|
|
for (const contrast of [Number.NaN, Number.POSITIVE_INFINITY, '150', null]) {
|
|
expect(normalizeNativeChatAppearanceSettings({ contrast })).toBeUndefined()
|
|
}
|
|
})
|
|
})
|