@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oversk7/pi-web-dsh-style",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "An unofficial DSH-styled Windows browser UI for pi coding agent with configurable LAN and native frp relay access",
5
5
  "type": "module",
6
6
  "license": "MIT",
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 target = normalizePath(resolve(session?.cwd ?? workspace?.path ?? process.cwd(), input));
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
  }