@burdenoff/microfe-vibecontrols 2026.1117.2 → 2026.1123.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.
@@ -2,18 +2,19 @@ import { VIBE_PERMISSIONS as e } from "../../constants/permissions.js";
2
2
  import { useTr as t } from "../../shared/hooks/useTr.js";
3
3
  import { useAgentCodeServerStartMutation as n, useAgentCodeServerStatusLazyQuery as r, useAgentCodeServerStopMutation as i, useMintAgentCapabilityMutation as a } from "../../generated/wspace-operations.js";
4
4
  import { AgentCapabilityScope as o } from "../../generated/wspace-types.js";
5
- import { useCallback as s, useEffect as c, useState as l } from "react";
6
- import { AlertCircle as u, Check as d, Code as f, Loader2 as p, X as m } from "lucide-react";
7
- import { usePermissions as h } from "@burdenoff/fe-libs/shared/providers/shell";
8
- import { jsx as g, jsxs as _ } from "react/jsx-runtime";
5
+ import { getSafeTunnelIframeUrl as s } from "../../utils/iframeUrl.js";
6
+ import { useCallback as c, useEffect as l, useState as u } from "react";
7
+ import { AlertCircle as d, Check as f, Code as p, Loader2 as m, X as h } from "lucide-react";
8
+ import { usePermissions as g } from "@burdenoff/fe-libs/shared/providers/shell";
9
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
9
10
  // src/components/agents/OpenInBrowserEditorButton.tsx
10
- var v = "default";
11
- function y({ agentId: c, tunnelUrl: m, profile: g, workspacePath: _, mode: y = "newtab", onIframeUrl: b }) {
12
- let x = t(), { hasPermission: S } = h(), C = S(e.AGENT_MUTATE), w = S(e.AGENT_INVOKE), [T, E] = l("idle"), [D, O] = l(null), [k] = r({ fetchPolicy: "network-only" }), [A] = n(), [j] = i(), [M] = a(), N = s(async (e) => {
13
- let t = (await k({ variables: {
14
- agentId: c,
11
+ var y = "default";
12
+ function b({ agentId: l, tunnelUrl: h, profile: _, workspacePath: v, mode: b = "newtab", onIframeUrl: x }) {
13
+ let S = t(), { hasPermission: C } = g(), w = C(e.AGENT_MUTATE), T = C(e.AGENT_INVOKE), [E, D] = u("idle"), [O, k] = u(null), [A] = r({ fetchPolicy: "network-only" }), [j] = n(), [M] = i(), [N] = a(), P = c(async (e) => {
14
+ let t = (await A({ variables: {
15
+ agentId: l,
15
16
  profile: e,
16
- name: v
17
+ name: y
17
18
  } })).data?.agentCodeServerStatus;
18
19
  if (!t) return {
19
20
  effective: null,
@@ -31,117 +32,115 @@ function y({ agentId: c, tunnelUrl: m, profile: g, workspacePath: _, mode: y = "
31
32
  status: t.data ?? {},
32
33
  missing: !1
33
34
  };
34
- }, [k, c]), P = s(async () => {
35
- if (!C || !w) {
36
- O(x("common.noPermission", "You do not have permission")), E("error");
35
+ }, [A, l]), F = c(async () => {
36
+ if (!w || !T) {
37
+ k(S("common.noPermission", "You do not have permission")), D("error");
37
38
  return;
38
39
  }
39
- if (!c || !m) {
40
- O("Agent not selected"), E("error");
40
+ if (!l || !h) {
41
+ k("Agent not selected"), D("error");
41
42
  return;
42
43
  }
43
- O(null);
44
+ k(null);
44
45
  let e = null;
45
- y !== "iframe" && (e = window.open("about:blank", "_blank"));
46
+ b !== "iframe" && (e = window.open("about:blank", "_blank"), e && (e.opener = null));
46
47
  try {
47
- E("checking");
48
- let t = g === "default" ? ["default"] : [g, "default"], n = null, r = null;
48
+ D("checking");
49
+ let t = _ === "default" ? ["default"] : [_, "default"], n = null, r = null;
49
50
  for (let e of t) {
50
- let { effective: t, status: i, missing: a } = await N(e);
51
+ let { effective: t, status: i, missing: a } = await P(e);
51
52
  if (!a && t) {
52
53
  n = t, r = i;
53
54
  break;
54
55
  }
55
56
  }
56
- if (!n || !r || !r.installed) throw Error(x("vibecontrols.agents.editor.notInstalled", "Code-server isn't installed on this agent. Install it from the Plugins tab to enable Open Editor."));
57
+ if (!n || !r || !r.installed) throw Error(S("vibecontrols.agents.editor.notInstalled", "Code-server isn't installed on this agent. Install it from the Plugins tab to enable Open Editor."));
57
58
  if (!r.running) {
58
- E("starting");
59
- let e = (await A({ variables: {
60
- agentId: c,
59
+ D("starting");
60
+ let e = (await j({ variables: {
61
+ agentId: l,
61
62
  profile: n,
62
- name: v,
63
- ..._ ? { path: _ } : {}
63
+ name: y,
64
+ ...v ? { path: v } : {}
64
65
  } })).data?.agentCodeServerStart;
65
66
  if (!e?.ok) throw Error(e?.error || `Start failed: HTTP ${e?.status ?? 0}`);
66
67
  await new Promise((e) => setTimeout(e, 1e3));
67
- } else if (_) {
68
- E("starting"), await j({ variables: {
69
- agentId: c,
68
+ } else if (v) {
69
+ D("starting"), await M({ variables: {
70
+ agentId: l,
70
71
  profile: n,
71
- name: v
72
+ name: y
72
73
  } });
73
- let e = (await A({ variables: {
74
- agentId: c,
74
+ let e = (await j({ variables: {
75
+ agentId: l,
75
76
  profile: n,
76
- name: v,
77
- path: _
77
+ name: y,
78
+ path: v
78
79
  } })).data?.agentCodeServerStart;
79
80
  if (!e?.ok) throw Error(e?.error || `Restart failed: HTTP ${e?.status ?? 0}`);
80
81
  await new Promise((e) => setTimeout(e, 1e3));
81
82
  }
82
- E("ready");
83
- let i = (await M({ variables: {
84
- agentId: c,
83
+ D("ready");
84
+ let i = (await N({ variables: {
85
+ agentId: l,
85
86
  profile: n,
86
87
  scope: o.IframePlugin,
87
- resourceId: `code-server:${v}`,
88
+ resourceId: `code-server:${y}`,
88
89
  ttlSeconds: 60
89
90
  } })).data?.mintAgentCapability?.token;
90
91
  if (!i) throw Error("Failed to mint editor capability");
91
- let a = `${m.replace(/\/$/, "")}/code-server/?vt=${encodeURIComponent(i)}`;
92
- if (y === "iframe" && b) b(a);
93
- else if (e && !e.closed) e.location.replace(a);
94
- else if (!window.open(a, "_blank")) throw Error(x("vibecontrols.agents.editor.popupBlocked", "Your browser blocked the editor tab. Allow pop-ups for this site, then click Open Editor again."));
95
- setTimeout(() => E("idle"), 2e3);
92
+ let a = h.replace(/\/$/, ""), c = s(`${a}/code-server/?vt=${encodeURIComponent(i)}`);
93
+ if (!c) throw Error("Invalid editor URL");
94
+ b === "iframe" && x ? x(c) : e && !e.closed ? e.location.replace(c) : window.open(c, "_blank", "noopener,noreferrer"), setTimeout(() => D("idle"), 2e3);
96
95
  } catch (t) {
97
- e && !e.closed && e.close(), O(t instanceof Error ? t.message : "Failed to open editor"), E("error");
96
+ e && !e.closed && e.close(), k(t instanceof Error ? t.message : "Failed to open editor"), D("error");
98
97
  }
99
98
  }, [
100
- c,
101
- m,
102
- g,
99
+ l,
100
+ h,
103
101
  _,
104
- y,
102
+ v,
105
103
  b,
106
104
  x,
107
- C,
105
+ S,
108
106
  w,
109
- N,
110
- A,
107
+ T,
108
+ P,
111
109
  j,
112
- M
113
- ]), F = !C || !w || !c || !m || T !== "idle" && T !== "error" && T !== "ready", I = (() => {
114
- switch (T) {
115
- case "checking": return x("vibecontrols.agents.editor.checking", "Checking...");
116
- case "installing": return x("vibecontrols.agents.editor.installing", "Installing...");
117
- case "starting": return x("vibecontrols.agents.editor.starting", "Starting...");
118
- case "ready": return x("vibecontrols.agents.editor.opened", "Opened");
119
- case "error": return x("vibecontrols.agents.editor.retry", "Retry");
120
- default: return x("vibecontrols.agents.editor.openEditor", "Open Editor");
110
+ M,
111
+ N
112
+ ]), I = !w || !T || !l || !h || E !== "idle" && E !== "error" && E !== "ready", L = (() => {
113
+ switch (E) {
114
+ case "checking": return S("vibecontrols.agents.editor.checking", "Checking...");
115
+ case "installing": return S("vibecontrols.agents.editor.installing", "Installing...");
116
+ case "starting": return S("vibecontrols.agents.editor.starting", "Starting...");
117
+ case "ready": return S("vibecontrols.agents.editor.opened", "Opened");
118
+ case "error": return S("vibecontrols.agents.editor.retry", "Retry");
119
+ default: return S("vibecontrols.agents.editor.openEditor", "Open Editor");
121
120
  }
122
- })(), L = (() => {
123
- switch (T) {
121
+ })(), R = (() => {
122
+ switch (E) {
124
123
  case "checking":
125
124
  case "installing":
126
- case "starting": return p;
127
- case "ready": return d;
128
- case "error": return u;
129
- default: return f;
125
+ case "starting": return m;
126
+ case "ready": return f;
127
+ case "error": return d;
128
+ default: return p;
130
129
  }
131
- })(), R = T === "checking" || T === "installing" || T === "starting";
130
+ })(), z = E === "checking" || E === "installing" || E === "starting";
132
131
  return {
133
- launch: P,
134
- state: T,
135
- errorMsg: D,
136
- dismissError: s(() => O(null), []),
137
- label: I,
138
- Icon: L,
139
- isSpinning: R,
140
- isDisabled: F
132
+ launch: F,
133
+ state: E,
134
+ errorMsg: O,
135
+ dismissError: c(() => k(null), []),
136
+ label: L,
137
+ Icon: R,
138
+ isSpinning: z,
139
+ isDisabled: I
141
140
  };
142
141
  }
143
- function b({ agentId: e, tunnelUrl: n, profile: r, workspacePath: i, mode: a = "newtab", onIframeUrl: o, className: s }) {
144
- let l = t(), { launch: d, state: f, errorMsg: p, dismissError: h, label: v, Icon: b, isSpinning: x, isDisabled: S } = y({
142
+ function x({ agentId: e, tunnelUrl: n, profile: r, workspacePath: i, mode: a = "newtab", onIframeUrl: o, className: s }) {
143
+ let c = t(), { launch: u, state: f, errorMsg: p, dismissError: m, label: g, Icon: y, isSpinning: x, isDisabled: S } = b({
145
144
  agentId: e,
146
145
  tunnelUrl: n,
147
146
  profile: r,
@@ -149,49 +148,49 @@ function b({ agentId: e, tunnelUrl: n, profile: r, workspacePath: i, mode: a = "
149
148
  mode: a,
150
149
  onIframeUrl: o
151
150
  }), C = f === "error" && !!p;
152
- return c(() => {
151
+ return l(() => {
153
152
  if (!C) return;
154
153
  let e = (e) => {
155
- e.key === "Escape" && h();
154
+ e.key === "Escape" && m();
156
155
  };
157
156
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
158
- }, [C, h]), /* @__PURE__ */ _("div", {
157
+ }, [C, m]), /* @__PURE__ */ v("div", {
159
158
  className: "relative inline-flex",
160
- children: [/* @__PURE__ */ _("button", {
159
+ children: [/* @__PURE__ */ v("button", {
161
160
  type: "button",
162
- onClick: () => void d(),
161
+ onClick: () => void u(),
163
162
  disabled: S,
164
- "aria-label": v,
163
+ "aria-label": g,
165
164
  "aria-busy": x,
166
165
  className: `flex items-center gap-1.5 px-2.5 py-1.5 sm:px-3 sm:py-2 max-md:min-h-11 text-xs sm:text-sm rounded-md transition-colors disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus ${f === "error" ? "bg-status-error-bg-subtle text-status-error-text hover:opacity-80" : f === "ready" ? "bg-status-success-bg-subtle text-status-success-text" : "bg-bg-sunken text-text-primary hover:bg-bg-elevated"} ${s || ""}`,
167
166
  title: p || "Open VS Code in browser via code-server",
168
- children: [/* @__PURE__ */ g(b, {
167
+ children: [/* @__PURE__ */ _(y, {
169
168
  "aria-hidden": "true",
170
169
  className: `size-3.5 sm:size-4 ${x ? "animate-spin" : ""}`
171
- }), /* @__PURE__ */ g("span", {
170
+ }), /* @__PURE__ */ _("span", {
172
171
  className: "hidden sm:inline",
173
- children: v
172
+ children: g
174
173
  })]
175
- }), C && /* @__PURE__ */ g("div", {
174
+ }), C && /* @__PURE__ */ _("div", {
176
175
  role: "alert",
177
176
  className: "absolute top-full right-0 mt-1.5 z-50 w-72 max-w-[calc(100vw-2rem)] rounded-md border border-status-error-border bg-bg-surface p-3 text-xs leading-relaxed text-status-error-text whitespace-normal break-words shadow-[var(--shadow-elevation-2)]",
178
- children: /* @__PURE__ */ _("div", {
177
+ children: /* @__PURE__ */ v("div", {
179
178
  className: "flex items-start gap-2",
180
179
  children: [
181
- /* @__PURE__ */ g(u, {
180
+ /* @__PURE__ */ _(d, {
182
181
  className: "mt-0.5 size-4 shrink-0",
183
182
  "aria-hidden": "true"
184
183
  }),
185
- /* @__PURE__ */ g("span", {
184
+ /* @__PURE__ */ _("span", {
186
185
  className: "min-w-0 flex-1",
187
186
  children: p
188
187
  }),
189
- /* @__PURE__ */ g("button", {
188
+ /* @__PURE__ */ _("button", {
190
189
  type: "button",
191
- onClick: h,
192
- "aria-label": l("vibecontrols.agents.editor.close", "Close"),
190
+ onClick: m,
191
+ "aria-label": c("vibecontrols.agents.editor.close", "Close"),
193
192
  className: "-m-1 inline-flex size-6 shrink-0 items-center justify-center rounded-button text-status-error-text transition-colors hover:bg-bg-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
194
- children: /* @__PURE__ */ g(m, {
193
+ children: /* @__PURE__ */ _(h, {
195
194
  className: "size-3.5",
196
195
  "aria-hidden": "true"
197
196
  })
@@ -201,4 +200,4 @@ function b({ agentId: e, tunnelUrl: n, profile: r, workspacePath: i, mode: a = "
201
200
  })]
202
201
  });
203
202
  }
204
- export { b as OpenInBrowserEditorButton, y as useBrowserEditorLauncher };
203
+ export { x as OpenInBrowserEditorButton, b as useBrowserEditorLauncher };