@loopstack/loopstack-studio 0.35.1 → 0.37.0

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.
Files changed (43) hide show
  1. package/dist/features/documents/DocumentRenderer.js +7 -7
  2. package/dist/features/documents/renderers/DocumentFormRenderer.js +1 -1
  3. package/dist/features/documents/renderers/DocumentMessageRenderer.js +23 -9
  4. package/dist/features/documents/renderers/LlmMessage.js +90 -50
  5. package/dist/features/file-explorer/components/FileExplorerPanel.js +66 -73
  6. package/dist/features/file-explorer/hooks/useFileExplorer.js +29 -25
  7. package/dist/features/file-explorer/providers/FileExplorerProvider.js +53 -53
  8. package/dist/features/git/components/WorkbenchGitPanel.js +36 -33
  9. package/dist/features/git/hooks/useGit.js +36 -33
  10. package/dist/features/oauth/OAuthCallbackPage.js +2 -0
  11. package/dist/features/run-view/RunView.js +153 -0
  12. package/dist/features/run-view/Transcript.js +127 -0
  13. package/dist/features/run-view/prompts/FormPrompt.js +129 -0
  14. package/dist/features/run-view/prompts/OAuthPrompt.js +94 -0
  15. package/dist/features/run-view/prompts/SandboxRunButton.js +35 -0
  16. package/dist/features/run-view/prompts/SecretPrompt.js +69 -0
  17. package/dist/features/run-view/prompts/SimplePrompts.js +196 -0
  18. package/dist/features/run-view/prompts/cards.js +90 -0
  19. package/dist/features/run-view/prompts/registry.js +16 -0
  20. package/dist/features/run-view/transcript.js +24 -0
  21. package/dist/features/run-view/useRunPrompts.js +111 -0
  22. package/dist/features/run-view/useRunTree.js +59 -0
  23. package/dist/features/run-view/useTreeLlmStreams.js +91 -0
  24. package/dist/features/secrets/components/WorkbenchSecretsPanel.js +1 -1
  25. package/dist/features/secrets/renderers/SecretInputRenderer.js +1 -1
  26. package/dist/features/workbench/WorkflowList.js +111 -52
  27. package/dist/features/workbench/components/EnvironmentSelector.js +46 -0
  28. package/dist/features/workbench/components/NewRunDialog.js +1 -1
  29. package/dist/features/workbench/index.js +1 -1
  30. package/dist/features/workbench/providers/WorkbenchLayoutProvider.js +68 -56
  31. package/dist/features/workspaces/components/WorkspaceHomePage.js +1 -1
  32. package/dist/index.d.ts +2 -0
  33. package/dist/node_modules/dompurify/dist/purify.es.js +351 -228
  34. package/dist/packages/client/dist/resources/workflows.js +2 -1
  35. package/dist/packages/client/dist/stream/invalidations.js +9 -2
  36. package/dist/packages/client/dist/stream/stream.js +73 -28
  37. package/dist/packages/contracts/dist/park-view/index.js +2 -0
  38. package/dist/packages/contracts/dist/park-view/park-view.rules.js +102 -0
  39. package/dist/packages/contracts/dist/park-view/park-view.types.js +15 -0
  40. package/dist/packages/contracts/dist/types/types/ui-message.type.js +15 -2
  41. package/dist/pages/PreviewWorkbenchPage.js +23 -23
  42. package/dist/providers/StudioPreferencesProvider.js +2 -1
  43. package/package.json +4 -4
@@ -2,19 +2,19 @@ import { useDocumentConfigs } from "../../hooks/useConfig.js";
2
2
  import CompletionMessagePaper_default from "../../components/messages/CompletionMessagePaper.js";
3
3
  import { useFeatureRegistry } from "../feature-registry/FeatureRegistryProvider.js";
4
4
  import "../feature-registry/index.js";
5
- import OAuthPromptRenderer_default from "../oauth/OAuthPromptRenderer.js";
6
- import "../oauth/index.js";
7
5
  import AiMessage_default from "./renderers/AiMessage.js";
8
- import ChoicesRenderer_default from "./renderers/ChoicesRenderer.js";
9
- import ConfirmPromptRenderer_default from "./renderers/ConfirmPromptRenderer.js";
10
6
  import DocumentDebugRenderer_default from "./renderers/DocumentDebugRenderer.js";
11
7
  import DocumentFormRenderer_default from "./renderers/DocumentFormRenderer.js";
12
8
  import DocumentMessageRenderer_default from "./renderers/DocumentMessageRenderer.js";
13
9
  import ErrorMessageRenderer_default from "./renderers/ErrorMessageRenderer.js";
14
- import LinkMessageRenderer_default from "./renderers/LinkMessageRenderer.js";
15
10
  import LlmMessage_default from "./renderers/LlmMessage.js";
16
11
  import MarkdownMessageRenderer_default from "./renderers/MarkdownMessageRenderer.js";
17
12
  import PlainMessageRenderer_default from "./renderers/PlainMessageRenderer.js";
13
+ import OAuthPromptRenderer_default from "../oauth/OAuthPromptRenderer.js";
14
+ import "../oauth/index.js";
15
+ import ChoicesRenderer_default from "./renderers/ChoicesRenderer.js";
16
+ import ConfirmPromptRenderer_default from "./renderers/ConfirmPromptRenderer.js";
17
+ import LinkMessageRenderer_default from "./renderers/LinkMessageRenderer.js";
18
18
  import TextPromptRenderer_default from "./renderers/TextPromptRenderer.js";
19
19
  import { c } from "react/compiler-runtime";
20
20
  import React, { useMemo } from "react";
@@ -52,11 +52,11 @@ var coreRendererRegistry = new Map([
52
52
  workflow: e,
53
53
  document: g
54
54
  })],
55
- ["oauth-prompt", ({ parentWorkflow: e, workflow: g, document: _, isActive: y }) => /* @__PURE__ */ jsx(OAuthPromptRenderer_default, {
55
+ ["oauth-prompt", ({ parentWorkflow: e, workflow: g, document: _, isActive: v }) => /* @__PURE__ */ jsx(OAuthPromptRenderer_default, {
56
56
  parentWorkflow: e,
57
57
  workflow: g,
58
58
  document: _,
59
- isActive: y
59
+ isActive: v
60
60
  })],
61
61
  ["text-prompt", ({ parentWorkflow: e, workflow: g, document: _, isActive: v }) => /* @__PURE__ */ jsx(TextPromptRenderer_default, {
62
62
  parentWorkflow: e,
@@ -1,8 +1,8 @@
1
1
  import { useRunWorkflow } from "../../../packages/react/dist/hooks/mutations.js";
2
2
  import { useDocumentConfigs } from "../../../hooks/useConfig.js";
3
3
  import { Button } from "../../../components/ui/button.js";
4
- import "../../../hooks/useProcessor.js";
5
4
  import Form_default from "../../../components/dynamic-form/Form.js";
5
+ import "../../../hooks/useProcessor.js";
6
6
  import { c } from "react/compiler-runtime";
7
7
  import React, { useEffect } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -2,7 +2,8 @@ import CompletionMessagePaper_default from "../../../components/messages/Complet
2
2
  import MarkdownContent_default from "../../../components/dynamic-form/MarkdownContent.js";
3
3
  import { c } from "react/compiler-runtime";
4
4
  import React from "react";
5
- import { jsx } from "react/jsx-runtime";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { Info } from "lucide-react";
6
7
  var KNOWN_ROLES = [
7
8
  "system",
8
9
  "user",
@@ -10,13 +11,26 @@ var KNOWN_ROLES = [
10
11
  "tool",
11
12
  "error",
12
13
  "document"
13
- ], DocumentMessageRenderer_default = (a) => {
14
- let o = c(5), { document: s } = a, { role: l, text: u } = s.content, d = KNOWN_ROLES.includes(l ?? "") ? l : void 0, f = u ?? "", p;
15
- o[0] === f ? p = o[1] : (p = /* @__PURE__ */ jsx(MarkdownContent_default, { content: f }), o[0] = f, o[1] = p);
16
- let m;
17
- return o[2] !== d || o[3] !== p ? (m = /* @__PURE__ */ jsx(CompletionMessagePaper_default, {
18
- role: d,
19
- children: p
20
- }), o[2] = d, o[3] = p, o[4] = m) : m = o[4], m;
14
+ ], DocumentMessageRenderer_default = (s) => {
15
+ let l = c(8), { document: u } = s, { role: d, text: f } = u.content, p = KNOWN_ROLES.includes(d ?? "") ? d : void 0;
16
+ if (p === "system") {
17
+ let e;
18
+ l[0] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ jsx(Info, { className: "mt-0.5 size-3.5 shrink-0 opacity-70" }), l[0] = e) : e = l[0];
19
+ let o = f ?? "", s;
20
+ return l[1] === o ? s = l[2] : (s = /* @__PURE__ */ jsxs("div", {
21
+ className: "text-muted-foreground flex items-start gap-1.5 px-1 py-0.5 text-sm leading-relaxed [&_p]:m-0",
22
+ children: [e, /* @__PURE__ */ jsx("div", {
23
+ className: "min-w-0",
24
+ children: /* @__PURE__ */ jsx(MarkdownContent_default, { content: o })
25
+ })]
26
+ }), l[1] = o, l[2] = s), s;
27
+ }
28
+ let m = f ?? "", h;
29
+ l[3] === m ? h = l[4] : (h = /* @__PURE__ */ jsx(MarkdownContent_default, { content: m }), l[3] = m, l[4] = h);
30
+ let g;
31
+ return l[5] !== p || l[6] !== h ? (g = /* @__PURE__ */ jsx(CompletionMessagePaper_default, {
32
+ role: p,
33
+ children: h
34
+ }), l[5] = p, l[6] = h, l[7] = g) : g = l[7], g;
21
35
  };
22
36
  export { DocumentMessageRenderer_default as default };
@@ -8,16 +8,50 @@ import { Fragment } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import { CopyIcon } from "lucide-react";
10
10
  var CopyActions = (e) => {
11
- let _ = c(5), { text: v } = e, y;
12
- _[0] === v ? y = _[1] : (y = () => void navigator.clipboard.writeText(v), _[0] = v, _[1] = y);
11
+ let g = c(5), { text: _ } = e, v;
12
+ g[0] === _ ? v = g[1] : (v = () => void navigator.clipboard.writeText(_), g[0] = _, g[1] = v);
13
+ let y;
14
+ g[2] === Symbol.for("react.memo_cache_sentinel") ? (y = /* @__PURE__ */ jsx(CopyIcon, { className: "size-3" }), g[2] = y) : y = g[2];
13
15
  let b;
14
- _[2] === Symbol.for("react.memo_cache_sentinel") ? (b = /* @__PURE__ */ jsx(CopyIcon, { className: "size-3" }), _[2] = b) : b = _[2];
15
- let x;
16
- return _[3] === y ? x = _[4] : (x = /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(MessageActions, { children: /* @__PURE__ */ jsx(MessageAction, {
17
- onClick: y,
16
+ return g[3] === v ? b = g[4] : (b = /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(MessageActions, { children: /* @__PURE__ */ jsx(MessageAction, {
17
+ onClick: v,
18
18
  label: "Copy",
19
- children: b
20
- }) }) }), _[3] = y, _[4] = x), x;
19
+ children: y
20
+ }) }) }), g[3] = v, g[4] = b), b;
21
+ };
22
+ function formatTokens(e) {
23
+ return e == null ? null : e >= 1e3 ? `${(e / 1e3).toFixed(1)}k` : String(e);
24
+ }
25
+ var CompletionMeta = (e) => {
26
+ let m = c(21), { meta: h } = e, g;
27
+ if (m[0] !== h.costUsd || m[1] !== h.durationMs || m[2] !== h.model || m[3] !== h.numTurns || m[4] !== h.usage?.cacheCreationInputTokens || m[5] !== h.usage?.cacheReadInputTokens || m[6] !== h.usage?.inputTokens || m[7] !== h.usage?.outputTokens) {
28
+ if (g = [], h.numTurns != null && g.push(`${h.numTurns} turn${h.numTurns === 1 ? "" : "s"}`), h.costUsd != null) {
29
+ let e;
30
+ m[9] === h.costUsd ? e = m[10] : (e = h.costUsd.toFixed(4), m[9] = h.costUsd, m[10] = e), g.push(`$${e}`);
31
+ }
32
+ let e = h.usage?.inputTokens, _;
33
+ m[11] === e ? _ = m[12] : (_ = formatTokens(e), m[11] = e, m[12] = _);
34
+ let v = _, y = h.usage?.outputTokens, b;
35
+ m[13] === y ? b = m[14] : (b = formatTokens(y), m[13] = y, m[14] = b);
36
+ let x = b;
37
+ v && x && g.push(`${v} in / ${x} out`);
38
+ let S = (h.usage?.cacheReadInputTokens ?? 0) + (h.usage?.cacheCreationInputTokens ?? 0);
39
+ if (S) {
40
+ let e;
41
+ m[15] === S ? e = m[16] : (e = formatTokens(S), m[15] = S, m[16] = e), g.push(`${e} cache`);
42
+ }
43
+ if (h.durationMs != null) {
44
+ let e = h.durationMs / 1e3, _;
45
+ m[17] === e ? _ = m[18] : (_ = e.toFixed(1), m[17] = e, m[18] = _), g.push(`${_}s`);
46
+ }
47
+ h.model && g.push(h.model), m[0] = h.costUsd, m[1] = h.durationMs, m[2] = h.model, m[3] = h.numTurns, m[4] = h.usage?.cacheCreationInputTokens, m[5] = h.usage?.cacheReadInputTokens, m[6] = h.usage?.inputTokens, m[7] = h.usage?.outputTokens, m[8] = g;
48
+ } else g = m[8];
49
+ if (!g.length) return null;
50
+ let _ = g.join(" · "), v;
51
+ return m[19] === _ ? v = m[20] : (v = /* @__PURE__ */ jsx("div", {
52
+ className: "text-muted-foreground mt-1 px-1 font-mono text-xs",
53
+ children: _
54
+ }), m[19] = _, m[20] = v), v;
21
55
  };
22
56
  function hasStructuredBlocks(e) {
23
57
  return !!e?.some((e) => e.type !== "text");
@@ -25,81 +59,87 @@ function hasStructuredBlocks(e) {
25
59
  function textFromBlocks(e) {
26
60
  return (e ?? []).filter((e) => e.type === "text").map((e) => e.text).join("\n");
27
61
  }
28
- var LlmMessage_default = (h) => {
29
- let g = c(23), { document: C } = h, w = C.content, T = w.id ?? C.id, E = !!C.meta?.streaming;
30
- if (!hasStructuredBlocks(w.blocks)) {
31
- let h;
32
- g[0] !== w.blocks || g[1] !== w.text ? (h = w.text ?? textFromBlocks(w.blocks), g[0] = w.blocks, g[1] = w.text, g[2] = h) : h = g[2];
33
- let y = h, b;
34
- g[3] !== E || g[4] !== y ? (b = /* @__PURE__ */ jsx(MessageContent, { children: E ? /* @__PURE__ */ jsx(StreamingText, { text: y }) : /* @__PURE__ */ jsx(MessageResponse, { children: y }) }), g[3] = E, g[4] = y, g[5] = b) : b = g[5];
62
+ var LlmMessage_default = (m) => {
63
+ let h = c(31), { document: w } = m, T = w.content, E = T.id ?? w.id, D = !!w.meta?.streaming;
64
+ if (!hasStructuredBlocks(T.blocks)) {
65
+ let m;
66
+ h[0] !== T.blocks || h[1] !== T.text ? (m = T.text ?? textFromBlocks(T.blocks), h[0] = T.blocks, h[1] = T.text, h[2] = m) : m = h[2];
67
+ let v = m, y;
68
+ h[3] !== D || h[4] !== v ? (y = /* @__PURE__ */ jsx(MessageContent, { children: D ? /* @__PURE__ */ jsx(StreamingText, { text: v }) : /* @__PURE__ */ jsx(MessageResponse, { children: v }) }), h[3] = D, h[4] = v, h[5] = y) : y = h[5];
69
+ let b;
70
+ h[6] !== D || h[7] !== T.role || h[8] !== v ? (b = T.role === "assistant" && !D && /* @__PURE__ */ jsx(CopyActions, { text: v }), h[6] = D, h[7] = T.role, h[8] = v, h[9] = b) : b = h[9];
35
71
  let x;
36
- g[6] !== E || g[7] !== w.role || g[8] !== y ? (x = w.role === "assistant" && !E && /* @__PURE__ */ jsx(CopyActions, { text: y }), g[6] = E, g[7] = w.role, g[8] = y, g[9] = x) : x = g[9];
72
+ h[10] !== T.role || h[11] !== y || h[12] !== b ? (x = /* @__PURE__ */ jsxs(Message, {
73
+ from: T.role,
74
+ children: [y, b]
75
+ }), h[10] = T.role, h[11] = y, h[12] = b, h[13] = x) : x = h[13];
37
76
  let S;
38
- return g[10] !== w.role || g[11] !== b || g[12] !== x ? (S = /* @__PURE__ */ jsxs(Message, {
39
- from: w.role,
40
- children: [b, x]
41
- }), g[10] = w.role, g[11] = b, g[12] = x, g[13] = S) : S = g[13], S;
77
+ h[14] === T.meta ? S = h[15] : (S = T.meta && /* @__PURE__ */ jsx(CompletionMeta, { meta: T.meta }), h[14] = T.meta, h[15] = S);
78
+ let C;
79
+ return h[16] !== x || h[17] !== S ? (C = /* @__PURE__ */ jsxs(Fragment, { children: [x, S] }), h[16] = x, h[17] = S, h[18] = C) : C = h[18], C;
42
80
  }
43
- let D;
44
- g[14] === w.blocks ? D = g[15] : (D = w.blocks ?? [], g[14] = w.blocks, g[15] = D);
45
- let O = D, k;
46
- g[16] !== O || g[17] !== E || g[18] !== w.role || g[19] !== T ? (k = O.map((h, g) => {
47
- switch (h.type) {
81
+ let O;
82
+ h[19] === T.blocks ? O = h[20] : (O = T.blocks ?? [], h[19] = T.blocks, h[20] = O);
83
+ let k = O, A;
84
+ h[21] !== k || h[22] !== D || h[23] !== T.role || h[24] !== E ? (A = k.map((m, h) => {
85
+ switch (m.type) {
48
86
  case "text": return /* @__PURE__ */ jsxs(Message, {
49
- from: w.role,
50
- children: [/* @__PURE__ */ jsx(MessageContent, { children: E ? /* @__PURE__ */ jsx(StreamingText, { text: h.text }) : /* @__PURE__ */ jsx(MessageResponse, { children: h.text }) }), w.role === "assistant" && !E && /* @__PURE__ */ jsx(CopyActions, { text: h.text })]
51
- }, `${T}-${g}`);
87
+ from: T.role,
88
+ children: [/* @__PURE__ */ jsx(MessageContent, { children: D ? /* @__PURE__ */ jsx(StreamingText, { text: m.text }) : /* @__PURE__ */ jsx(MessageResponse, { children: m.text }) }), T.role === "assistant" && !D && /* @__PURE__ */ jsx(CopyActions, { text: m.text })]
89
+ }, `${E}-${h}`);
52
90
  case "thinking": return /* @__PURE__ */ jsxs(Reasoning, {
53
91
  className: "w-full",
54
- isStreaming: E,
55
- children: [/* @__PURE__ */ jsx(ReasoningTrigger, {}), /* @__PURE__ */ jsx(ReasoningContent, { children: h.text })]
56
- }, `${T}-${g}`);
92
+ isStreaming: D,
93
+ children: [/* @__PURE__ */ jsx(ReasoningTrigger, {}), /* @__PURE__ */ jsx(ReasoningContent, { children: m.text })]
94
+ }, `${E}-${h}`);
57
95
  case "tool_call": return /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(Message, {
58
96
  from: "assistant",
59
97
  children: /* @__PURE__ */ jsxs(Tool, { children: [/* @__PURE__ */ jsx(ToolHeader, {
60
98
  state: "input-available",
61
- title: h.name,
99
+ title: m.name,
62
100
  type: "tool-call"
63
- }), /* @__PURE__ */ jsx(ToolContent, { children: /* @__PURE__ */ jsx(ToolInput, { input: h.args }) })] })
64
- }) }, `${T}-${g}`);
101
+ }), /* @__PURE__ */ jsx(ToolContent, { children: /* @__PURE__ */ jsx(ToolInput, { input: m.args }) })] })
102
+ }) }, `${E}-${h}`);
65
103
  case "tool_result": {
66
- let _;
104
+ let g;
67
105
  try {
68
- _ = JSON.parse(h.content);
106
+ g = JSON.parse(m.content);
69
107
  } catch {
70
- _ = h.content;
108
+ g = m.content;
71
109
  }
72
110
  return /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(Message, {
73
111
  from: "assistant",
74
112
  children: /* @__PURE__ */ jsxs(Tool, { children: [/* @__PURE__ */ jsx(ToolHeader, {
75
- state: h.isError ? "output-error" : "output-available",
113
+ state: m.isError ? "output-error" : "output-available",
76
114
  title: "Tool Result",
77
115
  type: "tool-call"
78
116
  }), /* @__PURE__ */ jsx(ToolContent, { children: /* @__PURE__ */ jsx(ToolOutput, {
79
- output: _,
80
- errorText: h.isError ? h.content : ""
117
+ output: g,
118
+ errorText: m.isError ? m.content : ""
81
119
  }) })] })
82
- }) }, `${T}-${g}`);
120
+ }) }, `${E}-${h}`);
83
121
  }
84
122
  case "server_tool_use": {
85
- let _ = O.find((e) => e.type === "server_tool_result" && e.toolUseId === h.id);
123
+ let g = k.find((e) => e.type === "server_tool_result" && e.toolUseId === m.id);
86
124
  return /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(Message, {
87
125
  from: "assistant",
88
126
  children: /* @__PURE__ */ jsxs(Tool, { children: [/* @__PURE__ */ jsx(ToolHeader, {
89
- state: _ ? "output-available" : "input-available",
90
- title: h.name,
127
+ state: g ? "output-available" : "input-available",
128
+ title: m.name,
91
129
  type: "tool-call"
92
- }), /* @__PURE__ */ jsxs(ToolContent, { children: [/* @__PURE__ */ jsx(ToolInput, { input: h.input }), _ && /* @__PURE__ */ jsx(ToolOutput, {
93
- output: _.content,
130
+ }), /* @__PURE__ */ jsxs(ToolContent, { children: [/* @__PURE__ */ jsx(ToolInput, { input: m.input }), g && /* @__PURE__ */ jsx(ToolOutput, {
131
+ output: g.content,
94
132
  errorText: ""
95
133
  })] })] })
96
- }) }, `${T}-${g}`);
134
+ }) }, `${E}-${h}`);
97
135
  }
98
136
  case "server_tool_result": return null;
99
137
  default: return null;
100
138
  }
101
- }), g[16] = O, g[17] = E, g[18] = w.role, g[19] = T, g[20] = k) : k = g[20];
102
- let A;
103
- return g[21] === k ? A = g[22] : (A = /* @__PURE__ */ jsx(Fragment, { children: k }), g[21] = k, g[22] = A), A;
139
+ }), h[21] = k, h[22] = D, h[23] = T.role, h[24] = E, h[25] = A) : A = h[25];
140
+ let j;
141
+ h[26] === T.meta ? j = h[27] : (j = T.meta && /* @__PURE__ */ jsx(CompletionMeta, { meta: T.meta }), h[26] = T.meta, h[27] = j);
142
+ let M;
143
+ return h[28] !== A || h[29] !== j ? (M = /* @__PURE__ */ jsxs(Fragment, { children: [A, j] }), h[28] = A, h[29] = j, h[30] = M) : M = h[30], M;
104
144
  };
105
145
  export { LlmMessage_default as default };
@@ -5,6 +5,7 @@ import "../../feature-registry/index.js";
5
5
  import { useWorkbenchLayout } from "../../workbench/providers/WorkbenchLayoutProvider.js";
6
6
  import { SidebarPanel } from "../../workbench/components/SidebarPanel.js";
7
7
  import "../../workbench/index.js";
8
+ import { EnvironmentSelector } from "../../workbench/components/EnvironmentSelector.js";
8
9
  import { FileExplorerProvider, useOptionalFileExplorer } from "../providers/FileExplorerProvider.js";
9
10
  import { FileTabsBar } from "./FileTabsBar.js";
10
11
  import { FileTree } from "./FileTree.js";
@@ -12,109 +13,101 @@ import { c } from "react/compiler-runtime";
12
13
  import { jsx, jsxs } from "react/jsx-runtime";
13
14
  import { Files } from "lucide-react";
14
15
  function FileExplorerContent() {
15
- let i = c(7), a = useOptionalFileExplorer();
16
- if (!a) {
16
+ let o = c(7), s = useOptionalFileExplorer();
17
+ if (!s) {
17
18
  let e;
18
- return i[0] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ jsx("div", {
19
+ return o[0] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ jsx("div", {
19
20
  className: "flex flex-1 items-center justify-center p-4",
20
21
  children: /* @__PURE__ */ jsx("p", {
21
22
  className: "text-muted-foreground text-sm",
22
23
  children: "File explorer is not available for this workspace."
23
24
  })
24
- }), i[0] = e) : e = i[0], e;
25
+ }), o[0] = e) : e = o[0], e;
25
26
  }
26
- let o;
27
- i[1] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ jsx("div", {
27
+ let l;
28
+ o[1] === Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ jsx("div", {
28
29
  className: "w-52 shrink-0 overflow-auto border-r bg-muted/40",
29
30
  children: /* @__PURE__ */ jsx(FileTree, {})
30
- }), i[1] = o) : o = i[1];
31
- let s;
32
- i[2] === Symbol.for("react.memo_cache_sentinel") ? (s = /* @__PURE__ */ jsx(FileTabsBar, {}), i[2] = s) : s = i[2];
33
- let p;
34
- return i[3] !== a.fileContent || i[4] !== a.isContentLoading || i[5] !== a.selectedFile ? (p = /* @__PURE__ */ jsxs("div", {
31
+ }), o[1] = l) : l = o[1];
32
+ let u;
33
+ o[2] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ jsx(FileTabsBar, {}), o[2] = u) : u = o[2];
34
+ let d;
35
+ return o[3] !== s.fileContent || o[4] !== s.isContentLoading || o[5] !== s.selectedFile ? (d = /* @__PURE__ */ jsxs("div", {
35
36
  className: "flex h-full",
36
- children: [o, /* @__PURE__ */ jsxs("div", {
37
+ children: [l, /* @__PURE__ */ jsxs("div", {
37
38
  className: "flex min-w-0 flex-1 flex-col",
38
- children: [s, /* @__PURE__ */ jsx("div", {
39
+ children: [u, /* @__PURE__ */ jsx("div", {
39
40
  className: "flex-1 overflow-hidden p-3 pt-2",
40
41
  children: /* @__PURE__ */ jsx(FileContentViewer, {
41
- selectedFile: a.selectedFile,
42
- content: a.fileContent,
43
- isLoading: a.isContentLoading,
42
+ selectedFile: s.selectedFile,
43
+ content: s.fileContent,
44
+ isLoading: s.isContentLoading,
44
45
  className: "h-full"
45
46
  })
46
47
  })]
47
48
  })]
48
- }), i[3] = a.fileContent, i[4] = a.isContentLoading, i[5] = a.selectedFile, i[6] = p) : p = i[6], p;
49
+ }), o[3] = s.fileContent, o[4] = s.isContentLoading, o[5] = s.selectedFile, o[6] = d) : d = o[6], d;
49
50
  }
50
51
  function FileExplorerPanel(e) {
51
- let l = c(26), { variant: u, featureId: d, title: f, description: m, workspaceId: h } = e, { closePanel: g, panelSize: _, setPanelSize: v, environments: y } = useWorkbenchLayout(), b = useFeatureConfig(d), x;
52
- l[0] === b?.config?.environments ? x = l[1] : (x = b?.config?.environments ?? [], l[0] = b?.config?.environments, l[1] = x);
53
- let S = x, C = y?.[0]?.slotId ?? "", w;
54
- l[2] !== S || l[3] !== C ? (w = S.length === 0 || S.includes(C), l[2] = S, l[3] = C, l[4] = w) : w = l[4];
55
- let T = w;
56
- if (!T) {
57
- let e;
58
- l[5] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ jsx(Files, { className: "h-4 w-4" }), l[5] = e) : e = l[5];
59
- let i;
60
- l[6] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ jsx("div", {
61
- className: "flex flex-1 items-center justify-center p-4",
62
- children: /* @__PURE__ */ jsx("p", {
63
- className: "text-muted-foreground text-sm",
64
- children: "File explorer is not available for this environment."
65
- })
66
- }), l[6] = i) : i = l[6];
67
- let a;
68
- return l[7] !== g || l[8] !== m || l[9] !== _ || l[10] !== v || l[11] !== f ? (a = /* @__PURE__ */ jsx(SidebarPanel, {
69
- icon: e,
70
- title: f,
71
- description: m,
72
- size: _,
73
- onSizeChange: v,
74
- onClose: g,
75
- children: i
76
- }), l[7] = g, l[8] = m, l[9] = _, l[10] = v, l[11] = f, l[12] = a) : a = l[12], a;
77
- }
78
- let E;
79
- l[13] === Symbol.for("react.memo_cache_sentinel") ? (E = /* @__PURE__ */ jsx(Files, { className: "h-4 w-4" }), l[13] = E) : E = l[13];
80
- let D;
81
- l[14] === Symbol.for("react.memo_cache_sentinel") ? (D = /* @__PURE__ */ jsx(FileExplorerContent, {}), l[14] = D) : D = l[14];
82
- let O;
83
- l[15] !== T || l[16] !== u || l[17] !== h ? (O = /* @__PURE__ */ jsx(FileExplorerProvider, {
84
- variant: u,
85
- workspaceId: h,
86
- enabled: T,
87
- children: D
88
- }), l[15] = T, l[16] = u, l[17] = h, l[18] = O) : O = l[18];
89
- let k;
90
- return l[19] !== g || l[20] !== m || l[21] !== _ || l[22] !== v || l[23] !== O || l[24] !== f ? (k = /* @__PURE__ */ jsx(SidebarPanel, {
91
- icon: E,
92
- title: f,
93
- description: m,
94
- size: _,
95
- onSizeChange: v,
96
- onClose: g,
97
- children: O
98
- }), l[19] = g, l[20] = m, l[21] = _, l[22] = v, l[23] = O, l[24] = f, l[25] = k) : k = l[25], k;
52
+ let f = c(24), { variant: p, featureId: m, title: h, description: g, workspaceId: _ } = e, { closePanel: v, panelSize: y, setPanelSize: b, environments: x, selectedSlotId: S } = useWorkbenchLayout(), C = useFeatureConfig(m), w;
53
+ f[0] === C?.config?.environments ? w = f[1] : (w = C?.config?.environments ?? [], f[0] = C?.config?.environments, f[1] = w);
54
+ let T = w, E;
55
+ f[2] !== x || f[3] !== S ? (E = x?.find((e) => e.slotId === S), f[2] = x, f[3] = S, f[4] = E) : E = f[4];
56
+ let D = E, O;
57
+ f[5] !== T || f[6] !== S ? (O = T.length === 0 || T.includes(S), f[5] = T, f[6] = S, f[7] = O) : O = f[7];
58
+ let k = O, A = !D || D.status === "running", j = k && A, M;
59
+ f[8] === Symbol.for("react.memo_cache_sentinel") ? (M = /* @__PURE__ */ jsx(Files, { className: "h-4 w-4" }), f[8] = M) : M = f[8];
60
+ let N;
61
+ f[9] === Symbol.for("react.memo_cache_sentinel") ? (N = /* @__PURE__ */ jsx(EnvironmentSelector, {}), f[9] = N) : N = f[9];
62
+ let P;
63
+ f[10] !== k || f[11] !== j || f[12] !== A || f[13] !== S || f[14] !== p || f[15] !== _ ? (P = k ? A ? /* @__PURE__ */ jsx(FileExplorerProvider, {
64
+ variant: p,
65
+ workspaceId: _,
66
+ slotId: S || void 0,
67
+ enabled: j,
68
+ children: /* @__PURE__ */ jsx(FileExplorerContent, {})
69
+ }) : /* @__PURE__ */ jsx("div", {
70
+ className: "flex flex-1 items-center justify-center p-4",
71
+ children: /* @__PURE__ */ jsx("p", {
72
+ className: "text-muted-foreground text-sm",
73
+ children: "This environment is not available (stopped)."
74
+ })
75
+ }) : /* @__PURE__ */ jsx("div", {
76
+ className: "flex flex-1 items-center justify-center p-4",
77
+ children: /* @__PURE__ */ jsx("p", {
78
+ className: "text-muted-foreground text-sm",
79
+ children: "File explorer is not available for this environment."
80
+ })
81
+ }), f[10] = k, f[11] = j, f[12] = A, f[13] = S, f[14] = p, f[15] = _, f[16] = P) : P = f[16];
82
+ let F;
83
+ return f[17] !== v || f[18] !== g || f[19] !== y || f[20] !== b || f[21] !== P || f[22] !== h ? (F = /* @__PURE__ */ jsxs(SidebarPanel, {
84
+ icon: M,
85
+ title: h,
86
+ description: g,
87
+ size: y,
88
+ onSizeChange: b,
89
+ onClose: v,
90
+ children: [N, P]
91
+ }), f[17] = v, f[18] = g, f[19] = y, f[20] = b, f[21] = P, f[22] = h, f[23] = F) : F = f[23], F;
99
92
  }
100
93
  function LocalFileExplorerPanel(e) {
101
- let i = c(2), { workspaceId: a } = e, o;
102
- return i[0] === a ? o = i[1] : (o = /* @__PURE__ */ jsx(FileExplorerPanel, {
94
+ let o = c(2), { workspaceId: s } = e, l;
95
+ return o[0] === s ? l = o[1] : (l = /* @__PURE__ */ jsx(FileExplorerPanel, {
103
96
  variant: "local",
104
97
  featureId: "localFileExplorer",
105
98
  title: "Files",
106
99
  description: "Browse and view local project files.",
107
- workspaceId: a
108
- }), i[0] = a, i[1] = o), o;
100
+ workspaceId: s
101
+ }), o[0] = s, o[1] = l), l;
109
102
  }
110
103
  function RemoteFileExplorerPanel(e) {
111
- let i = c(2), { workspaceId: a } = e, o;
112
- return i[0] === a ? o = i[1] : (o = /* @__PURE__ */ jsx(FileExplorerPanel, {
104
+ let o = c(2), { workspaceId: s } = e, l;
105
+ return o[0] === s ? l = o[1] : (l = /* @__PURE__ */ jsx(FileExplorerPanel, {
113
106
  variant: "remote",
114
107
  featureId: "remoteFileExplorer",
115
108
  title: "Remote Files",
116
109
  description: "Browse and view files on the remote workspace.",
117
- workspaceId: a
118
- }), i[0] = a, i[1] = o), o;
110
+ workspaceId: s
111
+ }), o[0] = s, o[1] = l), l;
119
112
  }
120
113
  export { LocalFileExplorerPanel, RemoteFileExplorerPanel };
@@ -14,38 +14,42 @@ function fileTreeKey(e, n, r) {
14
14
  ...r ? [r] : []
15
15
  ];
16
16
  }
17
- function useFileTree(i, o, s) {
18
- let l = c(12), u = s === void 0 ? !0 : s, d = useLoopstackClient(), f;
19
- l[0] !== d.envKey || l[1] !== i || l[2] !== o ? (f = fileTreeKey(d.envKey, i, o), l[0] = d.envKey, l[1] = i, l[2] = o, l[3] = f) : f = l[3];
20
- let p;
21
- l[4] !== d.http || l[5] !== i || l[6] !== o ? (p = () => d.http.get(`${explorerPath(i, o)}/tree`), l[4] = d.http, l[5] = i, l[6] = o, l[7] = p) : p = l[7];
22
- let m = !!o && u, h;
23
- return l[8] !== f || l[9] !== p || l[10] !== m ? (h = {
24
- queryKey: f,
25
- queryFn: p,
26
- enabled: m,
17
+ function useFileTree(i, o, s, l) {
18
+ let u = c(14), d = l === void 0 ? !0 : l, f = useLoopstackClient(), p;
19
+ u[0] !== f.envKey || u[1] !== s || u[2] !== i || u[3] !== o ? (p = [...fileTreeKey(f.envKey, i, o), s ?? ""], u[0] = f.envKey, u[1] = s, u[2] = i, u[3] = o, u[4] = p) : p = u[4];
20
+ let m;
21
+ u[5] !== f.http || u[6] !== s || u[7] !== i || u[8] !== o ? (m = () => f.http.get(`${explorerPath(i, o)}/tree`, s ? { slotId: s } : void 0), u[5] = f.http, u[6] = s, u[7] = i, u[8] = o, u[9] = m) : m = u[9];
22
+ let h = !!o && d, g;
23
+ return u[10] !== p || u[11] !== m || u[12] !== h ? (g = {
24
+ queryKey: p,
25
+ queryFn: m,
26
+ enabled: h,
27
27
  staleTime: 3e4,
28
28
  retry: !1
29
- }, l[8] = f, l[9] = p, l[10] = m, l[11] = h) : h = l[11], useQuery(h);
29
+ }, u[10] = p, u[11] = m, u[12] = h, u[13] = g) : g = u[13], useQuery(g);
30
30
  }
31
- function useFileContent(i, a, o, s) {
32
- let l = c(14), u = s === void 0 ? !0 : s, d = useLoopstackClient(), f;
33
- l[0] !== d.envKey || l[1] !== o || l[2] !== i || l[3] !== a ? (f = [
31
+ function useFileContent(i, a, o, s, l) {
32
+ let u = c(16), d = l === void 0 ? !0 : l, f = useLoopstackClient(), p = s ?? "", m;
33
+ u[0] !== f.envKey || u[1] !== o || u[2] !== p || u[3] !== i || u[4] !== a ? (m = [
34
34
  "file-explorer-content",
35
- d.envKey,
35
+ f.envKey,
36
36
  i,
37
37
  a,
38
- o
39
- ], l[0] = d.envKey, l[1] = o, l[2] = i, l[3] = a, l[4] = f) : f = l[4];
40
- let p;
41
- l[5] !== d.http || l[6] !== o || l[7] !== i || l[8] !== a ? (p = () => d.http.get(`${explorerPath(i, a)}/read`, { path: o }), l[5] = d.http, l[6] = o, l[7] = i, l[8] = a, l[9] = p) : p = l[9];
42
- let m = !!a && !!o && u, h;
43
- return l[10] !== f || l[11] !== p || l[12] !== m ? (h = {
44
- queryKey: f,
45
- queryFn: p,
46
- enabled: m,
38
+ o,
39
+ p
40
+ ], u[0] = f.envKey, u[1] = o, u[2] = p, u[3] = i, u[4] = a, u[5] = m) : m = u[5];
41
+ let h;
42
+ u[6] !== f.http || u[7] !== o || u[8] !== s || u[9] !== i || u[10] !== a ? (h = () => f.http.get(`${explorerPath(i, a)}/read`, {
43
+ path: o,
44
+ ...s ? { slotId: s } : {}
45
+ }), u[6] = f.http, u[7] = o, u[8] = s, u[9] = i, u[10] = a, u[11] = h) : h = u[11];
46
+ let g = !!a && !!o && d, _;
47
+ return u[12] !== m || u[13] !== h || u[14] !== g ? (_ = {
48
+ queryKey: m,
49
+ queryFn: h,
50
+ enabled: g,
47
51
  staleTime: 15e3,
48
52
  retry: !1
49
- }, l[10] = f, l[11] = p, l[12] = m, l[13] = h) : h = l[13], useQuery(h);
53
+ }, u[12] = m, u[13] = h, u[14] = g, u[15] = _) : _ = u[15], useQuery(_);
50
54
  }
51
55
  export { fileTreeKey, useFileContent, useFileTree };