update session logic
This commit is contained in:
parent
abedcbf404
commit
3ffe133c84
4 changed files with 61 additions and 51 deletions
106
core/core.ts
106
core/core.ts
|
|
@ -26,7 +26,10 @@ import { GlobalContext } from "./util/GlobalContext";
|
|||
import historyManager from "./util/history";
|
||||
import { editConfigFile, migrateV1DevDataFiles } from "./util/paths";
|
||||
import { Telemetry } from "./util/posthog";
|
||||
import { isProcessBackgrounded, markProcessAsBackgrounded } from "./util/processTerminalBackgroundStates";
|
||||
import {
|
||||
isProcessBackgrounded,
|
||||
markProcessAsBackgrounded,
|
||||
} from "./util/processTerminalBackgroundStates";
|
||||
import { getSymbolsForManyFiles } from "./util/treeSitter";
|
||||
import { TTS } from "./util/tts";
|
||||
|
||||
|
|
@ -644,12 +647,12 @@ export class Core {
|
|||
});
|
||||
|
||||
on("didChangeControlPlaneSessionInfo", async (msg) => {
|
||||
await this.configHandler.updateControlPlaneSessionInfo(
|
||||
msg.data.sessionInfo,
|
||||
);
|
||||
this.messenger.send("sessionUpdate", {
|
||||
sessionInfo: msg.data.sessionInfo,
|
||||
});
|
||||
await this.configHandler.updateControlPlaneSessionInfo(
|
||||
msg.data.sessionInfo,
|
||||
);
|
||||
});
|
||||
|
||||
on("auth/getAuthUrl", async (msg) => {
|
||||
|
|
@ -673,54 +676,57 @@ export class Core {
|
|||
}
|
||||
});
|
||||
|
||||
on("tools/call", async ({ data: { toolCall, selectedModelTitle }, messageId }) => {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
if (!config) {
|
||||
throw new Error("Config not loaded");
|
||||
}
|
||||
on(
|
||||
"tools/call",
|
||||
async ({ data: { toolCall, selectedModelTitle }, messageId }) => {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
if (!config) {
|
||||
throw new Error("Config not loaded");
|
||||
}
|
||||
|
||||
const tool = config.tools.find(
|
||||
(t) => t.function.name === toolCall.function.name,
|
||||
);
|
||||
const tool = config.tools.find(
|
||||
(t) => t.function.name === toolCall.function.name,
|
||||
);
|
||||
|
||||
if (!tool) {
|
||||
throw new Error(`Tool ${toolCall.function.name} not found`);
|
||||
}
|
||||
if (!tool) {
|
||||
throw new Error(`Tool ${toolCall.function.name} not found`);
|
||||
}
|
||||
|
||||
if (!config.selectedModelByRole.chat) {
|
||||
throw new Error("No chat model selected");
|
||||
}
|
||||
if (!config.selectedModelByRole.chat) {
|
||||
throw new Error("No chat model selected");
|
||||
}
|
||||
|
||||
// Define a callback for streaming output updates
|
||||
const onPartialOutput = (params: {
|
||||
toolCallId: string,
|
||||
contextItems: ContextItem[];
|
||||
}) => {
|
||||
this.messenger.send("toolCallPartialOutput", params);
|
||||
};
|
||||
// Define a callback for streaming output updates
|
||||
const onPartialOutput = (params: {
|
||||
toolCallId: string;
|
||||
contextItems: ContextItem[];
|
||||
}) => {
|
||||
this.messenger.send("toolCallPartialOutput", params);
|
||||
};
|
||||
|
||||
const contextItems = await callTool(
|
||||
tool,
|
||||
JSON.parse(toolCall.function.arguments || "{}"),
|
||||
{
|
||||
ide: this.ide,
|
||||
llm: config.selectedModelByRole.chat,
|
||||
fetch: (url, init) =>
|
||||
fetchwithRequestOptions(url, init, config.requestOptions),
|
||||
const contextItems = await callTool(
|
||||
tool,
|
||||
toolCallId: toolCall.id,
|
||||
onPartialOutput,
|
||||
},
|
||||
);
|
||||
JSON.parse(toolCall.function.arguments || "{}"),
|
||||
{
|
||||
ide: this.ide,
|
||||
llm: config.selectedModelByRole.chat,
|
||||
fetch: (url, init) =>
|
||||
fetchwithRequestOptions(url, init, config.requestOptions),
|
||||
tool,
|
||||
toolCallId: toolCall.id,
|
||||
onPartialOutput,
|
||||
},
|
||||
);
|
||||
|
||||
if (tool.faviconUrl) {
|
||||
contextItems.forEach((item) => {
|
||||
item.icon = tool.faviconUrl;
|
||||
});
|
||||
}
|
||||
if (tool.faviconUrl) {
|
||||
contextItems.forEach((item) => {
|
||||
item.icon = tool.faviconUrl;
|
||||
});
|
||||
}
|
||||
|
||||
return { contextItems };
|
||||
});
|
||||
return { contextItems };
|
||||
},
|
||||
);
|
||||
|
||||
on("isItemTooBig", async ({ data: { item, selectedModelTitle } }) => {
|
||||
return this.isItemTooBig(item);
|
||||
|
|
@ -731,11 +737,13 @@ export class Core {
|
|||
markProcessAsBackgrounded(toolCallId);
|
||||
});
|
||||
|
||||
on("process/isBackgrounded", async ({ data: { toolCallId }, messageId }) => {
|
||||
const isBackgrounded = isProcessBackgrounded(toolCallId);
|
||||
return isBackgrounded; // Return true to indicate the message was handled successfully
|
||||
});
|
||||
|
||||
on(
|
||||
"process/isBackgrounded",
|
||||
async ({ data: { toolCallId }, messageId }) => {
|
||||
const isBackgrounded = isProcessBackgrounded(toolCallId);
|
||||
return isBackgrounded; // Return true to indicate the message was handled successfully
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
private async isItemTooBig(item: ContextItemWithId) {
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@ class ContinueAuthService {
|
|||
setRefreshToken("")
|
||||
setAccountId("")
|
||||
setAccountLabel("")
|
||||
|
||||
ApplicationManager.getApplication().messageBus.syncPublisher(AuthListener.TOPIC)
|
||||
.handleUpdatedSessionInfo(null)
|
||||
}
|
||||
|
||||
private fun updateRefreshToken(token: String) {
|
||||
|
|
|
|||
|
|
@ -111,8 +111,6 @@ class IdeProtocolClient(
|
|||
"logoutOfControlPlane" -> {
|
||||
val authService = service<ContinueAuthService>()
|
||||
authService.signOut()
|
||||
ApplicationManager.getApplication().messageBus.syncPublisher(AuthListener.TOPIC)
|
||||
.handleUpdatedSessionInfo(null)
|
||||
|
||||
respond(null)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
useWebviewListener(
|
||||
"sessionUpdate",
|
||||
async (data) => {
|
||||
debugger;
|
||||
setSession(data.sessionInfo);
|
||||
},
|
||||
[],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue