diff --git a/packages/client/src/utils.ts b/packages/client/src/utils.ts index 2cf552b..c465848 100644 --- a/packages/client/src/utils.ts +++ b/packages/client/src/utils.ts @@ -93,8 +93,10 @@ export const filterSessions = (sessions: WebSession[], query: string): WebSessio sessions.filter((session) => matchesQuery(session, query)); export const filterEntries = (entries: WebEntry[], filter: Filter): WebEntry[] => { + // 压缩摘要等 system 输出只写入历史供上下文使用,不在界面上展示 + const visible = entries.filter((entry) => entryRole(entry) !== 'system'); if (filter === 'all') { - return entries; + return visible; } - return entries.filter((entry) => entryRole(entry) === filter); + return visible.filter((entry) => entryRole(entry) === filter); }; diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 3cbc1a6..5272177 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -66,7 +66,8 @@ export const startServer = async ( const port = config.port ?? Number(process.env.CALL_CODE_WEB_PORT ?? 4173); - const host = config.host ?? "127.0.0.1"; + const host = + config.host ?? process.env.CALL_CODE_WEB_HOST ?? "127.0.0.1"; const clientDir = config.clientDir; const handle = await startWebServer({ diff --git a/tests/client-ui.spec.ts b/tests/client-ui.spec.ts index c370f5a..9629d78 100644 --- a/tests/client-ui.spec.ts +++ b/tests/client-ui.spec.ts @@ -140,6 +140,38 @@ describe("client MainPanel", () => { expect(html).toContain('aria-label="压缩会话上下文" disabled=""'); }); + it("不渲染 system 输出(压缩摘要)", () => { + const session = makeSession({ + entries: [ + ...makeSession().entries, + { + seq: 3, + id: "e3", + parentId: null, + type: "compaction", + role: "system", + timestamp: "2026-08-05T00:00:00.000Z", + text: "手动压缩摘要", + payload: { summary: "手动压缩摘要" }, + }, + ], + }); + const html = renderToStaticMarkup( + React.createElement(MainPanel, { + session, + filter: "all", + onFilterChange: () => undefined, + onDeleteEntry: () => undefined, + chatStatus: { status: "idle" }, + onSendMessage: () => true, + onCompactSession: () => undefined, + }), + ); + + expect(html).not.toContain("手动压缩摘要"); + expect(html).not.toContain(">系统<"); + }); + it("没有会话时禁用压缩入口", () => { const html = renderToStaticMarkup( React.createElement(MainPanel, { diff --git a/tests/client-utils.spec.ts b/tests/client-utils.spec.ts index cc18525..c01f42f 100644 --- a/tests/client-utils.spec.ts +++ b/tests/client-utils.spec.ts @@ -122,4 +122,22 @@ describe('client utils', () => { expect(filterEntries(entries, 'tool')).toEqual([entries[2]]); expect(filterEntries(entries, 'system')).toEqual([]); }); + + it('全部视图不展示 system 输出', () => { + const entries = [ + makeEntry({ id: 'u1', type: 'user', role: 'user' }), + makeEntry({ + id: 'c1', + type: 'compaction', + role: 'system', + text: '手动压缩摘要', + }), + makeEntry({ id: 'a1', type: 'assistant', role: 'assistant' }), + ]; + + expect(filterEntries(entries, 'all')).toEqual([ + entries[0], + entries[2], + ]); + }); }); diff --git a/tests/server.spec.ts b/tests/server.spec.ts index 3de212e..3ed472d 100644 --- a/tests/server.spec.ts +++ b/tests/server.spec.ts @@ -162,4 +162,14 @@ describe("Server SDK 与集成服务", () => { data.sessions[0].entries.some((entry) => entry.text === "已处理完毕"), ).toBe(true); }); + + it("startServer 默认监听地址读取 CALL_CODE_WEB_HOST", async () => { + process.env.CALL_CODE_WEB_HOST = "0.0.0.0"; + try { + const { server } = await createTestServer(); + expect(server.host).toBe("0.0.0.0"); + } finally { + delete process.env.CALL_CODE_WEB_HOST; + } + }); });