docs: correct three more result-diff comments to the whole-file case
Three comments still implied the result diff is always an applied hunk or
that write returns undefined on no-hunk: the toolResultUpdate JSDoc (a diff
result "emits the applied-hunk blocks, which replace the call-time snippet"),
the empty-diffs test comment ("an empty write returns undefined" — write now
falls back to a whole-file diff), and diffsFromMeta's JSDoc ("a bad meta
yields no diff card" — only true for edit; write falls back to a whole-file
diff). Each now states the write whole-file fallback. Regenerate the catalog.
This commit is contained in:
@@ -81,7 +81,8 @@ function isFileDiff(value: unknown): value is FileDiff {
|
|||||||
* hunks, or `undefined` when it is absent/malformed. `presentResult` runs on
|
* hunks, or `undefined` when it is absent/malformed. `presentResult` runs on
|
||||||
* arbitrary logged `meta` (possibly from an older shape or a hand-edited log), so
|
* arbitrary logged `meta` (possibly from an older shape or a hand-edited log), so
|
||||||
* it validates defensively rather than trusting the payload — a bad `meta` yields
|
* it validates defensively rather than trusting the payload — a bad `meta` yields
|
||||||
* no diff card (the generic result rendering) instead of a thrown presenter.
|
* `undefined`, and the caller decides the fallback (edit → the generic result
|
||||||
|
* rendering; write → an args-derived whole-file diff), never a thrown presenter.
|
||||||
*/
|
*/
|
||||||
export function diffsFromMeta(meta: unknown): FileDiff[] | undefined {
|
export function diffsFromMeta(meta: unknown): FileDiff[] | undefined {
|
||||||
if (typeof meta !== 'object' || meta === null || Array.isArray(meta)) return undefined
|
if (typeof meta !== 'object' || meta === null || Array.isArray(meta)) return undefined
|
||||||
|
|||||||
@@ -1126,9 +1126,10 @@ function terminalExitMeta(callId: string, view: TerminalResultView): TerminalExi
|
|||||||
* (the terminal card consumes them and `content` is OMITTED — a
|
* (the terminal card consumes them and `content` is OMITTED — a
|
||||||
* `tool_call_update.content` REPLACES the call's content collection in Zed, so
|
* `tool_call_update.content` REPLACES the call's content collection in Zed, so
|
||||||
* re-sending would clobber the terminal block the call installed) and otherwise
|
* re-sending would clobber the terminal block the call installed) and otherwise
|
||||||
* derives the fenced ```console fallback from `output`. A `diff` result emits the
|
* derives the fenced ```console fallback from `output`. A `diff` result emits its
|
||||||
* applied-hunk `{ type: 'diff' }` content blocks, which replace the call-time
|
* `{ type: 'diff' }` content blocks (an applied hunk, or a whole-file diff for a
|
||||||
* whole-file snippet in the editor.
|
* create), which replace the diff the call installed — so the model-facing result
|
||||||
|
* text can never clobber it.
|
||||||
*/
|
*/
|
||||||
function toolResultUpdate(callId: CallId, view: ToolResultView, isError: boolean, terminal: TerminalRendering): ToolCallSessionUpdate {
|
function toolResultUpdate(callId: CallId, view: ToolResultView, isError: boolean, terminal: TerminalRendering): ToolCallSessionUpdate {
|
||||||
const status = isError ? 'failed' as const : 'completed' as const
|
const status = isError ? 'failed' as const : 'completed' as const
|
||||||
|
|||||||
@@ -677,9 +677,10 @@ describe('result-time diff card (REAL fs edit tool → tool_call_update diff blo
|
|||||||
|
|
||||||
it('a diff result with an EMPTY diffs array and no title omits both keys (nothing to send)', () => {
|
it('a diff result with an EMPTY diffs array and no title omits both keys (nothing to send)', () => {
|
||||||
// A synthetic tool whose presentResult yields a `diff` card with no hunks and
|
// A synthetic tool whose presentResult yields a `diff` card with no hunks and
|
||||||
// no title — the shipping fs tools never emit this (edit always has a hunk; an
|
// no title — the shipping fs tools never emit this (edit always has a hunk;
|
||||||
// empty write returns undefined), so a stand-in is the only way to exercise
|
// write always falls back to a whole-file diff), so a stand-in is the only way
|
||||||
// the empty-content AND absent-title branches of the result-side diff arm.
|
// to exercise the empty-content AND absent-title branches of the result-side
|
||||||
|
// diff arm.
|
||||||
const emptyDiffTool: ToolDefinition = {
|
const emptyDiffTool: ToolDefinition = {
|
||||||
name: 'writer',
|
name: 'writer',
|
||||||
description: 'writes a file',
|
description: 'writes a file',
|
||||||
|
|||||||
Reference in New Issue
Block a user