f27d45e288
* feat(tui): Ctrl+O opens the model picker without clearing your draft Reaching the model picker meant typing /model, which forces you to wipe whatever you'd already drafted. Bind Ctrl+O to open the same picker overlay directly, leaving the composer untouched. Ctrl+O is added to the textInput pass-through allowlist so the composer doesn't swallow it, mirroring the existing Ctrl+X session-switcher path. * feat(tui): apply a mid-turn model switch at the next turn instead of rejecting it Picking a model while a turn was streaming hit a 4009 'session busy' reject: switch_model() mutates the agent's model/provider/base_url/client in place and the worker thread reads those every iteration. Now config.set queues the pick in session[pending_model_switch] and _apply_pending_model_switch applies it on the turn thread at the next turn start, before any model call — no race, no interrupt, no waiting on the client rebuild. The TUI paints the pick optimistically and notes '(applies next turn)'.
54 lines
2.6 KiB
TypeScript
54 lines
2.6 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { shouldPassThroughToGlobalHandler, shouldPreserveCtrlJNewline } from '../components/textInput.js'
|
|
import { DEFAULT_VOICE_RECORD_KEY, parseVoiceRecordKey } from '../lib/platform.js'
|
|
|
|
const key = (overrides: Record<string, unknown> = {}) => ({ ctrl: false, meta: false, ...overrides }) as any
|
|
|
|
describe('shouldPreserveCtrlJNewline', () => {
|
|
it('preserves Ctrl+J as newline in Ghostty even when tmux masks TERM/TERM_PROGRAM', () => {
|
|
expect(
|
|
shouldPreserveCtrlJNewline({
|
|
GHOSTTY_RESOURCES_DIR: '/usr/share/ghostty',
|
|
TERM: 'tmux-256color',
|
|
TERM_PROGRAM: 'tmux'
|
|
})
|
|
).toBe(true)
|
|
})
|
|
|
|
it('keeps bare local POSIX LF-compatible prompts submitting on Ctrl+J', () => {
|
|
expect(shouldPreserveCtrlJNewline({ TERM: 'xterm-256color' })).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('shouldPassThroughToGlobalHandler', () => {
|
|
it('passes through the configured voice shortcut while composer is focused', () => {
|
|
expect(shouldPassThroughToGlobalHandler('o', key({ ctrl: true }), parseVoiceRecordKey('ctrl+o'))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('r', key({ meta: true }), parseVoiceRecordKey('alt+r'))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler(' ', key({ ctrl: true }), parseVoiceRecordKey('ctrl+space'))).toBe(true)
|
|
expect(
|
|
shouldPassThroughToGlobalHandler('', key({ ctrl: true, return: true }), parseVoiceRecordKey('ctrl+enter'))
|
|
).toBe(true)
|
|
})
|
|
|
|
it('keeps the legacy default pass-through when no custom key is provided', () => {
|
|
expect(shouldPassThroughToGlobalHandler('b', key({ ctrl: true }), DEFAULT_VOICE_RECORD_KEY)).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('b', key({ ctrl: true }))).toBe(true)
|
|
})
|
|
|
|
it('does not swallow ordinary typing keys', () => {
|
|
expect(shouldPassThroughToGlobalHandler('h', key(), parseVoiceRecordKey('ctrl+o'))).toBe(false)
|
|
expect(shouldPassThroughToGlobalHandler('o', key(), parseVoiceRecordKey('ctrl+o'))).toBe(false)
|
|
})
|
|
|
|
it('always passes through non-voice global control keys', () => {
|
|
expect(shouldPassThroughToGlobalHandler('c', key({ ctrl: true }))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('x', key({ ctrl: true }))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('o', key({ ctrl: true }))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('', key({ escape: true }))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('', key({ tab: true }))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('', key({ pageUp: true }))).toBe(true)
|
|
expect(shouldPassThroughToGlobalHandler('', key({ pageDown: true }))).toBe(true)
|
|
})
|
|
})
|