feat(subagent): open a child's chat in the native right sidebar
CI / ci (pull_request) Canceled after 0s
CI / ci-windows (pull_request) Canceled after 0s
CI / plugin-mount (pull_request) Canceled after 0s

The host's own catalog puts an "open beside" action on every non-current
child row; this port had never wired it. Add it: the row grows a hover
button that opens the child's chat as a `subagentchat` resource in the
native right Sidebar, so a user can watch a child work without giving up
the pane he is in (the in-pane jump stays the plain row click).

- src/client/native/subagent-chat.ts: the resource-address codec, copied
  from @deepseek-ai/dsh-client-ui-subagent rather than imported (the
  package exports no helpers and the plugin must not reach into it).
- native/surface.ts: carry `kind` / `preferNewPane` on an open.
- SubagentView: `openChildAside` via `ctx.get?.('sidebarRight')` — an
  optional probe, since a fake ctx without `get` otherwise crashes the
  whole render (9 specs caught it) — threaded through all three
  CatalogRows call sites.
- locales: `subagentOpenAside` in zh/en plus all 20 third-language
  dictionaries (tests/locales.spec.ts enforces key-set parity).
- docs: the conventions page now documents the resource-open recipe.

Gates: typecheck / lint / build / test 132 files 1390 passed /
check:consumer-types, plus the repo's runtime-contract symbol check.
This commit is contained in:
figmar
2026-10-14 09:32:16 +08:00
parent 35d33c7f65
commit 6b4a29ba24
27 changed files with 220 additions and 7 deletions
+52
View File
@@ -0,0 +1,52 @@
/**
* The `subagentchat` resource address must stay byte-compatible with the host's
* own codec: `@deepseek-ai/dsh-client-ui-subagent` parses what we emit, so a
* different query order or an unescaped child id would silently open the wrong
* page (or none).
*/
import { describe, expect, it } from 'vitest'
import {
SUBAGENT_CHAT_ADDRESS,
SUBAGENT_CHAT_KIND,
subagentChatAddress,
} from '../src/client/native/subagent-chat.ts'
describe('subagentChatAddress', () => {
it("emits the canonical form with parent and mode", () => {
expect(subagentChatAddress({
parentSessionId: 'parent-1',
childSessionId: 'child-2',
mode: 'one-shot',
})).toBe('dsh-resource://subagentchat/session/child-2?parent=parent-1&mode=one-shot')
})
it('keeps a continuable mode verbatim', () => {
expect(subagentChatAddress({
parentSessionId: 'p',
childSessionId: 'c',
mode: 'continuable',
})).toContain('mode=continuable')
})
it('percent-encodes a child id so the address stays one path segment', () => {
const address = subagentChatAddress({
parentSessionId: 'p',
childSessionId: 'child/with:odd chars',
mode: 'one-shot',
})
expect(address).toContain('/child%2Fwith%3Aodd%20chars?')
})
it('never leaks the parent into the path (it is a routing query only)', () => {
const address = subagentChatAddress({
parentSessionId: 'p secret',
childSessionId: 'c',
mode: 'one-shot',
})
expect(address.split('?')[0]).toBe(`${SUBAGENT_CHAT_ADDRESS}c`)
})
it('names the page kind the native Sidebar roots these pages under', () => {
expect(SUBAGENT_CHAT_KIND).toBe('subagentchat')
})
})