Implement bidirectional extension webview messaging system; extension holds claude messages state to keep webview stateless

This commit is contained in:
Saoud Rizwan
2024-07-08 12:58:05 -04:00
parent 09559c314b
commit 4da785b822
9 changed files with 242 additions and 79 deletions

View File

@@ -2,8 +2,18 @@
// webview will hold state
export interface ExtensionMessage {
type: "text" | "action" | "state"
type: "action" | "state"
text?: string
action?: "plusButtonTapped" | "settingsButtonTapped"
state?: { didOpenOnce: boolean, apiKey?: string, maxRequestsPerTask?: number }
}
state?: { didOpenOnce: boolean, apiKey?: string, maxRequestsPerTask?: number, claudeMessages: ClaudeMessage[] }
}
export interface ClaudeMessage {
type: "ask" | "say"
ask?: ClaudeAsk
say?: ClaudeSay
text?: string
}
export type ClaudeAsk = "request_limit_reached" | "followup" | "command" | "completion_result"
export type ClaudeSay = "error" | "api_cost" | "text" | "tool" | "command_output" | "task_completed"