@agent-native/core 0.129.0 → 0.129.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/corpus/README.md CHANGED
@@ -30,4 +30,4 @@ rg -n "defineAction|useActionQuery" node_modules/@agent-native/core/corpus
30
30
 
31
31
  - core files: 1629
32
32
  - toolkit files: 160
33
- - template files: 6868
33
+ - template files: 6870
@@ -1,5 +1,17 @@
1
1
  # @agent-native/core
2
2
 
3
+ ## 0.129.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 21e33c7: Keep asynchronous `ask_app` task handles and exact polling arguments visible to MCP callers so they can retrieve the same cross-app task without resubmitting it.
8
+
9
+ ## 0.129.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 8c4b44e: Keep the create organization and invite member popovers compact instead of allowing long helper text to expand their width.
14
+
3
15
  ## 0.129.0
4
16
 
5
17
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.129.0",
3
+ "version": "0.129.2",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -418,7 +418,7 @@ export function OrgSwitcher({
418
418
  align="start"
419
419
  sideOffset={6}
420
420
  collisionPadding={12}
421
- className={POPOVER_CONTENT_CLASS}
421
+ className={`${POPOVER_CONTENT_CLASS} ${mode === "list" ? "" : "w-64"}`}
422
422
  onOpenAutoFocus={(e) => {
423
423
  // Don't auto-focus the first item — feels heavy on a switcher.
424
424
  if (mode === "list") e.preventDefault();
@@ -692,9 +692,9 @@ export function OrgSwitcher({
692
692
  <div className="px-0.5 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground">
693
693
  New organization
694
694
  </div>
695
- <p className="flex items-start gap-1.5 px-0.5 pb-1.5 text-[11px] leading-snug text-muted-foreground">
696
- <IconKey className="mt-0.5 h-3 w-3 shrink-0" />
697
- <span>{t("org.createOrgVaultNotice")}</span>
695
+ <p className="pe-0.5 pb-1.5 ps-2 text-[11px] leading-snug text-muted-foreground">
696
+ <IconKey className="me-1.5 inline-block h-3 w-3 align-text-top" />
697
+ {t("org.createOrgVaultNotice")}
698
698
  </p>
699
699
  <input
700
700
  autoFocus
@@ -70,6 +70,12 @@ import {
70
70
  verifyMcpOAuthAccessToken,
71
71
  } from "./oauth-token.js";
72
72
 
73
+ const PRESERVE_MCP_OBJECT_RESULT = Symbol("preserveMcpObjectResult");
74
+
75
+ type MCPActionEntry = ActionEntry & {
76
+ [PRESERVE_MCP_OBJECT_RESULT]?: true;
77
+ };
78
+
73
79
  export interface MCPConfig {
74
80
  /** App name shown in MCP server info */
75
81
  name: string;
@@ -965,7 +971,16 @@ function mergeBuiltinTools(
965
971
  requestMeta?: MCPRequestMeta,
966
972
  ): Record<string, ActionEntry> {
967
973
  if (config.builtinCrossAppTools === false) return baseActions;
968
- const builtins = getBuiltinCrossAppTools(config, requestMeta);
974
+ const builtins = getBuiltinCrossAppTools(config, requestMeta) as Record<
975
+ string,
976
+ MCPActionEntry
977
+ >;
978
+ // Async ask_app responses contain the opaque handle needed to poll the same
979
+ // task. Mark the actual framework builtin rather than matching by name: an
980
+ // app-defined ask_app overrides this entry and keeps normal concise output.
981
+ if (builtins.ask_app) {
982
+ builtins.ask_app[PRESERVE_MCP_OBJECT_RESULT] = true;
983
+ }
969
984
  const merged: Record<string, ActionEntry> = { ...builtins };
970
985
  // Template / app actions overwrite same-named builtins.
971
986
  for (const [name, entry] of Object.entries(baseActions)) {
@@ -2127,7 +2142,10 @@ export async function createMCPServerForRequest(
2127
2142
  const text = mcpAppResource
2128
2143
  ? conciseMcpAppToolText(name, resultForClient, structuredContent!)
2129
2144
  : conciseToolResultText(name, resultForClient, {
2130
- preserveObjectResult: entry.readOnly === true,
2145
+ preserveObjectResult:
2146
+ entry.readOnly === true ||
2147
+ (entry as MCPActionEntry)[PRESERVE_MCP_OBJECT_RESULT] ===
2148
+ true,
2131
2149
  });
2132
2150
  const content: any[] = [{ type: "text", text }];
2133
2151
  if (block) content.push(block);
@@ -1,9 +1,9 @@
1
- import { useActionQuery } from "@agent-native/core/client/hooks";
1
+ import { useActionQuery, useAvatarUrl } from "@agent-native/core/client/hooks";
2
2
  import { useT } from "@agent-native/core/client/i18n";
3
3
  import { IconTerminal2, IconUser } from "@tabler/icons-react";
4
4
  import { useState } from "react";
5
5
 
6
- import { Avatar, AvatarFallback } from "@/components/ui/avatar";
6
+ import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
7
7
  import { Button } from "@/components/ui/button";
8
8
  import {
9
9
  Popover,
@@ -284,8 +284,12 @@ export function ViewerAvatar({
284
284
  className?: string;
285
285
  }) {
286
286
  const anonymous = !viewer.viewerName && !viewer.viewerEmail;
287
+ const avatarUrl = useAvatarUrl(viewer.viewerEmail);
288
+ const label = viewer.viewerName || viewer.viewerEmail || "";
289
+
287
290
  return (
288
291
  <Avatar className={cn("h-6 w-6 shrink-0", className)}>
292
+ {avatarUrl ? <AvatarImage src={avatarUrl} alt={label} /> : null}
289
293
  <AvatarFallback className="bg-primary text-[10px] text-primary-foreground">
290
294
  {anonymous ? (
291
295
  <IconUser className="h-3 w-3" />
@@ -16,6 +16,11 @@ import {
16
16
  import { useQueryClient } from "@tanstack/react-query";
17
17
  import { useMemo, useState } from "react";
18
18
 
19
+ import {
20
+ Avatar as UserAvatar,
21
+ AvatarFallback as UserAvatarFallback,
22
+ AvatarImage as UserAvatarImage,
23
+ } from "@/components/ui/avatar";
19
24
  import { Button } from "@/components/ui/button";
20
25
  import { Checkbox } from "@/components/ui/checkbox";
21
26
  import { Input } from "@/components/ui/input";
@@ -26,6 +31,7 @@ import {
26
31
  SelectTrigger,
27
32
  SelectValue,
28
33
  } from "@/components/ui/select";
34
+ import { useVisibleAvatarUrl } from "@/lib/use-visible-avatar-url";
29
35
  import { cn } from "@/lib/utils";
30
36
 
31
37
  // ---------------------------------------------------------------------------
@@ -304,17 +310,26 @@ export function CopyField({
304
310
  // ---------------------------------------------------------------------------
305
311
 
306
312
  export function Avatar({ label, org }: { label: string; org?: boolean }) {
307
- return (
308
- <span
309
- aria-hidden
310
- className="inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-muted text-[11px] font-semibold text-muted-foreground"
311
- >
312
- {org ? (
313
+ const { avatarRef, avatarUrl } = useVisibleAvatarUrl(org ? null : label);
314
+
315
+ if (org) {
316
+ return (
317
+ <span
318
+ aria-hidden
319
+ className="inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-muted text-[11px] font-semibold text-muted-foreground"
320
+ >
313
321
  <IconUsersGroup size={14} strokeWidth={1.75} />
314
- ) : (
315
- (label.split("@")[0]?.[0] ?? label[0] ?? "?").toUpperCase()
316
- )}
317
- </span>
322
+ </span>
323
+ );
324
+ }
325
+
326
+ return (
327
+ <UserAvatar ref={avatarRef} className="h-7 w-7 shrink-0">
328
+ {avatarUrl ? <UserAvatarImage src={avatarUrl} alt={label} /> : null}
329
+ <UserAvatarFallback className="bg-muted text-[11px] font-semibold text-muted-foreground">
330
+ {(label.split("@")[0]?.[0] ?? label[0] ?? "?").toUpperCase()}
331
+ </UserAvatarFallback>
332
+ </UserAvatar>
318
333
  );
319
334
  }
320
335
 
@@ -2,12 +2,13 @@ import { useActionQuery } from "@agent-native/core/client/hooks";
2
2
  import { useFormatters, useT } from "@agent-native/core/client/i18n";
3
3
  import { useState } from "react";
4
4
 
5
- import { Avatar, AvatarFallback } from "@/components/ui/avatar";
5
+ import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
6
6
  import {
7
7
  Popover,
8
8
  PopoverContent,
9
9
  PopoverTrigger,
10
10
  } from "@/components/ui/popover";
11
+ import { useVisibleAvatarUrl } from "@/lib/use-visible-avatar-url";
11
12
  import { cn } from "@/lib/utils";
12
13
 
13
14
  interface ClipViewRecord {
@@ -100,11 +101,11 @@ export function ViewedByPopover({
100
101
  key={v.id}
101
102
  className="flex items-center gap-2 rounded-md px-2 py-1.5"
102
103
  >
103
- <Avatar className="h-6 w-6 shrink-0">
104
- <AvatarFallback className="text-[10px] bg-primary text-primary-foreground">
105
- {initials(v.viewerName || v.viewerEmail || "?")}
106
- </AvatarFallback>
107
- </Avatar>
104
+ <ViewerAvatar
105
+ email={v.viewerEmail}
106
+ name={v.viewerName}
107
+ label={label}
108
+ />
108
109
  <div className="min-w-0 flex-1">
109
110
  <div className="truncate text-sm text-foreground">
110
111
  {label}
@@ -124,6 +125,27 @@ export function ViewedByPopover({
124
125
  );
125
126
  }
126
127
 
128
+ export function ViewerAvatar({
129
+ email,
130
+ name,
131
+ label,
132
+ }: {
133
+ email: string | null;
134
+ name: string | null;
135
+ label: string;
136
+ }) {
137
+ const { avatarRef, avatarUrl } = useVisibleAvatarUrl(email);
138
+
139
+ return (
140
+ <Avatar ref={avatarRef} className="h-6 w-6 shrink-0">
141
+ {avatarUrl ? <AvatarImage src={avatarUrl} alt={label} /> : null}
142
+ <AvatarFallback className="text-[10px] bg-primary text-primary-foreground">
143
+ {initials(name || email || "?")}
144
+ </AvatarFallback>
145
+ </Avatar>
146
+ );
147
+ }
148
+
127
149
  function initials(s: string): string {
128
150
  return s
129
151
  .split(/\s+|@/)
@@ -0,0 +1,34 @@
1
+ import { useAvatarUrl } from "@agent-native/core/client/hooks";
2
+ import { useEffect, useRef, useState } from "react";
3
+
4
+ export function useVisibleAvatarUrl(email: string | null | undefined) {
5
+ const avatarRef = useRef<HTMLSpanElement>(null);
6
+ const [visibleEmail, setVisibleEmail] = useState<string | null>(null);
7
+
8
+ useEffect(() => {
9
+ if (!email) return;
10
+
11
+ const element = avatarRef.current;
12
+ if (!element || typeof IntersectionObserver === "undefined") {
13
+ setVisibleEmail(email);
14
+ return;
15
+ }
16
+
17
+ const observer = new IntersectionObserver(
18
+ (entries) => {
19
+ if (!entries.some((entry) => entry.isIntersecting)) return;
20
+ setVisibleEmail(email);
21
+ observer.disconnect();
22
+ },
23
+ { rootMargin: "48px" },
24
+ );
25
+
26
+ observer.observe(element);
27
+ return () => observer.disconnect();
28
+ }, [email]);
29
+
30
+ return {
31
+ avatarRef,
32
+ avatarUrl: useAvatarUrl(visibleEmail === email ? email : null),
33
+ };
34
+ }
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: fixed
3
+ date: 2026-07-28
4
+ ---
5
+
6
+ Profile avatars now appear in viewer and share-access lists.
@@ -3995,7 +3995,7 @@ const SCK_FINALIZE_TIMEOUT: Duration = Duration::from_secs(10);
3995
3995
  const CUSTOM_SCK_STOP_TIMEOUT: Duration = Duration::from_secs(3);
3996
3996
 
3997
3997
  #[cfg(target_os = "macos")]
3998
- fn run_bounded_capture_stop<F>(stop: F, timeout: Duration) -> Result<(), String>
3998
+ pub(crate) fn run_bounded_capture_stop<F>(stop: F, timeout: Duration) -> Result<(), String>
3999
3999
  where
4000
4000
  F: FnOnce() -> Result<(), String> + Send + 'static,
4001
4001
  {
@@ -161,6 +161,7 @@ pub async fn audio_transcription_reset_timeline() -> Result<(), String> {
161
161
  pub(crate) mod macos {
162
162
  use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
163
163
  use std::sync::Arc;
164
+ use std::time::Duration;
164
165
 
165
166
  use objc2::rc::Retained;
166
167
  use objc2::AnyThread;
@@ -314,6 +315,15 @@ pub(crate) mod macos {
314
315
  }
315
316
  }
316
317
 
318
+ /// `SCStream::stop_capture()` occasionally never returns when the stream's
319
+ /// underlying connection was already interrupted (same ScreenCaptureKit
320
+ /// flakiness `native_screen::run_bounded_capture_stop` bounds for the video
321
+ /// stream). This capture has no delegate to observe that ahead of time, so
322
+ /// bound the stop call itself — otherwise a hung stop blocks the
323
+ /// `audio_transcription_stop` Tauri command, which blocks the recorder's
324
+ /// finalize await, forever.
325
+ const SYSTEM_AUDIO_SCK_STOP_TIMEOUT: Duration = Duration::from_secs(3);
326
+
317
327
  /// Handle for a running raw SCK audio capture. A meeting capture can carry
318
328
  /// both system and microphone output handlers on this one stream.
319
329
  pub(crate) struct RawSckAudioCapture {
@@ -328,7 +338,17 @@ pub(crate) mod macos {
328
338
  impl RawSckAudioCapture {
329
339
  pub(crate) fn stop(self) {
330
340
  self.cancelled.store(true, Ordering::SeqCst);
331
- let _ = self.stream.stop_capture();
341
+ let stream = self.stream;
342
+ if let Err(err) = crate::native_screen::run_bounded_capture_stop(
343
+ move || {
344
+ stream
345
+ .stop_capture()
346
+ .map_err(|e| format!("system audio SCStream stop failed: {e:?}"))
347
+ },
348
+ SYSTEM_AUDIO_SCK_STOP_TIMEOUT,
349
+ ) {
350
+ eprintln!("[system-audio] bounded stop_capture: {err}");
351
+ }
332
352
  }
333
353
  }
334
354
 
@@ -167,7 +167,7 @@ export function OrgSwitcher({ className, hideWhenSingle, reserveSpace, compact,
167
167
  const organizationSettingsHref = settingsPath
168
168
  ? organizationSettingsPath(settingsPath)
169
169
  : null;
170
- return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: handleOpenChange, children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, children: compact ? (_jsx("button", { type: "button", title: buttonLabel, "aria-label": buttonLabel, className: `${COMPACT_SWITCHER_BUTTON_CLASS} ${className ?? ""}`, children: _jsx(ButtonIcon, { className: "h-3.5 w-3.5 shrink-0" }) })) : (_jsxs("button", { type: "button", className: `${SWITCHER_BUTTON_CLASS} ${className ?? ""}`, children: [_jsx(ButtonIcon, { className: "h-3.5 w-3.5 shrink-0" }), _jsx("span", { className: "truncate flex-1 text-start", children: buttonLabel }), _jsx(IconSelector, { className: "h-3 w-3 shrink-0 opacity-50" })] })) }), _jsx(PopoverPrimitive.Portal, { children: _jsxs(PopoverPrimitive.Content, { side: "top", align: "start", sideOffset: 6, collisionPadding: 12, className: POPOVER_CONTENT_CLASS, onOpenAutoFocus: (e) => {
170
+ return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: handleOpenChange, children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, children: compact ? (_jsx("button", { type: "button", title: buttonLabel, "aria-label": buttonLabel, className: `${COMPACT_SWITCHER_BUTTON_CLASS} ${className ?? ""}`, children: _jsx(ButtonIcon, { className: "h-3.5 w-3.5 shrink-0" }) })) : (_jsxs("button", { type: "button", className: `${SWITCHER_BUTTON_CLASS} ${className ?? ""}`, children: [_jsx(ButtonIcon, { className: "h-3.5 w-3.5 shrink-0" }), _jsx("span", { className: "truncate flex-1 text-start", children: buttonLabel }), _jsx(IconSelector, { className: "h-3 w-3 shrink-0 opacity-50" })] })) }), _jsx(PopoverPrimitive.Portal, { children: _jsxs(PopoverPrimitive.Content, { side: "top", align: "start", sideOffset: 6, collisionPadding: 12, className: `${POPOVER_CONTENT_CLASS} ${mode === "list" ? "" : "w-64"}`, onOpenAutoFocus: (e) => {
171
171
  // Don't auto-focus the first item — feels heavy on a switcher.
172
172
  if (mode === "list")
173
173
  e.preventDefault();
@@ -247,7 +247,7 @@ export function OrgSwitcher({ className, hideWhenSingle, reserveSpace, compact,
247
247
  catch {
248
248
  /* error surfaced via createOrg.error */
249
249
  }
250
- }, className: "px-2 py-1.5", children: [_jsx("div", { className: "px-0.5 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground", children: "New organization" }), _jsxs("p", { className: "flex items-start gap-1.5 px-0.5 pb-1.5 text-[11px] leading-snug text-muted-foreground", children: [_jsx(IconKey, { className: "mt-0.5 h-3 w-3 shrink-0" }), _jsx("span", { children: t("org.createOrgVaultNotice") })] }), _jsx("input", { autoFocus: true, value: newName, onChange: (e) => setNewName(e.target.value), placeholder: "Organization name", disabled: createOrg.isPending, className: "w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs outline-none focus:ring-2 focus:ring-ring disabled:opacity-50" }), createOrg.error && (_jsx("div", { className: "pt-1 text-[11px] text-destructive", children: createOrg.error.message })), _jsxs("div", { className: "flex items-center gap-1.5 pt-1.5", children: [_jsx("button", { type: "button", onClick: () => setMode("list"), disabled: createOrg.isPending, className: "flex-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent disabled:opacity-50 cursor-pointer", children: "Cancel" }), _jsx("button", { type: "submit", disabled: createOrg.isPending || !newName.trim(), className: "flex flex-1 items-center justify-center rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50 cursor-pointer", children: createOrg.isPending ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : ("Create") })] })] })), mode === "invite" && (_jsxs("form", { onSubmit: async (e) => {
250
+ }, className: "px-2 py-1.5", children: [_jsx("div", { className: "px-0.5 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground", children: "New organization" }), _jsxs("p", { className: "pe-0.5 pb-1.5 ps-2 text-[11px] leading-snug text-muted-foreground", children: [_jsx(IconKey, { className: "me-1.5 inline-block h-3 w-3 align-text-top" }), t("org.createOrgVaultNotice")] }), _jsx("input", { autoFocus: true, value: newName, onChange: (e) => setNewName(e.target.value), placeholder: "Organization name", disabled: createOrg.isPending, className: "w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs outline-none focus:ring-2 focus:ring-ring disabled:opacity-50" }), createOrg.error && (_jsx("div", { className: "pt-1 text-[11px] text-destructive", children: createOrg.error.message })), _jsxs("div", { className: "flex items-center gap-1.5 pt-1.5", children: [_jsx("button", { type: "button", onClick: () => setMode("list"), disabled: createOrg.isPending, className: "flex-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent disabled:opacity-50 cursor-pointer", children: "Cancel" }), _jsx("button", { type: "submit", disabled: createOrg.isPending || !newName.trim(), className: "flex flex-1 items-center justify-center rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50 cursor-pointer", children: createOrg.isPending ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : ("Create") })] })] })), mode === "invite" && (_jsxs("form", { onSubmit: async (e) => {
251
251
  e.preventDefault();
252
252
  const email = inviteEmail.trim();
253
253
  if (!email)
@@ -1 +1 @@
1
- {"version":3,"file":"OrgSwitcher.js","sourceR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EAAC,sBAAsB,GAAG,CACjD,CAAC,CAAC,CAAC,CACF,aAAa,CACd,GACM,IACL,IACD,CACR,IACwB,GACH,IACJ,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport {\n IconApps,\n IconArrowUpRight,\n IconBrain,\n IconBrandJira,\n IconBrush,\n IconCalendar,\n IconCalendarTime,\n IconChartBar,\n IconCheck,\n IconChevronRight,\n IconClipboardList,\n IconCode,\n IconFileText,\n IconKey,\n IconLayoutBoard,\n IconListCheck,\n IconLoader2,\n IconLogout,\n IconMail,\n IconMessageCircle,\n IconMicrophone,\n IconNote,\n IconPhone,\n IconPhoto,\n IconPlus,\n IconPresentation,\n IconRoute,\n IconScreenShare,\n IconSelector,\n IconSettings,\n IconStack2,\n IconUser,\n IconUserCircle,\n IconUserPlus,\n IconUsers,\n IconUsersGroup,\n IconWorld,\n} from \"@tabler/icons-react\";\nimport { useState } from \"react\";\nimport { useNavigate } from \"react-router\";\n\nimport { agentNativePath } from \"../api-path.js\";\nimport { useT } from \"../i18n.js\";\nimport { useSession } from \"../use-session.js\";\nimport {\n useOrg,\n useSwitchOrg,\n useCreateOrg,\n useInviteMember,\n useAcceptInvitation,\n useJoinByDomain,\n} from \"./hooks.js\";\nimport {\n ORG_SWITCHER_MAX_APP_LINKS,\n useOrgSwitcherAppLinks,\n visibleOrgAppLinks,\n type OrgSwitcherAppLink,\n} from \"./workspace-app-links.js\";\n\nexport interface OrgSwitcherProps {\n className?: string;\n /** Hide entirely when the user only belongs to one org. Default: false. */\n hideWhenSingle?: boolean;\n /** Keep the switcher's button height reserved while org state is loading. */\n reserveSpace?: boolean;\n /**\n * Icon-only trigger for collapsed sidebar rails. The popover — and with it\n * the org list, pending invitations and \"Join your team\" — is identical;\n * dropping the switcher instead leaves a collapsed rail with no way to\n * reach another workspace.\n */\n compact?: boolean;\n /**\n * Path to navigate to when the user clicks \"Organization settings\".\n * Defaults to the Organization tab inside Settings. Templates with an\n * established org surface can pass their own path; pass `null` to only open\n * the in-sidebar settings panel.\n */\n settingsPath?: string | null;\n /** Path to navigate to when the user clicks \"Profile\". Defaults to the shared Account settings section. */\n profilePath?: string | null;\n}\n\nfunction personalLabelFromEmail(email: string | null | undefined): string {\n if (!email) return \"Personal\";\n const local = email.split(\"@\")[0] ?? email;\n const cleaned = local.replace(/[._-]+/g, \" \").trim();\n if (!cleaned) return \"Personal\";\n return cleaned\n .split(\" \")\n .filter(Boolean)\n .map((w) => w.charAt(0).toUpperCase() + w.slice(1))\n .join(\" \");\n}\n\ntype Mode = \"list\" | \"create\" | \"invite\";\n\nconst POPOVER_CONTENT_CLASS =\n \"z-50 min-w-[14rem] rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\";\n\nconst ITEM_CLASS =\n \"flex w-full items-center gap-2 px-2.5 py-1.5 text-xs text-foreground hover:bg-accent focus-visible:bg-accent focus:outline-none disabled:opacity-50 disabled:pointer-events-none\";\n\nconst SECTION_LABEL_CLASS =\n \"px-2.5 pt-1 pb-0.5 text-[10px] uppercase tracking-wide text-muted-foreground\";\n\nconst APP_SUBMENU_CONTENT_CLASS =\n \"z-50 w-72 rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\";\n\nconst SWITCHER_BUTTON_CLASS =\n \"flex w-full items-center gap-2 rounded-md border-0 bg-accent/50 px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent/70 hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-60 cursor-pointer\";\n\nconst COMPACT_SWITCHER_BUTTON_CLASS =\n \"flex items-center justify-center rounded-md border-0 bg-accent/50 p-1.5 text-muted-foreground hover:bg-accent/70 hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-60 cursor-pointer\";\n\nconst DEFAULT_ORGANIZATION_SETTINGS_PATH = \"/settings#organization\";\nconst DEFAULT_PROFILE_PATH = \"/settings#account\";\n\nconst APP_ICON_MAP: Record<string, typeof IconApps> = {\n Mail: IconMail,\n CalendarDays: IconCalendar,\n FileText: IconFileText,\n LayoutBoard: IconLayoutBoard,\n BarChart2: IconChartBar,\n GalleryHorizontal: IconPresentation,\n BrandJira: IconBrandJira,\n ClipboardList: IconClipboardList,\n Users: IconUsers,\n Code: IconCode,\n MessageCircle: IconMessageCircle,\n Route: IconRoute,\n ScreenShare: IconScreenShare,\n Brush: IconBrush,\n Brain: IconBrain,\n Phone: IconPhone,\n Note: IconNote,\n Microphone: IconMicrophone,\n CalendarTime: IconCalendarTime,\n Globe: IconWorld,\n Photo: IconPhoto,\n ListCheck: IconListCheck,\n};\n\nfunction appMenuIcon(app: OrgSwitcherAppLink): typeof IconApps {\n if (app.icon) return APP_ICON_MAP[app.icon] ?? IconStack2;\n return app.isDispatch ? IconMessageCircle : IconStack2;\n}\n\nfunction organizationSettingsPath(path: string): string {\n if (path.includes(\"#\")) return path;\n const pathname = path.split(\"?\")[0]?.replace(/\\/+$/, \"\");\n return pathname === \"/settings\" ? `${path}#organization` : path;\n}\n\nfunction AppMenuLink({\n app,\n onNavigate,\n}: {\n app: OrgSwitcherAppLink;\n onNavigate: () => void;\n}) {\n const Icon = appMenuIcon(app);\n const description =\n app.status === \"pending\"\n ? \"Building\"\n : app.description?.trim() ||\n (app.isDispatch ? \"Workspace hub\" : `${app.name} workspace`);\n return (\n <a\n href={app.href}\n onClick={onNavigate}\n className=\"flex items-center gap-2 rounded-sm px-2.5 py-2 text-xs outline-none hover:bg-accent focus:bg-accent\"\n >\n <span className=\"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground\">\n <Icon className=\"h-3.5 w-3.5\" />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate font-medium text-foreground\">\n {app.name}\n </span>\n <span\n className=\"block truncate text-[11px] text-muted-foreground\"\n title={description}\n >\n {description}\n </span>\n </span>\n <IconArrowUpRight className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n </a>\n );\n}\n\nfunction AppsSubmenu({\n apps,\n isLoading,\n dispatchHref,\n dispatchAllAppsHref,\n onNavigate,\n}: {\n apps: OrgSwitcherAppLink[];\n isLoading: boolean;\n dispatchHref: string;\n dispatchAllAppsHref: string;\n onNavigate: () => void;\n}) {\n const { links, overflowCount } = visibleOrgAppLinks(apps);\n const visibleDispatchApp = links.find((app) => app.isDispatch);\n const dispatchApp =\n visibleDispatchApp ??\n ({\n id: \"dispatch\",\n name: \"Dispatch\",\n href: dispatchHref,\n isDispatch: true,\n status: \"ready\",\n } satisfies OrgSwitcherAppLink);\n const visibleNonDispatch = links\n .filter((app) => !app.isDispatch)\n .slice(0, visibleDispatchApp ? undefined : ORG_SWITCHER_MAX_APP_LINKS - 1);\n const shownCount = (dispatchApp ? 1 : 0) + visibleNonDispatch.length;\n const remainingCount = Math.max(overflowCount, apps.length - shownCount);\n\n return (\n <PopoverPrimitive.Root>\n <PopoverPrimitive.Trigger asChild>\n <button type=\"button\" className={`${ITEM_CLASS} cursor-pointer`}>\n <IconApps className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1 text-start\">Apps</span>\n <span className=\"text-[11px] text-muted-foreground\">\n {isLoading ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n apps.length\n )}\n </span>\n <IconChevronRight className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground rtl:-scale-x-100\" />\n </button>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n side=\"right\"\n align=\"start\"\n sideOffset={8}\n collisionPadding={12}\n className={APP_SUBMENU_CONTENT_CLASS}\n >\n <AppMenuLink app={dispatchApp} onNavigate={onNavigate} />\n\n {visibleNonDispatch.length > 0 && (\n <div className=\"my-1 h-px bg-border\" />\n )}\n {visibleNonDispatch.map((app) => (\n <AppMenuLink key={app.id} app={app} onNavigate={onNavigate} />\n ))}\n\n {remainingCount > 0 && (\n <>\n <div className=\"my-1 h-px bg-border\" />\n <a\n href={dispatchAllAppsHref}\n onClick={onNavigate}\n className=\"flex items-center gap-2 rounded-sm px-2.5 py-1.5 text-xs text-foreground outline-none hover:bg-accent focus:bg-accent\"\n >\n <IconApps className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1\">\n {`View ${remainingCount} more in Dispatch`}\n </span>\n <IconArrowUpRight className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n </a>\n </>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n}\n\nfunction ReservedOrgSwitcherSpace({ className }: { className?: string }) {\n return <div aria-hidden=\"true\" className={`h-8 ${className ?? \"\"}`} />;\n}\n\nfunction OrgSwitcherLoadingPlaceholder({ className }: { className?: string }) {\n return (\n <button\n type=\"button\"\n disabled\n aria-label=\"Loading organization\"\n className={`${SWITCHER_BUTTON_CLASS} animate-pulse ${className ?? \"\"}`}\n >\n <IconUsersGroup className=\"h-3.5 w-3.5 shrink-0 opacity-60\" />\n <span className=\"h-3 min-w-0 flex-1 rounded-sm bg-muted-foreground/20\" />\n <IconSelector className=\"h-3 w-3 shrink-0 opacity-30\" />\n </button>\n );\n}\n\n/**\n * Compact org switcher button. Shows the active org (or \"Personal\" when the\n * user has none); opens a popover with the user's other orgs, pending\n * invitations, inline forms to create a new org / invite a teammate, and a\n * sign-out item. Renders nothing in dev / no-auth mode.\n */\nexport function OrgSwitcher({\n className,\n hideWhenSingle,\n reserveSpace,\n compact,\n settingsPath = DEFAULT_ORGANIZATION_SETTINGS_PATH,\n profilePath = DEFAULT_PROFILE_PATH,\n}: OrgSwitcherProps) {\n const { data: org, isLoading } = useOrg();\n const { session } = useSession();\n const t = useT();\n const switchOrg = useSwitchOrg();\n const createOrg = useCreateOrg();\n const inviteMember = useInviteMember();\n const acceptInvitation = useAcceptInvitation();\n const joinByDomain = useJoinByDomain();\n const navigate = useNavigate();\n const [open, setOpen] = useState(false);\n const [mode, setMode] = useState<Mode>(\"list\");\n const [newName, setNewName] = useState(\"\");\n const [inviteEmail, setInviteEmail] = useState(\"\");\n const [signingOut, setSigningOut] = useState(false);\n const [joiningOrgId, setJoiningOrgId] = useState<string | null>(null);\n const appLinks = useOrgSwitcherAppLinks(open);\n\n const handleOpenChange = (next: boolean) => {\n setOpen(next);\n if (!next) {\n setMode(\"list\");\n setNewName(\"\");\n setInviteEmail(\"\");\n }\n };\n\n const handleSignOut = async () => {\n if (signingOut) return;\n setSigningOut(true);\n try {\n await fetch(agentNativePath(\"/_agent-native/auth/logout\"), {\n method: \"POST\",\n credentials: \"include\",\n });\n } catch {\n /* fall through to reload — server may already have cleared the cookie */\n }\n window.location.reload();\n };\n\n if (!org) {\n return reserveSpace && isLoading ? (\n <OrgSwitcherLoadingPlaceholder className={className} />\n ) : null;\n }\n\n const orgs = org.orgs ?? [];\n const pendingInvitations = org.pendingInvitations ?? [];\n const domainMatches = org.domainMatches ?? [];\n const orgCount = orgs.length;\n const hasAny =\n orgCount > 0 || pendingInvitations.length > 0 || domainMatches.length > 0;\n if (!hasAny && !org.email) {\n return reserveSpace ? (\n <ReservedOrgSwitcherSpace className={className} />\n ) : null;\n }\n if (\n hideWhenSingle &&\n orgCount < 2 &&\n pendingInvitations.length === 0 &&\n domainMatches.length === 0\n ) {\n return reserveSpace ? (\n <ReservedOrgSwitcherSpace className={className} />\n ) : null;\n }\n\n const canInvite =\n !!org.orgId && (org.role === \"owner\" || org.role === \"admin\");\n\n const personalLabel = session?.name || personalLabelFromEmail(org.email);\n const inOrg = !!org.orgId;\n const buttonLabel = org.orgName ?? \"Personal\";\n const ButtonIcon = inOrg ? IconUsersGroup : IconUser;\n const organizationSettingsHref = settingsPath\n ? organizationSettingsPath(settingsPath)\n : null;\n\n return (\n <PopoverPrimitive.Root open={open} onOpenChange={handleOpenChange}>\n <PopoverPrimitive.Trigger asChild>\n {compact ? (\n <button\n type=\"button\"\n title={buttonLabel}\n aria-label={buttonLabel}\n className={`${COMPACT_SWITCHER_BUTTON_CLASS} ${className ?? \"\"}`}\n >\n <ButtonIcon className=\"h-3.5 w-3.5 shrink-0\" />\n </button>\n ) : (\n <button\n type=\"button\"\n className={`${SWITCHER_BUTTON_CLASS} ${className ?? \"\"}`}\n >\n <ButtonIcon className=\"h-3.5 w-3.5 shrink-0\" />\n <span className=\"truncate flex-1 text-start\">{buttonLabel}</span>\n <IconSelector className=\"h-3 w-3 shrink-0 opacity-50\" />\n </button>\n )}\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n side=\"top\"\n align=\"start\"\n sideOffset={6}\n collisionPadding={12}\n className={POPOVER_CONTENT_CLASS}\n onOpenAutoFocus={(e) => {\n // Don't auto-focus the first item — feels heavy on a switcher.\n if (mode === \"list\") e.preventDefault();\n }}\n >\n {mode === \"list\" && (\n <>\n {!inOrg && (\n <div\n className=\"flex w-full items-center gap-2 px-2.5 py-1.5 text-xs text-muted-foreground\"\n aria-disabled=\"true\"\n >\n <IconUser className=\"h-3.5 w-3.5 shrink-0\" />\n <span className=\"truncate flex-1 text-start\">\n Personal ({personalLabel})\n </span>\n </div>\n )}\n {orgs.length > 0 && (\n <div className={SECTION_LABEL_CLASS}>Organizations</div>\n )}\n {orgs.map((o) => (\n <button\n key={o.orgId}\n type=\"button\"\n onClick={async () => {\n if (o.orgId === org.orgId) {\n setOpen(false);\n return;\n }\n try {\n await switchOrg.mutateAsync(o.orgId);\n setOpen(false);\n } catch {\n /* error surfaced via switchOrg.error */\n }\n }}\n disabled={switchOrg.isPending}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n <IconUsersGroup className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate flex-1 text-start\">\n {o.orgName}\n </span>\n {o.orgId === org.orgId && (\n <IconCheck className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n )}\n </button>\n ))}\n\n {pendingInvitations.length > 0 && (\n <>\n {orgs.length > 0 && <div className=\"my-1 h-px bg-border\" />}\n <div className={SECTION_LABEL_CLASS}>Invitations</div>\n {pendingInvitations.map((inv) => (\n <div key={inv.id} className=\"px-2.5 py-1.5 text-xs\">\n <div className=\"flex items-center gap-2\">\n <IconUsersGroup className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate flex-1 text-foreground\">\n {inv.orgName}\n </span>\n <button\n type=\"button\"\n onClick={async () => {\n try {\n await acceptInvitation.mutateAsync(inv.id);\n setOpen(false);\n } catch {\n /* error surfaced via acceptInvitation.error */\n }\n }}\n disabled={acceptInvitation.isPending}\n className=\"rounded px-1.5 py-0.5 text-[11px] font-medium text-primary hover:bg-primary/10 disabled:opacity-50 cursor-pointer\"\n >\n {acceptInvitation.isPending ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n \"Join\"\n )}\n </button>\n </div>\n {org.orgId && (\n <p className=\"mt-1 flex items-start gap-1.5 text-[11px] leading-snug text-muted-foreground\">\n <IconKey className=\"mt-0.5 h-3 w-3 shrink-0\" />\n <span>\n {t(\"org.acceptInvitationOrgSwitchNotice\", {\n name: inv.orgName,\n })}\n </span>\n </p>\n )}\n </div>\n ))}\n </>\n )}\n\n {domainMatches.length > 0 && (\n <>\n {(orgs.length > 0 || pendingInvitations.length > 0) && (\n <div className=\"my-1 h-px bg-border\" />\n )}\n <div className={SECTION_LABEL_CLASS}>Join your team</div>\n {domainMatches.map((match) => {\n const isJoining =\n joinByDomain.isPending && joiningOrgId === match.orgId;\n return (\n <div\n key={match.orgId}\n className=\"flex items-center gap-2 px-2.5 py-1.5 text-xs\"\n >\n <IconUsersGroup className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate flex-1 text-foreground\">\n {match.orgName}\n </span>\n <button\n type=\"button\"\n onClick={async () => {\n setJoiningOrgId(match.orgId);\n try {\n await joinByDomain.mutateAsync(match.orgId);\n setOpen(false);\n } catch {\n /* error surfaced via joinByDomain.error */\n } finally {\n setJoiningOrgId(null);\n }\n }}\n disabled={joinByDomain.isPending}\n className=\"rounded px-1.5 py-0.5 text-[11px] font-medium text-primary hover:bg-primary/10 disabled:opacity-50 cursor-pointer\"\n >\n {isJoining ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n \"Join\"\n )}\n </button>\n </div>\n );\n })}\n </>\n )}\n\n <div className=\"my-1 h-px bg-border\" />\n <AppsSubmenu\n apps={appLinks.apps}\n isLoading={appLinks.isLoading}\n dispatchHref={appLinks.dispatchHref}\n dispatchAllAppsHref={appLinks.dispatchAllAppsHref}\n onNavigate={() => setOpen(false)}\n />\n {profilePath && (\n <button\n type=\"button\"\n onClick={() => {\n setOpen(false);\n navigate(profilePath);\n }}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n <IconUserCircle className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1 text-start\">\n {t(\"settings.profileMenuItem\")}\n </span>\n </button>\n )}\n {inOrg && (\n <button\n type=\"button\"\n onClick={() => {\n setOpen(false);\n if (organizationSettingsHref) {\n navigate(organizationSettingsHref);\n } else {\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:open-settings\", {\n detail: { section: \"workspace-settings\" },\n }),\n );\n }\n }}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n <IconSettings className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1 text-start\">\n Organization settings\n </span>\n </button>\n )}\n <button\n type=\"button\"\n onClick={() => {\n // Clear any leftover input from a prior session — otherwise\n // the create form re-opens prefilled with the just-created\n // org's name and looks like a create dialog for the new org.\n setNewName(\"\");\n setMode(\"create\");\n }}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n <IconPlus className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1 text-start\">Create organization</span>\n </button>\n {canInvite && (\n <button\n type=\"button\"\n onClick={() => {\n setInviteEmail(\"\");\n setMode(\"invite\");\n }}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n <IconUserPlus className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1 text-start\">Invite member</span>\n </button>\n )}\n\n <div className=\"my-1 h-px bg-border\" />\n <button\n type=\"button\"\n onClick={handleSignOut}\n disabled={signingOut}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n {signingOut ? (\n <IconLoader2 className=\"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground\" />\n ) : (\n <IconLogout className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground rtl:-scale-x-100\" />\n )}\n <span className=\"flex-1 text-start\">\n Sign out\n {org.email ? (\n <span className=\"ms-1 text-muted-foreground\">\n ({org.email})\n </span>\n ) : null}\n </span>\n </button>\n\n {(switchOrg.error ||\n acceptInvitation.error ||\n joinByDomain.error) && (\n <div className=\"px-2.5 pt-1 text-[11px] text-destructive\">\n {\n (\n (switchOrg.error ||\n acceptInvitation.error ||\n joinByDomain.error) as Error\n ).message\n }\n </div>\n )}\n </>\n )}\n\n {mode === \"create\" && (\n <form\n onSubmit={async (e) => {\n e.preventDefault();\n const name = newName.trim();\n if (!name) return;\n try {\n await createOrg.mutateAsync(name);\n handleOpenChange(false);\n } catch {\n /* error surfaced via createOrg.error */\n }\n }}\n className=\"px-2 py-1.5\"\n >\n <div className=\"px-0.5 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground\">\n New organization\n </div>\n <p className=\"flex items-start gap-1.5 px-0.5 pb-1.5 text-[11px] leading-snug text-muted-foreground\">\n <IconKey className=\"mt-0.5 h-3 w-3 shrink-0\" />\n <span>{t(\"org.createOrgVaultNotice\")}</span>\n </p>\n <input\n autoFocus\n value={newName}\n onChange={(e) => setNewName(e.target.value)}\n placeholder=\"Organization name\"\n disabled={createOrg.isPending}\n className=\"w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs outline-none focus:ring-2 focus:ring-ring disabled:opacity-50\"\n />\n {createOrg.error && (\n <div className=\"pt-1 text-[11px] text-destructive\">\n {(createOrg.error as Error).message}\n </div>\n )}\n <div className=\"flex items-center gap-1.5 pt-1.5\">\n <button\n type=\"button\"\n onClick={() => setMode(\"list\")}\n disabled={createOrg.isPending}\n className=\"flex-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent disabled:opacity-50 cursor-pointer\"\n >\n Cancel\n </button>\n <button\n type=\"submit\"\n disabled={createOrg.isPending || !newName.trim()}\n className=\"flex flex-1 items-center justify-center rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50 cursor-pointer\"\n >\n {createOrg.isPending ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n \"Create\"\n )}\n </button>\n </div>\n </form>\n )}\n\n {mode === \"invite\" && (\n <form\n onSubmit={async (e) => {\n e.preventDefault();\n const email = inviteEmail.trim();\n if (!email) return;\n try {\n await inviteMember.mutateAsync(email);\n setInviteEmail(\"\");\n setMode(\"list\");\n } catch {\n /* error surfaced via inviteMember.error */\n }\n }}\n className=\"px-2 py-1.5\"\n >\n <div className=\"px-0.5 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground\">\n Invite to {org.orgName}\n </div>\n <input\n autoFocus\n type=\"email\"\n value={inviteEmail}\n onChange={(e) => setInviteEmail(e.target.value)}\n placeholder=\"teammate@company.com\"\n disabled={inviteMember.isPending}\n className=\"w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs outline-none focus:ring-2 focus:ring-ring disabled:opacity-50\"\n />\n {inviteMember.error && (\n <div className=\"pt-1 text-[11px] text-destructive\">\n {(inviteMember.error as Error).message}\n </div>\n )}\n <div className=\"flex items-center gap-1.5 pt-1.5\">\n <button\n type=\"button\"\n onClick={() => setMode(\"list\")}\n disabled={inviteMember.isPending}\n className=\"flex-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent disabled:opacity-50 cursor-pointer\"\n >\n Cancel\n </button>\n <button\n type=\"submit\"\n disabled={inviteMember.isPending || !inviteEmail.trim()}\n className=\"flex flex-1 items-center justify-center rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50 cursor-pointer\"\n >\n {inviteMember.isPending ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n \"Send invite\"\n )}\n </button>\n </div>\n </form>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n}\n"]}
1
+ {"version":3,"file":"OrgSwitcher.js","sourceRoot":"","sources":["../../../src/client/org/OrgSwitcher.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACX,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ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ACP,2CAA2C;gCAC7C,CAAC;4BACH,CAAC,EACD,SAAS,EAAC,aAAa,aAEvB,eAAK,SAAS,EAAC,uEAAuE,2BACzE,GAAG,CAAC,OAAO,IAClB,EACN,gBACE,SAAS,QACT,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC/C,WAAW,EAAC,sBAAsB,EAClC,QAAQ,EAAE,YAAY,CAAC,SAAS,EAChC,SAAS,EAAC,uIAAuI,GACjJ,EACD,YAAY,CAAC,KAAK,IAAI,CACrB,cAAK,SAAS,EAAC,mCAAmC,YAC9C,YAAY,CAAC,KAAe,CAAC,OAAO,GAClC,CACP,EACD,eAAK,SAAS,EAAC,kCAAkC,aAC/C,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAC9B,QAAQ,EAAE,YAAY,CAAC,SAAS,EAChC,SAAS,EAAC,8GAA8G,uBAGjH,EACT,iBACE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,YAAY,CAAC,SAAS,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EACvD,SAAS,EAAC,yKAAyK,YAElL,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CACxB,KAAC,WAAW,IAAC,SAAS,EAAC,sBAAsB,GAAG,CACjD,CAAC,CAAC,CAAC,CACF,aAAa,CACd,GACM,IACL,IACD,CACR,IACwB,GACH,IACJ,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport {\n IconApps,\n IconArrowUpRight,\n IconBrain,\n IconBrandJira,\n IconBrush,\n IconCalendar,\n IconCalendarTime,\n IconChartBar,\n IconCheck,\n IconChevronRight,\n IconClipboardList,\n IconCode,\n IconFileText,\n IconKey,\n IconLayoutBoard,\n IconListCheck,\n IconLoader2,\n IconLogout,\n IconMail,\n IconMessageCircle,\n IconMicrophone,\n IconNote,\n IconPhone,\n IconPhoto,\n IconPlus,\n IconPresentation,\n IconRoute,\n IconScreenShare,\n IconSelector,\n IconSettings,\n IconStack2,\n IconUser,\n IconUserCircle,\n IconUserPlus,\n IconUsers,\n IconUsersGroup,\n IconWorld,\n} from \"@tabler/icons-react\";\nimport { useState } from \"react\";\nimport { useNavigate } from \"react-router\";\n\nimport { agentNativePath } from \"../api-path.js\";\nimport { useT } from \"../i18n.js\";\nimport { useSession } from \"../use-session.js\";\nimport {\n useOrg,\n useSwitchOrg,\n useCreateOrg,\n useInviteMember,\n useAcceptInvitation,\n useJoinByDomain,\n} from \"./hooks.js\";\nimport {\n ORG_SWITCHER_MAX_APP_LINKS,\n useOrgSwitcherAppLinks,\n visibleOrgAppLinks,\n type OrgSwitcherAppLink,\n} from \"./workspace-app-links.js\";\n\nexport interface OrgSwitcherProps {\n className?: string;\n /** Hide entirely when the user only belongs to one org. Default: false. */\n hideWhenSingle?: boolean;\n /** Keep the switcher's button height reserved while org state is loading. */\n reserveSpace?: boolean;\n /**\n * Icon-only trigger for collapsed sidebar rails. The popover — and with it\n * the org list, pending invitations and \"Join your team\" — is identical;\n * dropping the switcher instead leaves a collapsed rail with no way to\n * reach another workspace.\n */\n compact?: boolean;\n /**\n * Path to navigate to when the user clicks \"Organization settings\".\n * Defaults to the Organization tab inside Settings. Templates with an\n * established org surface can pass their own path; pass `null` to only open\n * the in-sidebar settings panel.\n */\n settingsPath?: string | null;\n /** Path to navigate to when the user clicks \"Profile\". Defaults to the shared Account settings section. */\n profilePath?: string | null;\n}\n\nfunction personalLabelFromEmail(email: string | null | undefined): string {\n if (!email) return \"Personal\";\n const local = email.split(\"@\")[0] ?? email;\n const cleaned = local.replace(/[._-]+/g, \" \").trim();\n if (!cleaned) return \"Personal\";\n return cleaned\n .split(\" \")\n .filter(Boolean)\n .map((w) => w.charAt(0).toUpperCase() + w.slice(1))\n .join(\" \");\n}\n\ntype Mode = \"list\" | \"create\" | \"invite\";\n\nconst POPOVER_CONTENT_CLASS =\n \"z-50 min-w-[14rem] rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\";\n\nconst ITEM_CLASS =\n \"flex w-full items-center gap-2 px-2.5 py-1.5 text-xs text-foreground hover:bg-accent focus-visible:bg-accent focus:outline-none disabled:opacity-50 disabled:pointer-events-none\";\n\nconst SECTION_LABEL_CLASS =\n \"px-2.5 pt-1 pb-0.5 text-[10px] uppercase tracking-wide text-muted-foreground\";\n\nconst APP_SUBMENU_CONTENT_CLASS =\n \"z-50 w-72 rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\";\n\nconst SWITCHER_BUTTON_CLASS =\n \"flex w-full items-center gap-2 rounded-md border-0 bg-accent/50 px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent/70 hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-60 cursor-pointer\";\n\nconst COMPACT_SWITCHER_BUTTON_CLASS =\n \"flex items-center justify-center rounded-md border-0 bg-accent/50 p-1.5 text-muted-foreground hover:bg-accent/70 hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-60 cursor-pointer\";\n\nconst DEFAULT_ORGANIZATION_SETTINGS_PATH = \"/settings#organization\";\nconst DEFAULT_PROFILE_PATH = \"/settings#account\";\n\nconst APP_ICON_MAP: Record<string, typeof IconApps> = {\n Mail: IconMail,\n CalendarDays: IconCalendar,\n FileText: IconFileText,\n LayoutBoard: IconLayoutBoard,\n BarChart2: IconChartBar,\n GalleryHorizontal: IconPresentation,\n BrandJira: IconBrandJira,\n ClipboardList: IconClipboardList,\n Users: IconUsers,\n Code: IconCode,\n MessageCircle: IconMessageCircle,\n Route: IconRoute,\n ScreenShare: IconScreenShare,\n Brush: IconBrush,\n Brain: IconBrain,\n Phone: IconPhone,\n Note: IconNote,\n Microphone: IconMicrophone,\n CalendarTime: IconCalendarTime,\n Globe: IconWorld,\n Photo: IconPhoto,\n ListCheck: IconListCheck,\n};\n\nfunction appMenuIcon(app: OrgSwitcherAppLink): typeof IconApps {\n if (app.icon) return APP_ICON_MAP[app.icon] ?? IconStack2;\n return app.isDispatch ? IconMessageCircle : IconStack2;\n}\n\nfunction organizationSettingsPath(path: string): string {\n if (path.includes(\"#\")) return path;\n const pathname = path.split(\"?\")[0]?.replace(/\\/+$/, \"\");\n return pathname === \"/settings\" ? `${path}#organization` : path;\n}\n\nfunction AppMenuLink({\n app,\n onNavigate,\n}: {\n app: OrgSwitcherAppLink;\n onNavigate: () => void;\n}) {\n const Icon = appMenuIcon(app);\n const description =\n app.status === \"pending\"\n ? \"Building\"\n : app.description?.trim() ||\n (app.isDispatch ? \"Workspace hub\" : `${app.name} workspace`);\n return (\n <a\n href={app.href}\n onClick={onNavigate}\n className=\"flex items-center gap-2 rounded-sm px-2.5 py-2 text-xs outline-none hover:bg-accent focus:bg-accent\"\n >\n <span className=\"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground\">\n <Icon className=\"h-3.5 w-3.5\" />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate font-medium text-foreground\">\n {app.name}\n </span>\n <span\n className=\"block truncate text-[11px] text-muted-foreground\"\n title={description}\n >\n {description}\n </span>\n </span>\n <IconArrowUpRight className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n </a>\n );\n}\n\nfunction AppsSubmenu({\n apps,\n isLoading,\n dispatchHref,\n dispatchAllAppsHref,\n onNavigate,\n}: {\n apps: OrgSwitcherAppLink[];\n isLoading: boolean;\n dispatchHref: string;\n dispatchAllAppsHref: string;\n onNavigate: () => void;\n}) {\n const { links, overflowCount } = visibleOrgAppLinks(apps);\n const visibleDispatchApp = links.find((app) => app.isDispatch);\n const dispatchApp =\n visibleDispatchApp ??\n ({\n id: \"dispatch\",\n name: \"Dispatch\",\n href: dispatchHref,\n isDispatch: true,\n status: \"ready\",\n } satisfies OrgSwitcherAppLink);\n const visibleNonDispatch = links\n .filter((app) => !app.isDispatch)\n .slice(0, visibleDispatchApp ? undefined : ORG_SWITCHER_MAX_APP_LINKS - 1);\n const shownCount = (dispatchApp ? 1 : 0) + visibleNonDispatch.length;\n const remainingCount = Math.max(overflowCount, apps.length - shownCount);\n\n return (\n <PopoverPrimitive.Root>\n <PopoverPrimitive.Trigger asChild>\n <button type=\"button\" className={`${ITEM_CLASS} cursor-pointer`}>\n <IconApps className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1 text-start\">Apps</span>\n <span className=\"text-[11px] text-muted-foreground\">\n {isLoading ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n apps.length\n )}\n </span>\n <IconChevronRight className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground rtl:-scale-x-100\" />\n </button>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n side=\"right\"\n align=\"start\"\n sideOffset={8}\n collisionPadding={12}\n className={APP_SUBMENU_CONTENT_CLASS}\n >\n <AppMenuLink app={dispatchApp} onNavigate={onNavigate} />\n\n {visibleNonDispatch.length > 0 && (\n <div className=\"my-1 h-px bg-border\" />\n )}\n {visibleNonDispatch.map((app) => (\n <AppMenuLink key={app.id} app={app} onNavigate={onNavigate} />\n ))}\n\n {remainingCount > 0 && (\n <>\n <div className=\"my-1 h-px bg-border\" />\n <a\n href={dispatchAllAppsHref}\n onClick={onNavigate}\n className=\"flex items-center gap-2 rounded-sm px-2.5 py-1.5 text-xs text-foreground outline-none hover:bg-accent focus:bg-accent\"\n >\n <IconApps className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1\">\n {`View ${remainingCount} more in Dispatch`}\n </span>\n <IconArrowUpRight className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n </a>\n </>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n}\n\nfunction ReservedOrgSwitcherSpace({ className }: { className?: string }) {\n return <div aria-hidden=\"true\" className={`h-8 ${className ?? \"\"}`} />;\n}\n\nfunction OrgSwitcherLoadingPlaceholder({ className }: { className?: string }) {\n return (\n <button\n type=\"button\"\n disabled\n aria-label=\"Loading organization\"\n className={`${SWITCHER_BUTTON_CLASS} animate-pulse ${className ?? \"\"}`}\n >\n <IconUsersGroup className=\"h-3.5 w-3.5 shrink-0 opacity-60\" />\n <span className=\"h-3 min-w-0 flex-1 rounded-sm bg-muted-foreground/20\" />\n <IconSelector className=\"h-3 w-3 shrink-0 opacity-30\" />\n </button>\n );\n}\n\n/**\n * Compact org switcher button. Shows the active org (or \"Personal\" when the\n * user has none); opens a popover with the user's other orgs, pending\n * invitations, inline forms to create a new org / invite a teammate, and a\n * sign-out item. Renders nothing in dev / no-auth mode.\n */\nexport function OrgSwitcher({\n className,\n hideWhenSingle,\n reserveSpace,\n compact,\n settingsPath = DEFAULT_ORGANIZATION_SETTINGS_PATH,\n profilePath = DEFAULT_PROFILE_PATH,\n}: OrgSwitcherProps) {\n const { data: org, isLoading } = useOrg();\n const { session } = useSession();\n const t = useT();\n const switchOrg = useSwitchOrg();\n const createOrg = useCreateOrg();\n const inviteMember = useInviteMember();\n const acceptInvitation = useAcceptInvitation();\n const joinByDomain = useJoinByDomain();\n const navigate = useNavigate();\n const [open, setOpen] = useState(false);\n const [mode, setMode] = useState<Mode>(\"list\");\n const [newName, setNewName] = useState(\"\");\n const [inviteEmail, setInviteEmail] = useState(\"\");\n const [signingOut, setSigningOut] = useState(false);\n const [joiningOrgId, setJoiningOrgId] = useState<string | null>(null);\n const appLinks = useOrgSwitcherAppLinks(open);\n\n const handleOpenChange = (next: boolean) => {\n setOpen(next);\n if (!next) {\n setMode(\"list\");\n setNewName(\"\");\n setInviteEmail(\"\");\n }\n };\n\n const handleSignOut = async () => {\n if (signingOut) return;\n setSigningOut(true);\n try {\n await fetch(agentNativePath(\"/_agent-native/auth/logout\"), {\n method: \"POST\",\n credentials: \"include\",\n });\n } catch {\n /* fall through to reload — server may already have cleared the cookie */\n }\n window.location.reload();\n };\n\n if (!org) {\n return reserveSpace && isLoading ? (\n <OrgSwitcherLoadingPlaceholder className={className} />\n ) : null;\n }\n\n const orgs = org.orgs ?? [];\n const pendingInvitations = org.pendingInvitations ?? [];\n const domainMatches = org.domainMatches ?? [];\n const orgCount = orgs.length;\n const hasAny =\n orgCount > 0 || pendingInvitations.length > 0 || domainMatches.length > 0;\n if (!hasAny && !org.email) {\n return reserveSpace ? (\n <ReservedOrgSwitcherSpace className={className} />\n ) : null;\n }\n if (\n hideWhenSingle &&\n orgCount < 2 &&\n pendingInvitations.length === 0 &&\n domainMatches.length === 0\n ) {\n return reserveSpace ? (\n <ReservedOrgSwitcherSpace className={className} />\n ) : null;\n }\n\n const canInvite =\n !!org.orgId && (org.role === \"owner\" || org.role === \"admin\");\n\n const personalLabel = session?.name || personalLabelFromEmail(org.email);\n const inOrg = !!org.orgId;\n const buttonLabel = org.orgName ?? \"Personal\";\n const ButtonIcon = inOrg ? IconUsersGroup : IconUser;\n const organizationSettingsHref = settingsPath\n ? organizationSettingsPath(settingsPath)\n : null;\n\n return (\n <PopoverPrimitive.Root open={open} onOpenChange={handleOpenChange}>\n <PopoverPrimitive.Trigger asChild>\n {compact ? (\n <button\n type=\"button\"\n title={buttonLabel}\n aria-label={buttonLabel}\n className={`${COMPACT_SWITCHER_BUTTON_CLASS} ${className ?? \"\"}`}\n >\n <ButtonIcon className=\"h-3.5 w-3.5 shrink-0\" />\n </button>\n ) : (\n <button\n type=\"button\"\n className={`${SWITCHER_BUTTON_CLASS} ${className ?? \"\"}`}\n >\n <ButtonIcon className=\"h-3.5 w-3.5 shrink-0\" />\n <span className=\"truncate flex-1 text-start\">{buttonLabel}</span>\n <IconSelector className=\"h-3 w-3 shrink-0 opacity-50\" />\n </button>\n )}\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n side=\"top\"\n align=\"start\"\n sideOffset={6}\n collisionPadding={12}\n className={`${POPOVER_CONTENT_CLASS} ${mode === \"list\" ? \"\" : \"w-64\"}`}\n onOpenAutoFocus={(e) => {\n // Don't auto-focus the first item — feels heavy on a switcher.\n if (mode === \"list\") e.preventDefault();\n }}\n >\n {mode === \"list\" && (\n <>\n {!inOrg && (\n <div\n className=\"flex w-full items-center gap-2 px-2.5 py-1.5 text-xs text-muted-foreground\"\n aria-disabled=\"true\"\n >\n <IconUser className=\"h-3.5 w-3.5 shrink-0\" />\n <span className=\"truncate flex-1 text-start\">\n Personal ({personalLabel})\n </span>\n </div>\n )}\n {orgs.length > 0 && (\n <div className={SECTION_LABEL_CLASS}>Organizations</div>\n )}\n {orgs.map((o) => (\n <button\n key={o.orgId}\n type=\"button\"\n onClick={async () => {\n if (o.orgId === org.orgId) {\n setOpen(false);\n return;\n }\n try {\n await switchOrg.mutateAsync(o.orgId);\n setOpen(false);\n } catch {\n /* error surfaced via switchOrg.error */\n }\n }}\n disabled={switchOrg.isPending}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n <IconUsersGroup className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate flex-1 text-start\">\n {o.orgName}\n </span>\n {o.orgId === org.orgId && (\n <IconCheck className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n )}\n </button>\n ))}\n\n {pendingInvitations.length > 0 && (\n <>\n {orgs.length > 0 && <div className=\"my-1 h-px bg-border\" />}\n <div className={SECTION_LABEL_CLASS}>Invitations</div>\n {pendingInvitations.map((inv) => (\n <div key={inv.id} className=\"px-2.5 py-1.5 text-xs\">\n <div className=\"flex items-center gap-2\">\n <IconUsersGroup className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate flex-1 text-foreground\">\n {inv.orgName}\n </span>\n <button\n type=\"button\"\n onClick={async () => {\n try {\n await acceptInvitation.mutateAsync(inv.id);\n setOpen(false);\n } catch {\n /* error surfaced via acceptInvitation.error */\n }\n }}\n disabled={acceptInvitation.isPending}\n className=\"rounded px-1.5 py-0.5 text-[11px] font-medium text-primary hover:bg-primary/10 disabled:opacity-50 cursor-pointer\"\n >\n {acceptInvitation.isPending ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n \"Join\"\n )}\n </button>\n </div>\n {org.orgId && (\n <p className=\"mt-1 flex items-start gap-1.5 text-[11px] leading-snug text-muted-foreground\">\n <IconKey className=\"mt-0.5 h-3 w-3 shrink-0\" />\n <span>\n {t(\"org.acceptInvitationOrgSwitchNotice\", {\n name: inv.orgName,\n })}\n </span>\n </p>\n )}\n </div>\n ))}\n </>\n )}\n\n {domainMatches.length > 0 && (\n <>\n {(orgs.length > 0 || pendingInvitations.length > 0) && (\n <div className=\"my-1 h-px bg-border\" />\n )}\n <div className={SECTION_LABEL_CLASS}>Join your team</div>\n {domainMatches.map((match) => {\n const isJoining =\n joinByDomain.isPending && joiningOrgId === match.orgId;\n return (\n <div\n key={match.orgId}\n className=\"flex items-center gap-2 px-2.5 py-1.5 text-xs\"\n >\n <IconUsersGroup className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate flex-1 text-foreground\">\n {match.orgName}\n </span>\n <button\n type=\"button\"\n onClick={async () => {\n setJoiningOrgId(match.orgId);\n try {\n await joinByDomain.mutateAsync(match.orgId);\n setOpen(false);\n } catch {\n /* error surfaced via joinByDomain.error */\n } finally {\n setJoiningOrgId(null);\n }\n }}\n disabled={joinByDomain.isPending}\n className=\"rounded px-1.5 py-0.5 text-[11px] font-medium text-primary hover:bg-primary/10 disabled:opacity-50 cursor-pointer\"\n >\n {isJoining ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n \"Join\"\n )}\n </button>\n </div>\n );\n })}\n </>\n )}\n\n <div className=\"my-1 h-px bg-border\" />\n <AppsSubmenu\n apps={appLinks.apps}\n isLoading={appLinks.isLoading}\n dispatchHref={appLinks.dispatchHref}\n dispatchAllAppsHref={appLinks.dispatchAllAppsHref}\n onNavigate={() => setOpen(false)}\n />\n {profilePath && (\n <button\n type=\"button\"\n onClick={() => {\n setOpen(false);\n navigate(profilePath);\n }}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n <IconUserCircle className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1 text-start\">\n {t(\"settings.profileMenuItem\")}\n </span>\n </button>\n )}\n {inOrg && (\n <button\n type=\"button\"\n onClick={() => {\n setOpen(false);\n if (organizationSettingsHref) {\n navigate(organizationSettingsHref);\n } else {\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:open-settings\", {\n detail: { section: \"workspace-settings\" },\n }),\n );\n }\n }}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n <IconSettings className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1 text-start\">\n Organization settings\n </span>\n </button>\n )}\n <button\n type=\"button\"\n onClick={() => {\n // Clear any leftover input from a prior session — otherwise\n // the create form re-opens prefilled with the just-created\n // org's name and looks like a create dialog for the new org.\n setNewName(\"\");\n setMode(\"create\");\n }}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n <IconPlus className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1 text-start\">Create organization</span>\n </button>\n {canInvite && (\n <button\n type=\"button\"\n onClick={() => {\n setInviteEmail(\"\");\n setMode(\"invite\");\n }}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n <IconUserPlus className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"flex-1 text-start\">Invite member</span>\n </button>\n )}\n\n <div className=\"my-1 h-px bg-border\" />\n <button\n type=\"button\"\n onClick={handleSignOut}\n disabled={signingOut}\n className={`${ITEM_CLASS} cursor-pointer`}\n >\n {signingOut ? (\n <IconLoader2 className=\"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground\" />\n ) : (\n <IconLogout className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground rtl:-scale-x-100\" />\n )}\n <span className=\"flex-1 text-start\">\n Sign out\n {org.email ? (\n <span className=\"ms-1 text-muted-foreground\">\n ({org.email})\n </span>\n ) : null}\n </span>\n </button>\n\n {(switchOrg.error ||\n acceptInvitation.error ||\n joinByDomain.error) && (\n <div className=\"px-2.5 pt-1 text-[11px] text-destructive\">\n {\n (\n (switchOrg.error ||\n acceptInvitation.error ||\n joinByDomain.error) as Error\n ).message\n }\n </div>\n )}\n </>\n )}\n\n {mode === \"create\" && (\n <form\n onSubmit={async (e) => {\n e.preventDefault();\n const name = newName.trim();\n if (!name) return;\n try {\n await createOrg.mutateAsync(name);\n handleOpenChange(false);\n } catch {\n /* error surfaced via createOrg.error */\n }\n }}\n className=\"px-2 py-1.5\"\n >\n <div className=\"px-0.5 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground\">\n New organization\n </div>\n <p className=\"pe-0.5 pb-1.5 ps-2 text-[11px] leading-snug text-muted-foreground\">\n <IconKey className=\"me-1.5 inline-block h-3 w-3 align-text-top\" />\n {t(\"org.createOrgVaultNotice\")}\n </p>\n <input\n autoFocus\n value={newName}\n onChange={(e) => setNewName(e.target.value)}\n placeholder=\"Organization name\"\n disabled={createOrg.isPending}\n className=\"w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs outline-none focus:ring-2 focus:ring-ring disabled:opacity-50\"\n />\n {createOrg.error && (\n <div className=\"pt-1 text-[11px] text-destructive\">\n {(createOrg.error as Error).message}\n </div>\n )}\n <div className=\"flex items-center gap-1.5 pt-1.5\">\n <button\n type=\"button\"\n onClick={() => setMode(\"list\")}\n disabled={createOrg.isPending}\n className=\"flex-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent disabled:opacity-50 cursor-pointer\"\n >\n Cancel\n </button>\n <button\n type=\"submit\"\n disabled={createOrg.isPending || !newName.trim()}\n className=\"flex flex-1 items-center justify-center rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50 cursor-pointer\"\n >\n {createOrg.isPending ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n \"Create\"\n )}\n </button>\n </div>\n </form>\n )}\n\n {mode === \"invite\" && (\n <form\n onSubmit={async (e) => {\n e.preventDefault();\n const email = inviteEmail.trim();\n if (!email) return;\n try {\n await inviteMember.mutateAsync(email);\n setInviteEmail(\"\");\n setMode(\"list\");\n } catch {\n /* error surfaced via inviteMember.error */\n }\n }}\n className=\"px-2 py-1.5\"\n >\n <div className=\"px-0.5 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground\">\n Invite to {org.orgName}\n </div>\n <input\n autoFocus\n type=\"email\"\n value={inviteEmail}\n onChange={(e) => setInviteEmail(e.target.value)}\n placeholder=\"teammate@company.com\"\n disabled={inviteMember.isPending}\n className=\"w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs outline-none focus:ring-2 focus:ring-ring disabled:opacity-50\"\n />\n {inviteMember.error && (\n <div className=\"pt-1 text-[11px] text-destructive\">\n {(inviteMember.error as Error).message}\n </div>\n )}\n <div className=\"flex items-center gap-1.5 pt-1.5\">\n <button\n type=\"button\"\n onClick={() => setMode(\"list\")}\n disabled={inviteMember.isPending}\n className=\"flex-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent disabled:opacity-50 cursor-pointer\"\n >\n Cancel\n </button>\n <button\n type=\"submit\"\n disabled={inviteMember.isPending || !inviteEmail.trim()}\n className=\"flex flex-1 items-center justify-center rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50 cursor-pointer\"\n >\n {inviteMember.isPending ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n \"Send invite\"\n )}\n </button>\n </div>\n </form>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n}\n"]}
@@ -26,8 +26,8 @@ export declare const getCollabState: import("h3").EventHandlerWithFetch<import("
26
26
  * Body: { update: string (base64), requestSource?: string }
27
27
  */
28
28
  export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
29
- error: string;
30
29
  ok?: undefined;
30
+ error: string;
31
31
  } | {
32
32
  error?: undefined;
33
33
  ok: boolean;