🚧 /share

This commit is contained in:
Nate Sesti 2023-10-30 16:08:50 -07:00
parent ef131a0f80
commit ba6db9cbf1
9 changed files with 252 additions and 263 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -59,8 +59,6 @@ abstract class AbstractContinueGUIClientProtocol {
abstract deleteContextGroup(id: string): void;
abstract setCurrentSessionTitle(title: string): void;
abstract onConfigUpdate(callback: (config: ContinueConfig) => void);
}

View file

@ -216,10 +216,6 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
deleteContextGroup(id: string): void {
this.messenger?.send("delete_context_group", { id });
}
setCurrentSessionTitle(title: string): void {
this.messenger?.send("set_current_session_title", { title });
}
}
export default ContinueGUIClientProtocol;

View file

@ -75,6 +75,9 @@ function useSetup(
const cp = await resp.json();
dispatch(setContextProviders(cp));
});
client.getConfig().then((config) => {
dispatch(setConfig(config));
});
}, [client]);
// IDE event listeners

View file

@ -51,6 +51,7 @@ import {
newSession,
setActive,
setHistory,
setTitle,
} from "../redux/slices/sessionStateReducer";
import { StepDescription } from "../schema/SessionState";
@ -554,7 +555,7 @@ function GUI(props: GUIProps) {
e.target.value === "New Session")
)
return;
client?.setCurrentSessionTitle(e.target.value);
dispatch(setTitle(e.target.value));
}}
onKeyDown={(e) => {
if (e.key === "Enter") {

View file

@ -1,5 +1,7 @@
from typing import Type, Union
from ..steps.share_session import ShareSessionStep
from ..steps.chroma import AnswerQuestionChroma
from ...core.config import ContinueConfig
@ -18,6 +20,7 @@ REPLACEMENT_SLASH_COMMAND_STEPS = [
AnswerQuestionChroma,
GenerateShellCommandStep,
EditHighlightedCodeStep,
ShareSessionStep,
]

View file

@ -1,11 +1,8 @@
import json
import os
import time
from typing import Optional
from ...core.main import Step, StepDescription, SessionState
from ...core.main import Step
from ...core.sdk import ContinueSDK
from ...libs.util.paths import getGlobalFolderPath, getSessionFilePath
from ...libs.util.paths import getGlobalFolderPath
class ShareSessionStep(Step):
@ -13,29 +10,25 @@ class ShareSessionStep(Step):
# Format SessionState as a .md file
import datetime
# TODO: Can this still be done? Is a slash command really what you want?
date_created = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
content = f"This is a session transcript from [Continue](https://continue.dev) on {date_created}.\n\n"
# date_created = datetime.datetime.fromtimestamp(
# float(session_state.session_info.date_created)
# ).strftime("%Y-%m-%d %H:%M:%S")
# content = f"This is a session transcript from [Continue](https://continue.dev) on {date_created}.\n\n"
for step in sdk.history[:-2]:
if step.hide:
continue # ay
# for node in session_state.history.timeline[:-2]:
# if node.step.hide:
# continue # ay
content += f"## {step.name}\n"
content += f"{step.description}\n\n"
# content += f"## {node.step.name}\n"
# content += f"{node.step.description}\n\n"
# Save to a markdown file
save_filepath = os.path.join(
getGlobalFolderPath(), f"continue ({date_created}).md"
)
# # Save to a markdown file
# save_filepath = os.path.join(
# getGlobalFolderPath(), f"{session_state.session_info.title}.md"
# )
with open(save_filepath, "w") as f:
f.write(content)
# with open(save_filepath, "w") as f:
# f.write(content)
# Open the file
await sdk.ide.setFileOpen(save_filepath)
# # Open the file
# await sdk.ide.setFileOpen(save_filepath)
# self.description = f"The session transcript has been saved to a markdown file at {save_filepath}."
self.description = f"The session transcript has been saved to a markdown file at {save_filepath}."

View file

@ -79,8 +79,6 @@ class GUIProtocolServer:
elif msg.message_type == "get_config":
return self.get_config().dict()
elif msg.message_type == "set_current_session_title":
self.set_current_session_title(data["title"])
elif msg.message_type == "show_context_virtual_file":
self.show_context_virtual_file(data.get("index", None))
elif msg.message_type == "load_session":
@ -171,9 +169,6 @@ class GUIProtocolServer:
# posthog_logger.capture_event("load_session", {"session_id": session_id})
def set_current_session_title(self, title: str):
self.session.autopilot.set_current_session_title(title)
async def set_model_for_role_from_index(self, role: str, index: int):
models = self.get_config().models
temp = models.default