Elffuss BraidHub

kikocis/continue public

show current session data in editor

- add a protocol in core to get session data
- add gui in help section
Changeset9fdff64e54855db3d22d5c55cbea0fa99ffc88be283532508b75d370caa89570
Authoruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-07-15 11:54 +05:30
Committeruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-07-15 11:54 +05:30
Parents10ed2343a94a

Browse the files at this changeset

6 files changed

modified core/core.ts +4 −0
@@ -292,6 +292,10 @@
292292 historyManager.clearAll();
293293 });
294294
295+ on("history/getSessionData", (msg) => {
296+ return historyManager.getSessionData(msg.data.id);
297+ });
298+
295299 on("devdata/log", async (msg) => {
296300 void DataLogger.getInstance().logDevData(msg.data);
297301 });
modified core/protocol/core.ts +1 −0
@@ -67,6 +67,7 @@
6767 "history/load": [{ id: string }, Session];
6868 "history/save": [Session, void];
6969 "history/clear": [undefined, void];
70+ "history/getSessionData": [{ id: string }, string];
7071 "devdata/log": [DevDataLogEvent, void];
7172 "config/addOpenAiKey": [string, void];
7273 "config/addModel": [
modified core/protocol/passThrough.ts +1 −0
@@ -15,6 +15,7 @@
1515 "history/load",
1616 "history/save",
1717 "history/clear",
18+ "history/getSessionData",
1819 "devdata/log",
1920 "config/addModel",
2021 "config/newPromptFile",
modified core/util/history.ts +13 −0
@@ -95,6 +95,19 @@
9595 }
9696 }
9797
98+ getSessionData(sessionId: string): string {
99+ try {
100+ const sessionFile = getSessionFilePath(sessionId);
101+ if (!fs.existsSync(sessionFile)) {
102+ throw new Error(`Session file ${sessionFile} does not exist`);
103+ }
104+ const fileContent = fs.readFileSync(sessionFile, "utf8");
105+ return JSON.stringify(JSON.parse(fileContent), null, 2);
106+ } catch (e) {
107+ throw new Error(`Error reading session data: ${e}`);
108+ }
109+ }
110+
98111 save(session: Session) {
99112 // Save the main session json file
100113 // Explicitely rewriting here to influence the written key order in the file!
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +1 −0
@@ -81,6 +81,7 @@
8181 "history/load",
8282 "history/save",
8383 "history/clear",
84+ "history/getSessionData",
8485 "devdata/log",
8586 "config/addModel",
8687 "config/newPromptFile",
modified gui/src/pages/config/HelpCenterSection.tsx +30 −1
@@ -1,13 +1,14 @@
11 import {
22 ArrowTopRightOnSquareIcon,
33 DocumentArrowUpIcon,
4+ NumberedListIcon,
45 PaintBrushIcon,
56 TableCellsIcon,
67 } from "@heroicons/react/24/outline";
78 import { useContext } from "react";
89 import { useNavigate } from "react-router-dom";
910 import { IdeMessengerContext } from "../../context/IdeMessenger";
10-import { useAppDispatch } from "../../redux/hooks";
11+import { useAppDispatch, useAppSelector } from "../../redux/hooks";
1112 import { setOnboardingCard } from "../../redux/slices/uiSlice";
1213 import { saveCurrentSession } from "../../redux/thunks/session";
1314 import { ROUTES } from "../../util/navigation";
@@ -18,6 +19,25 @@
1819 const navigate = useNavigate();
1920 const dispatch = useAppDispatch();
2021
22+ const currentSession = useAppSelector((state) => state.session);
23+
24+ const handleViewSessionData = async () => {
25+ try {
26+ const sessionData = await ideMessenger.request("history/getSessionData", {
27+ id: currentSession.id,
28+ });
29+
30+ if (sessionData.status === "success") {
31+ await ideMessenger.request("showVirtualFile", {
32+ name: "currentSessionData.json",
33+ content: sessionData.content,
34+ });
35+ }
36+ } catch (error) {
37+ console.error("Error viewing session data:", error);
38+ }
39+ };
40+
2141 return (
2242 <div className="py-5">
2343 <h3 className="mb-4 mt-0 text-xl">Help center</h3>
@@ -68,6 +88,15 @@
6888 onClick={() => navigate("/stats")}
6989 />
7090
91+ {currentSession.history.length > 0 && !currentSession.isStreaming && (
92+ <MoreHelpRow
93+ title="View current session history"
94+ description="Open the current chat session file for troubleshooting"
95+ Icon={NumberedListIcon}
96+ onClick={handleViewSessionData}
97+ />
98+ )}
99+
71100 <MoreHelpRow
72101 title="Quickstart"
73102 description="Reopen the quickstart and tutorial file"