@oversk7/pi-web-dsh-style 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server.ts +4 -1
- package/web/app.js +9 -1
- package/web/assets/markdown.js +14 -14
- package/web/markdown.ts +10 -3
package/package.json
CHANGED
package/server.ts
CHANGED
|
@@ -2343,7 +2343,10 @@ async function handleApi(req: import("node:http").IncomingMessage, res: ServerRe
|
|
|
2343
2343
|
const workspace = workspaceId ? state.workspaces.find((item) => item.id === workspaceId) : undefined;
|
|
2344
2344
|
if (sessionId && !session) return sendJson(res, 404, { error: "session not found" });
|
|
2345
2345
|
if (workspaceId && !workspace) return sendJson(res, 404, { error: "workspace not found" });
|
|
2346
|
-
const
|
|
2346
|
+
const activeSession = !sessionId && !workspaceId && state.currentSessionId ? sessions.get(state.currentSessionId) : undefined;
|
|
2347
|
+
const activeWorkspace = !sessionId && !workspaceId
|
|
2348
|
+
? state.workspaces.find((item) => item.id === (activeSession?.workspaceId ?? state.currentWorkspaceId)) : undefined;
|
|
2349
|
+
const target = normalizePath(resolve(session?.cwd ?? workspace?.path ?? activeWorkspace?.path ?? activeSession?.cwd ?? process.cwd(), input));
|
|
2347
2350
|
const info = await stat(target);
|
|
2348
2351
|
if (!info.isFile()) return sendJson(res, 400, { error: "path is not a file" });
|
|
2349
2352
|
const image = url.searchParams.get("format") === "image";
|
package/web/app.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { markdown } from "./assets/markdown.js";
|
|
3
|
+
import { markdown as renderMarkdown } from "./assets/markdown.js";
|
|
4
4
|
import { webSlashCommands, unsupportedSlashCommands, parseSlashCommand } from "./slash-commands.js";
|
|
5
5
|
import { getLanguage, setLanguage, t, translateUi, observeUi } from "./i18n.js";
|
|
6
6
|
|
|
@@ -274,6 +274,14 @@ function snapshotFor(id) {
|
|
|
274
274
|
return S.snapshots.get(id) || { session: null, state: null, stats: null, models: [], thinkingLevels: [], thinkingLevelsByModel: {}, commands: [], extensionStatuses: {}, messages: [], pendingQueue: { steering: [], followUp: [] }, dialogs: [] };
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
function markdown(text) {
|
|
278
|
+
const session = S.currentSessionId ? S.snapshots.get(S.currentSessionId)?.session : null;
|
|
279
|
+
const workspace = S.currentSessionId
|
|
280
|
+
? S.workspaces.find((item) => item.sessions?.some((entry) => entry.id === S.currentSessionId))
|
|
281
|
+
: S.workspaces.find((item) => item.id === S.currentWorkspaceId);
|
|
282
|
+
return renderMarkdown(text, { cwd: session?.cwd || workspace?.path });
|
|
283
|
+
}
|
|
284
|
+
|
|
277
285
|
function currentWorkspace() {
|
|
278
286
|
return S.workspaces.find((w) => w.id === S.currentWorkspaceId) || S.workspaces[0] || null;
|
|
279
287
|
}
|