feat(tooling): preserve native tool titles (#1133)

This commit is contained in:
SSU-WEI HUANG
2026-07-23 08:41:33 +08:00
committed by GitHub
parent e69ca0782f
commit 6bedd0d924
18 changed files with 135 additions and 18 deletions
+8 -4
View File
@@ -335,7 +335,8 @@ export async function opencodeLocalLauncher(
type: 'tool-call',
name: toolCall.name,
callId: toolCall.callId,
input: toolCall.input
input: toolCall.input,
...(toolCall.title ? { nativeTitle: toolCall.title } : {})
});
}
@@ -349,7 +350,8 @@ export async function opencodeLocalLauncher(
type: 'tool-call',
name: toolCall.name,
callId: toolCall.callId,
input: toolCall.input
input: toolCall.input,
...(toolCall.title ? { nativeTitle: toolCall.title } : {})
});
}
sentToolResults.add(toolResult.callId);
@@ -418,7 +420,8 @@ export async function opencodeLocalLauncher(
type: 'tool-call',
name,
callId,
input: toolInput
input: toolInput,
...(getString(tool.title ?? record.title) ? { nativeTitle: getString(tool.title ?? record.title) } : {})
});
return;
}
@@ -431,7 +434,8 @@ export async function opencodeLocalLauncher(
type: 'tool-call',
name,
callId,
input: toolInput
input: toolInput,
...(getString(tool.title ?? record.title) ? { nativeTitle: getString(tool.title ?? record.title) } : {})
});
}
sentToolResults.add(callId);
@@ -28,6 +28,19 @@ function collectMessages(parts: unknown[]): Array<{ type: string; name?: string;
}
describe('OpenCode local tool part parsing', () => {
it('preserves the native state title', () => {
expect(parseToolCall({
type: 'tool',
tool: 'bash',
callID: 'call-title',
state: {
status: 'running',
input: { command: 'bun test' },
title: 'Run project tests'
}
})).toMatchObject({ title: 'Run project tests' });
});
it('does not emit tool-call on pending with empty input; emits on running with real args', () => {
const callId = 'call-6049b4cf-0272-4651-be9a-402c3a40c933-0';
const messages = collectMessages([
@@ -4,6 +4,7 @@ export type ParsedToolCall = {
callId: string;
name: string;
input: unknown;
title?: string;
};
export type ParsedToolResult = {
@@ -77,10 +78,12 @@ export function parseToolCall(part: unknown): ParsedToolCall | null {
return null;
}
const input = parseMaybeJson(state.input ?? state.raw ?? record.input ?? record.args ?? record.arguments);
return { callId, name, input };
const title = getString(state.title);
return { callId, name, input, ...(title ? { title } : {}) };
}
const input = parseMaybeJson(record.input ?? record.args ?? record.arguments ?? record.raw);
return { callId, name, input };
const title = getString(record.title);
return { callId, name, input, ...(title ? { title } : {}) };
}
export function parseToolResult(part: unknown): ParsedToolResult | null {