fix: model et al selection on enter
This commit is contained in:
@@ -731,7 +731,8 @@ function parseKeypress(s: string = ''): ParsedKey {
|
|||||||
key.raw = undefined
|
key.raw = undefined
|
||||||
key.name = 'return'
|
key.name = 'return'
|
||||||
} else if (s === '\n') {
|
} else if (s === '\n') {
|
||||||
key.name = 'enter'
|
key.raw = undefined
|
||||||
|
key.name = 'return'
|
||||||
} else if (s === '\t') {
|
} else if (s === '\t') {
|
||||||
key.name = 'tab'
|
key.name = 'tab'
|
||||||
} else if (s === '\b' || s === '\x1b\b') {
|
} else if (s === '\b' || s === '\x1b\b') {
|
||||||
|
|||||||
@@ -406,6 +406,7 @@ function TranscriptScrollbar({ scrollRef, t }: { scrollRef: RefObject<ScrollBoxH
|
|||||||
if (!s || !scrollable) {
|
if (!s || !scrollable) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
s.scrollTo(Math.round((Math.max(0, Math.min(travel, row - offset)) / travel) * Math.max(0, total - vp)))
|
s.scrollTo(Math.round((Math.max(0, Math.min(travel, row - offset)) / travel) * Math.max(0, total - vp)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,6 +559,28 @@ export function App({ gw }: { gw: GatewayClient }) {
|
|||||||
const { historyRef, historyIdx, setHistoryIdx, historyDraftRef, pushHistory } = useInputHistory()
|
const { historyRef, historyIdx, setHistoryIdx, historyDraftRef, pushHistory } = useInputHistory()
|
||||||
const { completions, compIdx, setCompIdx, compReplace } = useCompletion(input, blocked(), gw)
|
const { completions, compIdx, setCompIdx, compReplace } = useCompletion(input, blocked(), gw)
|
||||||
|
|
||||||
|
const applyCompletion = useCallback(
|
||||||
|
(value = input) => {
|
||||||
|
const row = completions[compIdx]
|
||||||
|
|
||||||
|
if (!row?.text) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const text = value.startsWith('/') && row.text.startsWith('/') && compReplace > 0 ? row.text.slice(1) : row.text
|
||||||
|
const next = value.slice(0, compReplace) + text
|
||||||
|
|
||||||
|
if (next === value) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
setInput(next)
|
||||||
|
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
[compIdx, compReplace, completions, input]
|
||||||
|
)
|
||||||
|
|
||||||
const pulseReasoningStreaming = useCallback(() => {
|
const pulseReasoningStreaming = useCallback(() => {
|
||||||
if (reasoningStreamingTimerRef.current) {
|
if (reasoningStreamingTimerRef.current) {
|
||||||
clearTimeout(reasoningStreamingTimerRef.current)
|
clearTimeout(reasoningStreamingTimerRef.current)
|
||||||
@@ -1480,12 +1503,7 @@ export function App({ gw }: { gw: GatewayClient }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (key.tab && completions.length) {
|
if (key.tab && completions.length) {
|
||||||
const row = completions[compIdx]
|
applyCompletion()
|
||||||
|
|
||||||
if (row?.text) {
|
|
||||||
const text = input.startsWith('/') && row.text.startsWith('/') && compReplace > 0 ? row.text.slice(1) : row.text
|
|
||||||
setInput(input.slice(0, compReplace) + text)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -3122,6 +3140,17 @@ export function App({ gw }: { gw: GatewayClient }) {
|
|||||||
[dequeue, dispatchSubmission, inputBuf, sid]
|
[dequeue, dispatchSubmission, inputBuf, sid]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const submitOrComplete = useCallback(
|
||||||
|
(value: string) => {
|
||||||
|
if (value.startsWith('/') && completions.length && applyCompletion(value)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
submit(value)
|
||||||
|
},
|
||||||
|
[applyCompletion, completions.length, submit]
|
||||||
|
)
|
||||||
|
|
||||||
// ── Derived ──────────────────────────────────────────────────────
|
// ── Derived ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
const statusColor =
|
const statusColor =
|
||||||
@@ -3389,7 +3418,7 @@ export function App({ gw }: { gw: GatewayClient }) {
|
|||||||
columns={Math.max(20, cols - 3)}
|
columns={Math.max(20, cols - 3)}
|
||||||
onChange={setInput}
|
onChange={setInput}
|
||||||
onPaste={handleTextPaste}
|
onPaste={handleTextPaste}
|
||||||
onSubmit={submit}
|
onSubmit={submitOrComplete}
|
||||||
placeholder={empty ? PLACEHOLDER : busy ? 'Ctrl+C to interrupt…' : ''}
|
placeholder={empty ? PLACEHOLDER : busy ? 'Ctrl+C to interrupt…' : ''}
|
||||||
value={input}
|
value={input}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user