mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-22 05:11:06 -05:00
Initial streaming refactor
This commit is contained in:
@@ -5,7 +5,15 @@ import { HistoryItem } from "./HistoryItem"
|
||||
|
||||
// webview will hold state
|
||||
export interface ExtensionMessage {
|
||||
type: "action" | "state" | "selectedImages" | "ollamaModels" | "theme" | "workspaceUpdated" | "invoke"
|
||||
type:
|
||||
| "action"
|
||||
| "state"
|
||||
| "selectedImages"
|
||||
| "ollamaModels"
|
||||
| "theme"
|
||||
| "workspaceUpdated"
|
||||
| "invoke"
|
||||
| "partialMessage"
|
||||
text?: string
|
||||
action?: "chatButtonTapped" | "settingsButtonTapped" | "historyButtonTapped" | "didBecomeVisible"
|
||||
invoke?: "sendMessage" | "primaryButtonClick" | "secondaryButtonClick"
|
||||
@@ -13,6 +21,7 @@ export interface ExtensionMessage {
|
||||
images?: string[]
|
||||
models?: string[]
|
||||
filePaths?: string[]
|
||||
partialMessage?: ClaudeMessage
|
||||
}
|
||||
|
||||
export interface ExtensionState {
|
||||
@@ -33,6 +42,7 @@ export interface ClaudeMessage {
|
||||
say?: ClaudeSay
|
||||
text?: string
|
||||
images?: string[]
|
||||
partial?: boolean
|
||||
}
|
||||
|
||||
export type ClaudeAsk =
|
||||
|
||||
22
src/shared/array.ts
Normal file
22
src/shared/array.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Returns the index of the last element in the array where predicate is true, and -1
|
||||
* otherwise.
|
||||
* @param array The source array to search in
|
||||
* @param predicate find calls predicate once for each element of the array, in descending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.
|
||||
*/
|
||||
export function findLastIndex<T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean): number {
|
||||
let l = array.length
|
||||
while (l--) {
|
||||
if (predicate(array[l], l, array)) {
|
||||
return l
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
export function findLast<T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean): T | undefined {
|
||||
const index = findLastIndex(array, predicate)
|
||||
return index === -1 ? undefined : array[index]
|
||||
}
|
||||
Reference in New Issue
Block a user