Merge branch 'main' into bb/gui
This commit is contained in:
@@ -379,11 +379,11 @@ describe('createGatewayEventHandler', () => {
|
||||
const handler = createGatewayEventHandler(ctx)
|
||||
|
||||
handler({
|
||||
payload: { message: 'Chrome launched and listening on port 9222' },
|
||||
payload: { message: 'Chromium-family browser launched and listening on port 9222' },
|
||||
type: 'browser.progress'
|
||||
} as any)
|
||||
|
||||
expect(ctx.system.sys).toHaveBeenCalledWith('Chrome launched and listening on port 9222')
|
||||
expect(ctx.system.sys).toHaveBeenCalledWith('Chromium-family browser launched and listening on port 9222')
|
||||
})
|
||||
|
||||
it('annotates gateway.start_timeout with stderr tail lines so users can diagnose without /logs', () => {
|
||||
|
||||
@@ -387,8 +387,8 @@ describe('createSlashHandler', () => {
|
||||
Promise.resolve({
|
||||
connected: false,
|
||||
messages: [
|
||||
"Chrome isn't running with remote debugging — attempting to launch...",
|
||||
'Browser not connected — start Chrome with remote debugging and retry /browser connect'
|
||||
"Chromium-family browser isn't running with remote debugging — attempting to launch...",
|
||||
'Browser not connected — start a Chromium-family browser with remote debugging and retry /browser connect'
|
||||
],
|
||||
url: 'http://127.0.0.1:9222'
|
||||
})
|
||||
@@ -397,14 +397,14 @@ describe('createSlashHandler', () => {
|
||||
const ctx = buildCtx({ gateway: { ...buildGateway(), rpc } })
|
||||
|
||||
expect(createSlashHandler(ctx)('/browser connect')).toBe(true)
|
||||
expect(ctx.transcript.sys).toHaveBeenCalledWith('checking Chrome remote debugging at http://127.0.0.1:9222...')
|
||||
expect(ctx.transcript.sys).toHaveBeenCalledWith('checking Chromium-family browser remote debugging at http://127.0.0.1:9222...')
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(ctx.transcript.sys).toHaveBeenCalledWith(
|
||||
"Chrome isn't running with remote debugging — attempting to launch..."
|
||||
"Chromium-family browser isn't running with remote debugging — attempting to launch..."
|
||||
)
|
||||
expect(ctx.transcript.sys).toHaveBeenCalledWith(
|
||||
'Browser not connected — start Chrome with remote debugging and retry /browser connect'
|
||||
'Browser not connected — start a Chromium-family browser with remote debugging and retry /browser connect'
|
||||
)
|
||||
expect(ctx.transcript.sys).not.toHaveBeenCalledWith('browser connect failed')
|
||||
})
|
||||
|
||||
@@ -21,11 +21,26 @@ describe('splitReasoning', () => {
|
||||
expect(text).toBe('body')
|
||||
})
|
||||
|
||||
it('treats unclosed trailing <think>… as reasoning', () => {
|
||||
const { reasoning, text } = splitReasoning('answer start <think>still deciding')
|
||||
it('treats unclosed leading <think>… as reasoning (real reasoning-model stream)', () => {
|
||||
const { reasoning, text } = splitReasoning('<think>still deciding')
|
||||
|
||||
expect(reasoning).toBe('still deciding')
|
||||
expect(text).toBe('answer start')
|
||||
expect(text).toBe('')
|
||||
})
|
||||
|
||||
it('does not strip trailing prose after a stray mid-text <think> mention', () => {
|
||||
// Regression for "TUI eats last paragraph of output": when the model
|
||||
// emits a literal `<think>` somewhere in prose (quoted explanation, code
|
||||
// example, partial stream-mid-tag), the trailing greedy unclosed-tag
|
||||
// regex used to consume every paragraph after it. Real unclosed
|
||||
// reasoning blocks always lead the message — anchor to ^ so prose
|
||||
// mentions are preserved.
|
||||
const { reasoning, text } = splitReasoning(
|
||||
'final answer paragraph one.\n\n<think>internal note never closed\n\nfinal answer paragraph two.'
|
||||
)
|
||||
|
||||
expect(reasoning).toBe('')
|
||||
expect(text).toBe('final answer paragraph one.\n\n<think>internal note never closed\n\nfinal answer paragraph two.')
|
||||
})
|
||||
|
||||
it('returns empty reasoning and untouched text when no tags present', () => {
|
||||
|
||||
@@ -155,7 +155,7 @@ export const opsCommands: SlashCommand[] = [
|
||||
const url = action === 'connect' ? rest.join(' ').trim() || 'http://127.0.0.1:9222' : undefined
|
||||
|
||||
if (url) {
|
||||
ctx.transcript.sys(`checking Chrome remote debugging at ${url}...`)
|
||||
ctx.transcript.sys(`checking Chromium-family browser remote debugging at ${url}...`)
|
||||
}
|
||||
|
||||
ctx.gateway
|
||||
@@ -181,7 +181,7 @@ export const opsCommands: SlashCommand[] = [
|
||||
}
|
||||
|
||||
if (r.connected) {
|
||||
ctx.transcript.sys('Browser connected to live Chrome via CDP')
|
||||
ctx.transcript.sys('Browser connected to live Chromium-family browser via CDP')
|
||||
ctx.transcript.sys(`Endpoint: ${r.url || '(url unavailable)'}`)
|
||||
ctx.transcript.sys('next browser tool call will use this CDP endpoint')
|
||||
}
|
||||
|
||||
@@ -21,7 +21,12 @@ export function splitReasoning(input: string): SplitReasoning {
|
||||
return ''
|
||||
})
|
||||
|
||||
const unclosed = new RegExp(`<${tag}>([\\s\\S]*)$`, 'i')
|
||||
// Anchor to start-of-input so a literal `<think>` mid-prose (model quoting
|
||||
// the word, code blocks containing the tag, etc.) doesn't eat every
|
||||
// paragraph after it. Real unclosed reasoning blocks always lead the
|
||||
// message — that's how reasoning models stream. See test
|
||||
// "does not strip trailing prose after a stray mid-text <think> mention".
|
||||
const unclosed = new RegExp(`^\\s*<${tag}>([\\s\\S]*)$`, 'i')
|
||||
text = text.replace(unclosed, (_m, inner: string) => {
|
||||
const trimmed = inner.trim()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user