🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
⚡️ perf(tools): project the whole command-output family, not just one member (#19695)
Arvin Xuf799ae489300
diff --git a/packages/tool-view-model/src/project.test.ts b/packages/tool-view-model/src/project.test.tsindex 4176b4dd709..e57762a8beb 100644--- a/packages/tool-view-model/src/project.test.ts+++ b/packages/tool-view-model/src/project.test.ts@@ -114,10 +114,14 @@ describe('projectToolViewModels', () => {describe('registry', () => {it('projects exactly the tools that were measured and audited', () => {expect(listProjectedTools().sort()).toEqual([+ 'claude-code/Bash',+ 'codex/command_execution','lobe-agent-documents/readDocument','lobe-local-system/runCommand','lobe-web-browsing/crawlMultiPages','lobe-web-browsing/crawlSinglePage',+ 'opencode/bash',+ 'pi/bash',]);});});diff --git a/packages/tool-view-model/src/projectors/localSystem.ts b/packages/tool-view-model/src/projectors/localSystem.tsindex 32c424772fa..de7e824ceab 100644--- a/packages/tool-view-model/src/projectors/localSystem.ts+++ b/packages/tool-view-model/src/projectors/localSystem.ts@@ -7,7 +7,9 @@ const isRecord = (value: unknown): value is Record<string, unknown> =>const OUTPUT_KEYS = new Set(['output', 'stdout']);/**- * `runCommand`.+ * The command-output family: every tool whose result renders through the shared+ * `RunCommand` card — `lobe-local-system/runCommand`,+ * `codex/command_execution`, `claude-code/Bash`, `opencode/bash`, `pi/bash`.** The command's output is stored THREE times: the tool message body,* `state.stdout`, and the legacy `state.output`. All three go. What stays is thediff --git a/packages/tool-view-model/src/projectors/projectors.test.ts b/packages/tool-view-model/src/projectors/projectors.test.tsindex 7764539f511..639ef6746a7 100644--- a/packages/tool-view-model/src/projectors/projectors.test.ts+++ b/packages/tool-view-model/src/projectors/projectors.test.ts@@ -126,6 +126,40 @@ describe('runCommandProjector', () => {expect(result?.pluginState).toEqual({ exitCode: 0 });});+ it('handles the codex shape, whose extra metadata keys must survive', () => {+ // Observed on production: `stdout` and `output` are byte-identical copies,+ // and the collapsed row reads `success` / `exitCode` — which is why the+ // whole command-output family shares this projector.+ const result = runCommandProjector(+ input({+ pluginState: {+ exitCode: 0,+ isBackground: false,+ omittedOutputCharacters: 120,+ originalOutputLength: 4181,+ output: 'OUT',+ stdout: 'OUT',+ success: true,+ },+ }),+ );++ expect(result?.content).toBeNull();+ expect(result?.pluginState).toEqual({+ exitCode: 0,+ isBackground: false,+ omittedOutputCharacters: 120,+ originalOutputLength: 4181,+ success: true,+ });+ });++ it('strips a body carried without any state, as claude-code/Bash does', () => {+ const result = runCommandProjector(input({ content: 'the output', pluginState: undefined }));++ expect(result).toEqual({ content: null, storedPayloadNeededBy: 'render' });+ });+it('declines a call that produced nothing to drop', () => {expect(runCommandProjector(input({ content: '', pluginState: { exitCode: 0 } })),diff --git a/packages/tool-view-model/src/registry.ts b/packages/tool-view-model/src/registry.tsindex 0e7121a1301..d73c2416eba 100644--- a/packages/tool-view-model/src/registry.ts+++ b/packages/tool-view-model/src/registry.ts@@ -13,6 +13,17 @@ import type { ToolProjector } from './types';* the map can be filled one tool at a time.*/const toolProjectors: Record<string, Record<string, ToolProjector>> = {+ // Every tool below renders through the SAME shared card,+ // `shared-tool-ui/Render/RunCommand` — it reads `stdout || output || content`+ // for the body and `success` / `exitCode` for the collapsed row. One shape,+ // so one projector; see `register.ts` for the render registrations that make+ // this true.+ 'claude-code': {+ Bash: runCommandProjector,+ },+ 'codex': {+ command_execution: runCommandProjector,+ },'lobe-agent-documents': {readDocument: readDocumentProjector,},@@ -23,6 +34,12 @@ const toolProjectors: Record<string, Record<string, ToolProjector>> = {crawlMultiPages: crawlProjector,crawlSinglePage: crawlProjector,},+ 'opencode': {+ bash: runCommandProjector,+ },+ 'pi': {+ bash: runCommandProjector,+ },};export const getToolProjector = (