Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
14 changes: 14 additions & 0 deletions packages/types/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@

export type TokenUsage = z.infer<typeof tokenUsageSchema>

/**
* MentionSegment
*/

/** A part of a message with a known origin. Only `user` parts may have mentions expanded. */
export const mentionSegmentSchema = z.object({

Check warning on line 375 in packages/types/src/message.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

packages/types/src/message.ts:375: Survived ObjectLiteral mutant (replacement: {}). See the job summary for the complete list and resolution guidance.
text: z.string(),
source: z.enum(["user", "generated"]),

Check warning on line 377 in packages/types/src/message.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

packages/types/src/message.ts:377: 3 mutation test gaps; example: Survived ArrayDeclaration mutant (replacement: []). See the job summary for the complete list and resolution guidance.
})

export type MentionSegment = z.infer<typeof mentionSegmentSchema>

/**
* QueuedMessage
*/
Expand All @@ -376,6 +388,8 @@
id: z.string(),
text: z.string(),
images: z.array(z.string()).optional(),
/** Origin of each part of `text`. Absent means all generated. */
segments: z.array(mentionSegmentSchema).optional(),
})

export type QueuedMessage = z.infer<typeof queuedMessageSchema>
6 changes: 5 additions & 1 deletion packages/types/src/vscode-extension-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ProviderSettings, ProviderSettingsEntry } from "./provider-setting
import type { HistoryItem } from "./history.js"
import type { ModeConfig, PromptComponent } from "./mode.js"
import type { Experiments } from "./experiment.js"
import type { ClineMessage, QueuedMessage } from "./message.js"
import type { ClineMessage, MentionSegment, QueuedMessage } from "./message.js"
import type { MarketplaceItem, MarketplaceInstalledMetadata, InstallMarketplaceItemOptions } from "./marketplace.js"
import type { TodoItem } from "./todo.js"
import type { CloudUserInfo, CloudOrganizationMembership, OrganizationAllowList, ShareVisibility } from "./cloud.js"
Expand Down Expand Up @@ -133,6 +133,8 @@ export interface ExtensionMessage {
| "switchTab"
| "toggleAutoApprove"
invoke?: "newChat" | "sendMessage" | "primaryButtonClick" | "secondaryButtonClick" | "setChatBoxMessage"
/** With `invoke: "setChatBoxMessage"`: origin of each part of `text`. Absent means all generated. */
segments?: MentionSegment[]
/**
* Partial state updates are allowed to reduce message size (e.g. omit large fields like taskHistory).
* The webview is responsible for merging.
Expand Down Expand Up @@ -817,6 +819,8 @@ export interface WebviewMessage {
updatedSettings?: RooCodeSettings
/** Task configuration applied via `createTask()`. */
taskConfiguration?: RooCodeSettings
/** Origin of each part of `text`. Absent or not matching `text` means all generated. */
segments?: MentionSegment[]
// Worktree properties
worktreePath?: string
worktreeBranch?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,15 @@ describe("presentAssistantMessage - Image Handling in Native Tool Calling", () =

await presentAssistantMessage(mockTask, baseSnapshot)

// Anthropic rejects user messages where image blocks sit between
// tool_result blocks, so images from both tools must be grouped
// after the last tool_result instead of interleaved.
// Images must come after all tool_result blocks (#1307). Feedback
// text blocks join the tail in push order. No image may appear
// before the second tool_result.
expect(mockTask.userMessageContent.map((block: UserContentBlock) => block.type)).toEqual([
"tool_result",
"tool_result",
"text",
"image",
"text",
"image",
])
expect(
Expand Down Expand Up @@ -442,10 +444,14 @@ describe("presentAssistantMessage - Image Handling in Native Tool Calling", () =

await presentAssistantMessage(mockTask, baseSnapshot)

// The image must come after the last tool_result (#1307), never
// between tool_result blocks. Feedback text joins the tail.
expect(mockTask.userMessageContent.map((block: UserContentBlock) => block.type)).toEqual([
"tool_result",
"tool_result",
"text",
"image",
"text",
])
expect(
mockTask.userMessageContent
Expand Down
Loading
Loading