Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .dsh-plugin/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions .dsh-plugin/client/GalView.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** GAL 视窗顶层:模式切换 + 游戏模式(舞台/控制条/输入/历史/设置)+ 编辑模式。
* 数据来源:useSession(会话快照 nodes/partial/running/blank)、useScene(场景)、
* 数据来源:useChat(对话快照 legacy nodes/partial/runningCalls)、
* useSession(会话生命周期 running/blank/pending/promptError)、useScene(场景)、
* inputActions(发送走宿主输入机,与普通输入框同一管线)。
*/

Expand Down Expand Up @@ -152,19 +153,19 @@ function useFillSessionArea(rootRef) {

/**
* GAL 视窗组件(conversation.view 槽位条目)。
* @param props - 槽位框架注入:sessionId/useSession/useInput/inputActions + inject 面的 useScene/useHistory/api。
* @param props - 槽位框架注入:sessionId/useSession/useChat/useInput/inputActions + inject 面的 useScene/useHistory/api。
*/
export function GalView({ useSession, inputActions, useScene, useHistory, useAssets, useFonts, useStore, actions, api }) {
export function GalView({ useSession, useChat, inputActions, useScene, useHistory, useAssets, useFonts, useStore, actions, api }) {
const scene = useScene(s => s)
const history = useHistory(h => h)
const assets = useAssets(a => a)
const fonts = useFonts(f => f)
const readState = useStore(s => s)
const nodes = useSession(s => s.nodes)
const partial = useSession(s => s.partial)
const nodes = useChat(s => s.legacy.nodes)
const partial = useChat(s => s.legacy.partial)
const runningCalls = useChat(s => s.legacy.runningCalls)
const running = useSession(s => s.running)
const blank = useSession(s => s.blank)
const runningCalls = useSession(s => s.runningCalls)
const pending = useSession(s => s.pending)
const promptError = useSession(s => s.promptError)

Expand Down
30 changes: 24 additions & 6 deletions scripts/smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,40 @@ async function pageTestPhase1() {
const sessionState = {
current: {
sessionId: 'session-1',
nodes: [
{ kind: 'user', seq: 1, content: [{ type: 'text', text: '你好' }], source: null },
{ kind: 'assistant', seq: 2, turn: 1, step: 1, blocks: [{ kind: 'text', text: '……你终于来了。欢迎回来。' }] },
],
partial: null,
running: false,
blank: false,
pending: [],
promptError: null,
},
}
const chatState = {
current: {
legacy: {
nodes: [
{ kind: 'user', seq: 1, content: [{ type: 'text', text: '你好' }], source: null },
{ kind: 'assistant', seq: 2, turn: 1, step: 1, blocks: [{ kind: 'text', text: '……你终于来了。欢迎回来。' }] },
],
partial: null,
runningCalls: [],
},
},
}
const sessionListeners = new Set()
const chatListeners = new Set()
const sessionSource = {
getSnapshot: () => sessionState.current,
subscribe(fn) { sessionListeners.add(fn); return () => { sessionListeners.delete(fn) } },
}
const chatSource = {
getSnapshot: () => chatState.current,
subscribe(fn) { chatListeners.add(fn); return () => { chatListeners.delete(fn) } },
}
window.__setSession = next => {
sessionState.current = next
const { nodes = [], partial = null, runningCalls = [], ...session } = next
sessionState.current = session
chatState.current = { legacy: { nodes, partial, runningCalls } }
for (const fn of [...sessionListeners]) fn()
for (const fn of [...chatListeners]) fn()
}

const React = window.React
Expand All @@ -142,6 +159,7 @@ async function pageTestPhase1() {
const props = {
sessionId: 'session-1',
useSession: bindHook(sessionSource),
useChat: bindHook(chatSource),
useInput: bindHook({ getSnapshot: () => ({ draft: '' }), subscribe: () => () => {} }),
inputActions,
useScene: bindHook(sceneSource),
Expand Down