From 7c0ba713143884855dca23a91439ed0a594666d1 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sun, 30 Mar 2025 21:30:01 -0700 Subject: [PATCH] scaffolding for checkpoints --- .../contrib/void/browser/chatThreadService.ts | 31 ++++++++++++++----- .../void/common/chatThreadServiceTypes.ts | 15 +++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/chatThreadService.ts b/src/vs/workbench/contrib/void/browser/chatThreadService.ts index 65c49a3b..dddd7d18 100644 --- a/src/vs/workbench/contrib/void/browser/chatThreadService.ts +++ b/src/vs/workbench/contrib/void/browser/chatThreadService.ts @@ -76,18 +76,19 @@ type ThreadType = { createdAt: string; // ISO string lastModified: string; // ISO string messages: ChatMessage[]; + currentHistoryIdx: number | null; // index in messages, ALWAYS points to a LLMHistoryEntry or UserHistoryEntry, or -1 if no changes. current code is inclusive of the current index's change + + // this doesn't need to go in a state object, but feels right state: { stagingSelections: StagingSelectionItem[]; - focusedMessageIdx: number | undefined; // index of the message that is being edited (undefined if none) + focusedMessageIdx: number | undefined; // index of the user message that is being edited (undefined if none) linksOfMessageIdx: { // eg. link = linksOfMessageIdx[4]['RangeFunction'] [messageIdx: number]: { [codespanName: string]: CodespanLocationLink } } - - isCheckedOfSelectionId: { [selectionId: string]: boolean }; // TODO - } + }; } type ChatThreads = { @@ -97,7 +98,6 @@ type ChatThreads = { export const defaultThreadState: ThreadType['state'] = { stagingSelections: [], focusedMessageIdx: undefined, - isCheckedOfSelectionId: {}, linksOfMessageIdx: {}, } @@ -130,7 +130,8 @@ const newThreadObject = () => { lastModified: now, messages: [], state: defaultThreadState, - } satisfies ChatThreads[string] + currentHistoryIdx: null, + } satisfies ThreadType } @@ -943,6 +944,9 @@ class ChatThreadService extends Disposable implements IChatThreadService { } + async callWhenJumpBackToIdx(toIdx: number) { + // TODO!!! + } @@ -1251,7 +1255,20 @@ class ChatThreadService extends Disposable implements IChatThreadService { // add the current file as a staging selection const model = this._codeEditorService.getActiveCodeEditor()?.getModel() if (model) { - this._setCurrentThreadState({ ...defaultThreadState, stagingSelections: [{ type: 'File', fileURI: model.uri, language: model.getLanguageId(), selectionStr: null, range: null, state: { isOpened: false, wasAddedAsCurrentFile: true } }] }) + this._setCurrentThreadState({ + ...defaultThreadState, + stagingSelections: [{ + type: 'File', + fileURI: model.uri, + language: model.getLanguageId(), + selectionStr: null, + range: null, + state: { + isOpened: false, + wasAddedAsCurrentFile: true + } + }] + }) } return; } diff --git a/src/vs/workbench/contrib/void/common/chatThreadServiceTypes.ts b/src/vs/workbench/contrib/void/common/chatThreadServiceTypes.ts index c4893d6c..7dfe39e5 100644 --- a/src/vs/workbench/contrib/void/common/chatThreadServiceTypes.ts +++ b/src/vs/workbench/contrib/void/common/chatThreadServiceTypes.ts @@ -24,6 +24,18 @@ export type ToolRequestApproval = { id: string; // proposed tool's id } + +// checkpoints +export type LLMHistoryEntry = { // ALWAYS comes right after a {role:'tool', name:'edit'} message + role: 'LLM_changes'; + afterStrOfURI: { [fsPath: string]: string }; +} +export type UserHistoryEntry = { // ALWAYS comes right before a {role:'user'} message, or if it's the last message (w/o a user message yet) + role: 'user_changes'; + afterStrOfURI: { [fsPath: string]: string }; +} + + // WARNING: changing this format is a big deal!!!!!! need to migrate old format to new format on users' computers so people don't get errors. export type ChatMessage = | { @@ -44,6 +56,8 @@ export type ChatMessage = } | ToolMessage | ToolRequestApproval + | LLMHistoryEntry // invisible + | UserHistoryEntry // invisible // one of the square items that indicates a selection in a chat bubble (NOT a file, a Selection of text) @@ -75,6 +89,7 @@ export type StagingSelectionItem = CodeSelection | FileSelection +// a link to a symbol (an underlined link to a piece of code) export type CodespanLocationLink = { uri: URI, // we handle serialization for this displayText: string,