fix(native-chat): a non-string host id no longer crashes the terminal workbench (#43499)

* fix(execution-host): a non-string saved host id no longer crashes the terminal workbench

Crash d1e50ca3 (1.4.259, Windows): rendering a chat name passed a non-string
executionHostId into normalizeHostPart, which threw 'e?.trim is not a function'
and took down the terminal workbench boundary. Treat it as absent, as blank is.

* fix(execution-host): take unknown at the host-id parse boundary instead of casting in the test

* fix(execution-host): a repo with a non-string host id no longer proves it is local

* fix(native-chat): guard only the chat-name host lookup, not the shared host-id parser

Reviewers found that making the shared parser read a non-string as absent turns it
into 'local' for worktree removal and trash cleanup, which could act on this
machine's disk. Restore the shared parser and check the type at the one render path
the crash report hit.
This commit is contained in:
Brennan Benson
2026-11-17 00:48:17 -08:00
committed by GitHub
parent c63a855bcc
commit 331c5922fe
2 changed files with 13 additions and 2 deletions
@@ -0,0 +1,10 @@
import { describe, expect, it } from 'vitest'
import { structuredAgentSessionTargetForHost } from './structured-agent-session-owner'
describe('structuredAgentSessionTargetForHost', () => {
// A non-string host id reached render and threw `e?.trim is not a function` (crash d1e50ca3).
it('serves no runtime for a non-string host id instead of throwing', () => {
expect(structuredAgentSessionTargetForHost(42)).toBeNull()
expect(structuredAgentSessionTargetForHost({ id: 'local' })).toBeNull()
})
})
@@ -27,9 +27,10 @@ import type { RuntimeClientTarget } from '../../../../../shared/remote-runtime/h
* runtime serves: an SSH host, or the catalog's unresolved-owner sentinel.
*/
export function structuredAgentSessionTargetForHost(
executionHostId: string | null | undefined
executionHostId: unknown
): RuntimeClientTarget | null {
const host = parseExecutionHostId(executionHostId)
// Render reads unchecked tab and wire stamps: a non-string owner has no runtime, not a crash.
const host = typeof executionHostId === 'string' ? parseExecutionHostId(executionHostId) : null
return host ? runtimeRpcTargetForAuthorityKey(host.id) : null
}