@oversk7/pi-web-dsh-style 1.3.0 → 1.3.1

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.0",
3
+ "version": "1.3.1",
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
@@ -2337,7 +2337,13 @@ async function handleApi(req: import("node:http").IncomingMessage, res: ServerRe
2337
2337
  const input = url.searchParams.get("path")?.trim();
2338
2338
  if (!input) return sendJson(res, 400, { error: "path is required" });
2339
2339
  try {
2340
- const target = normalizePath(input);
2340
+ const sessionId = url.searchParams.get("sessionId");
2341
+ const workspaceId = url.searchParams.get("workspaceId");
2342
+ const session = sessionId ? sessions.get(sessionId) : undefined;
2343
+ const workspace = workspaceId ? state.workspaces.find((item) => item.id === workspaceId) : undefined;
2344
+ if (sessionId && !session) return sendJson(res, 404, { error: "session not found" });
2345
+ if (workspaceId && !workspace) return sendJson(res, 404, { error: "workspace not found" });
2346
+ const target = normalizePath(resolve(session?.cwd ?? workspace?.path ?? process.cwd(), input));
2341
2347
  const info = await stat(target);
2342
2348
  if (!info.isFile()) return sendJson(res, 400, { error: "path is not a file" });
2343
2349
  const image = url.searchParams.get("format") === "image";
package/web/app.js CHANGED
@@ -586,7 +586,8 @@ async function openFilePreview(path, line, href, trigger = document.activeElemen
586
586
  }
587
587
  const requestedLine = Number(line);
588
588
  const normalizedLine = Number.isFinite(requestedLine) && requestedLine > 0 ? Math.max(1, requestedLine) : null;
589
- if (S.filePreview?.path === path && !S.filePreview.error) {
589
+ const previewContext = S.currentSessionId || S.currentWorkspaceId || "";
590
+ if ((S.filePreview?.requestedPath || S.filePreview?.path) === path && S.filePreview?.context === previewContext && !S.filePreview.error) {
590
591
  S.filePreview = { ...S.filePreview, line: normalizedLine, href };
591
592
  applyFrameLayout();
592
593
  renderFilePreview();
@@ -596,15 +597,17 @@ async function openFilePreview(path, line, href, trigger = document.activeElemen
596
597
  }
597
598
 
598
599
  const generation = ++S.filePreviewGeneration;
599
- S.filePreview = { path, line: normalizedLine, href, name: fileNameFromPath(path), loading: true };
600
+ S.filePreview = { path, requestedPath: path, context: previewContext, line: normalizedLine, href, name: fileNameFromPath(path), loading: true };
600
601
  applyFrameLayout();
601
602
  renderFilePreview();
602
603
  if (mobile) $(".pI_x6G_detailsCol")?.focus({ preventScroll: true });
603
604
  try {
604
- const data = await api(`/api/fs/view?path=${encodeURIComponent(path)}&format=json`);
605
+ const context = S.currentSessionId ? `&sessionId=${encodeURIComponent(S.currentSessionId)}`
606
+ : S.currentWorkspaceId ? `&workspaceId=${encodeURIComponent(S.currentWorkspaceId)}` : "";
607
+ const data = await api(`/api/fs/view?path=${encodeURIComponent(path)}&format=json${context}`);
605
608
  if (generation !== S.filePreviewGeneration) return;
606
609
  const activeLine = S.filePreview?.path === path ? S.filePreview.line : normalizedLine;
607
- S.filePreview = { ...data, path, line: activeLine, href, loading: false, error: null };
610
+ S.filePreview = { ...data, path: data.path || path, requestedPath: path, context: previewContext, line: activeLine, href, loading: false, error: null };
608
611
  } catch (error) {
609
612
  if (generation !== S.filePreviewGeneration) return;
610
613
  S.filePreview = { ...S.filePreview, loading: false, error: error.message || String(error) };