Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat: Consolidated container-chat loading, Centralized share-cache refreshes, Added visible team-loading errors

Chadpiha2612548391f6
diff --git a/src/components/CreateTeamDialog.tsx b/src/components/CreateTeamDialog.tsx
index f7e0444e9..57196a109 100644
--- a/src/components/CreateTeamDialog.tsx
+++ b/src/components/CreateTeamDialog.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useMemo, useState } from "react";
+import { useCallback, useEffect, useMemo, useState } from "react";
import { useShallow } from "zustand/react/shallow";
import { useTranslation } from "react-i18next";
import { Loader2 } from "lucide-react";
@@ -45,14 +45,21 @@ export default function CreateTeamDialog({
const [isCreating, setIsCreating] = useState(false);
const showSpinner = useDelayedFlag(isCreating);
- useEffect(() => {
- if (!open) return;
+ const loadMembers = useCallback(async () => {
setMembersError(false);
setRosterLoaded(false);
- refreshMembers(workspaceId)
- .then(() => setRosterLoaded(true))
- .catch(() => setMembersError(true));
- }, [open, workspaceId, refreshMembers]);
+ try {
+ await refreshMembers(workspaceId);
+ setRosterLoaded(true);
+ } catch {
+ setMembersError(true);
+ }
+ }, [refreshMembers, workspaceId]);
+
+ useEffect(() => {
+ if (!open) return;
+ void loadMembers();
+ }, [open, loadMembers]);
const candidates = useMemo(
() => (rosterLoaded ? orderMemberCandidates(roster, user?.id) : []),
@@ -148,12 +155,7 @@ export default function CreateTeamDialog({
<Button
variant="ghost"
size="sm"
- onClick={() => {
- setMembersError(false);
- refreshMembers(workspaceId)
- .then(() => setRosterLoaded(true))
- .catch(() => setMembersError(true));
- }}
+ onClick={() => void loadMembers()}
className="h-6 px-2 text-xs shrink-0"
>
{t("settingsPage.workspace.loadError.retry")}
diff --git a/src/components/chat/ChatMessage.tsx b/src/components/chat/ChatMessage.tsx
index 4240f1710..dc19e452d 100644
--- a/src/components/chat/ChatMessage.tsx
+++ b/src/components/chat/ChatMessage.tsx
@@ -207,7 +207,7 @@ export function ChatMessage({
const hasToolCalls = toolCalls && toolCalls.length > 0;
const hasContent = content.length > 0;
- const noteCards = extractNoteCards(toolCalls);
+ const noteCards = extractNoteCards(toolCalls, t("notes.list.untitledNote"));
return (
<div
diff --git a/src/components/chat/noteCards.ts b/src/components/chat/noteCards.ts
index 093b18e63..140b537b8 100644
--- a/src/components/chat/noteCards.ts
+++ b/src/components/chat/noteCards.ts
@@ -10,20 +10,27 @@ const NOTE_TOOLS = new Set(["create_note", "update_note", "get_note"]);
// doesn't bury the answer under a wall of note buttons.
const MAX_SEARCH_CARDS = 5;
-function cardFromHit(hit: Record<string, unknown>, seen: Set<number>): NoteCardRef | null {
+function cardFromHit(
+ hit: Record<string, unknown>,
+ seen: Set<number>,
+ fallbackTitle: string
+): NoteCardRef | null {
// Cloud search hits carry null ids for notes with no local row — nothing to
// open. Non-numeric ids (cloud UUIDs) are equally unopenable locally.
if (hit.id == null) return null;
const noteId = Number(hit.id);
if (!Number.isFinite(noteId) || seen.has(noteId)) return null;
seen.add(noteId);
- return { noteId, title: typeof hit.title === "string" && hit.title ? hit.title : "Note" };
+ return { noteId, title: typeof hit.title === "string" && hit.title ? hit.title : fallbackTitle };
}
// Note cards rendered under an assistant message: one per note the turn
// created/updated/fetched, plus up to MAX_SEARCH_CARDS notes its searches
// grounded on. Single pass in toolCalls order, deduped across tools.
-export function extractNoteCards(toolCalls?: ToolCallInfo[]): NoteCardRef[] {
+export function extractNoteCards(
+ toolCalls: ToolCallInfo[] | undefined,
+ fallbackTitle: string
+): NoteCardRef[] {
if (!toolCalls) return [];
const cards: NoteCardRef[] = [];
const seen = new Set<number>();
@@ -39,12 +46,12 @@ export function extractNoteCards(toolCalls?: ToolCallInfo[]): NoteCardRef[] {
const title =
(tc.metadata.title as string) ||
tc.result?.replace(/^(Created|Updated|Retrieved) note: "(.+)"$/, "$2") ||
- "Note";
+ fallbackTitle;
cards.push({ noteId, title });
} else if (tc.name === "search_notes" && Array.isArray(tc.metadata)) {
for (const hit of tc.metadata) {
if (searchCards >= MAX_SEARCH_CARDS) break;
- const card = cardFromHit(hit, seen);
+ const card = cardFromHit(hit, seen, fallbackTitle);
if (!card) continue;
cards.push(card);
searchCards += 1;
diff --git a/src/components/notes/ConversationPicker.tsx b/src/components/notes/ConversationPicker.tsx
new file mode 100644
index 000000000..702b9e9bf
--- /dev/null
+++ b/src/components/notes/ConversationPicker.tsx
@@ -0,0 +1,73 @@
+import { ChevronDown, Plus } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { ContainerConversationItem } from "../../hooks/useContainerChat";
+import { formatShortDate } from "../../utils/dateFormatting";
+import { cn } from "../lib/utils";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from "../ui/dropdown-menu";
+
+interface ConversationPickerProps {
+ conversations: ContainerConversationItem[];
+ activeConversationId?: number | null;
+ onSwitchConversation: (id: number) => void;
+ onNewChat?: () => void;
+ titleClassName?: string;
+}
+
+export function ConversationPicker({
+ conversations,
+ activeConversationId,
+ onSwitchConversation,
+ onNewChat,
+ titleClassName,
+}: ConversationPickerProps) {
+ const { t } = useTranslation();
+ const activeConversation = conversations.find((item) => item.id === activeConversationId);
+
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button
+ className="inline-flex items-center gap-1 text-xs font-medium text-foreground/50 hover:text-foreground/70 hover:bg-foreground/5 rounded-md px-1.5 py-0.5 -ml-1.5 transition-colors duration-150 outline-none"
+ aria-label={t("embeddedChat.conversationSelector")}
+ >
+ <span className={cn("truncate max-w-40", titleClassName)}>
+ {activeConversation?.title || t("embeddedChat.newChat")}
+ </span>
+ <ChevronDown size={10} className="shrink-0 text-foreground/30" />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" sideOffset={4} className="min-w-44 max-w-56 p-1">
+ <DropdownMenuItem onClick={onNewChat} className="text-xs gap-2 rounded-md px-2 py-1.5">
+ <Plus size={10} className="text-foreground/40 shrink-0" />
+ {t("embeddedChat.newChat")}
+ </DropdownMenuItem>
+ {conversations.length > 0 && (
+ <>
+ <DropdownMenuSeparator />
+ {conversations.map((conversation) => (
+ <DropdownMenuItem
+ key={conversation.id}
+ onClick={() => onSwitchConversation(conversation.id)}
+ className={cn(
+ "text-xs gap-2 rounded-md px-2 py-1.5",
+ conversation.id === activeConversationId && "bg-foreground/4"
+ )}
+ >
+ <span className="truncate flex-1">{conversation.title}</span>
+ <span className="text-[10px] text-foreground/30 shrink-0">
+ {formatShortDate(conversation.updated_at)}
+ </span>
+ </DropdownMenuItem>
+ ))}
+ </>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
diff --git a/src/components/notes/CreateSpaceDialog.tsx b/src/components/notes/CreateSpaceDialog.tsx
index 26ffb32aa..b4552aa49 100644
--- a/src/components/notes/CreateSpaceDialog.tsx
+++ b/src/components/notes/CreateSpaceDialog.tsx
@@ -314,44 +314,62 @@ export default function CreateSpaceDialog({
it renders as fixed context rather than a picker. */}
{workspaces.length > 1 && workspace && (
<div className="space-y-1.5">
- <label className="text-xs font-medium text-foreground/50">
- {t("settingsPage.workspace.title")}
- </label>
{manageableWorkspaces.length > 1 && !initialWorkspaceId ? (
- <Select value={workspace.id} onValueChange={handleWorkspaceChange}>
- <SelectTrigger>
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- {manageableWorkspaces.map((item) => (
- <SelectItem key={item.id} value={item.id}>
- {item.name}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
+ <>
+ <label
+ htmlFor="create-space-workspace"
+ className="text-xs font-medium text-foreground/50"
+ >
+ {t("settingsPage.workspace.title")}
+ </label>
+ <Select value={workspace.id} onValueChange={handleWorkspaceChange}>
+ <SelectTrigger id="create-space-workspace">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {manageableWorkspaces.map((item) => (
+ <SelectItem key={item.id} value={item.id}>
+ {item.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </>
) : (
- <p className="text-sm text-foreground truncate">{workspace.name}</p>
+ <>
+ <p className="text-xs font-medium text-foreground/50">
+ {t("settingsPage.workspace.title")}
+ </p>
+ <p className="text-sm text-foreground truncate">{workspace.name}</p>
+ </>
)}
</div>
)}
<div className="flex gap-3">
<div className="space-y-1.5 w-14 shrink-0">
- <label className="text-xs font-medium text-foreground/50">
+ <label
+ htmlFor="create-space-emoji"
+ className="text-xs font-medium text-foreground/50"
+ >
{t("notes.spaces.emojiLabel")}
</label>
<EmojiPickerInput
+ id="create-space-emoji"
value={emoji}
onChange={setEmoji}
ariaLabel={t("notes.spaces.changeEmoji")}
/>
</div>
<div className="space-y-1.5 flex-1">
- <label className="text-xs font-medium text-foreground/50">
+ <label
+ htmlFor="create-space-name"
+ className="text-xs font-medium text-foreground/50"
+ >
{t("notes.spaces.nameLabel")}
</label>
<Input
+ id="create-space-name"
value={name}
autoFocus
maxLength={80}
@@ -364,9 +382,9 @@ export default function CreateSpaceDialog({
</div>
<div className="space-y-1.5">
- <label className="text-xs font-medium text-foreground/50">
+ <p className="text-xs font-medium text-foreground/50">
{t("notes.spaces.teams.assignLabel")}
- </label>
+ </p>
{teamsError && teams.length === 0 ? (
<div className="rounded border border-border/70 dark:border-border-subtle/50 px-3 py-2.5 flex items-center justify-between gap-2">
<p className="text-xs text-muted-foreground">
@@ -421,10 +439,14 @@ export default function CreateSpaceDialog({
{newTeamOpen ? (
<div className="rounded border border-border/70 dark:border-border-subtle/50 p-2.5 space-y-2">
<div className="space-y-1.5">
- <label className="text-xs font-medium text-foreground/50">
+ <label
+ htmlFor="create-space-new-team-name"
+ className="text-xs font-medium text-foreground/50"
+ >
{t("notes.spaces.teams.newTeamNameLabel")}
</label>
<Input
+ id="create-space-new-team-name"
value={newTeamName}
maxLength={80}
placeholder={name.trim() || undefined}
@@ -468,7 +490,7 @@ export default function CreateSpaceDialog({
}}
className="h-6 px-2 text-xs"
>
- {t("notes.upload.cancel")}
+ {t("common.cancel")}
</Button>
)}
</div>
@@ -517,7 +539,7 @@ export default function CreateSpaceDialog({
onClick={() => handleOpenChange(false)}
disabled={isCreating}
>
- {t("notes.upload.cancel")}
+ {t("common.cancel")}
</Button>
<Button
onClick={handleCreate}
diff --git a/src/components/notes/EmbeddedChat.tsx b/src/components/notes/EmbeddedChat.tsx
index 84b9ec22c..1d36d85e1 100644
--- a/src/components/notes/EmbeddedChat.tsx
+++ b/src/components/notes/EmbeddedChat.tsx
@@ -1,19 +1,13 @@
import { useEffect, useCallback } from "react";
import { useTranslation } from "react-i18next";
-import { X, PanelRight, PanelRightClose, ChevronDown, Plus } from "lucide-react";
+import { X, PanelRight, PanelRightClose } from "lucide-react";
import { cn } from "../lib/utils";
import { ChatMessages } from "../chat/ChatMessages";
import { ChatInput } from "../chat/ChatInput";
import type { Message, AgentState } from "../chat/types";
import { setActiveNoteId, setActiveFolderId } from "../../stores/noteStore";
-import { formatShortDate } from "../../utils/dateFormatting";
-import {
- DropdownMenu,
- DropdownMenuTrigger,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuSeparator,
-} from "../ui/dropdown-menu";
+import type { ContainerConversationItem } from "../../hooks/useContainerChat";
+import { ConversationPicker } from "./ConversationPicker";
export type EmbeddedChatMode = "hidden" | "floating" | "sidebar";
@@ -24,13 +18,7 @@ interface EmbeddedChatProps {
agentState: AgentState;
onTextSubmit: (text: string) => void;
onCancel: () => void;
- noteConversations?: Array<{
- id: number;
- title: string;
- created_at: string;
- updated_at: string;
- message_count: number;
- }>;
+ noteConversations?: ContainerConversationItem[];
activeConversationId?: number | null;
onSwitchConversation?: (id: number) => void;
onNewChat?: () => void;
@@ -86,53 +74,14 @@ export default function EmbeddedChat({
const hasConversationSelector =
noteConversations !== undefined && onSwitchConversation !== undefined;
- const activeConversation = hasConversationSelector
- ? noteConversations.find((c) => c.id === activeConversationId)
- : undefined;
-
const headerTitle = hasConversationSelector ? (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <button
- className="inline-flex items-center gap-1 text-xs font-medium text-foreground/50 hover:text-foreground/70 hover:bg-foreground/5 rounded-md px-1.5 py-0.5 -ml-1.5 transition-colors duration-150 outline-none"
- aria-label={t("embeddedChat.conversationSelector")}
- >
- <span className="truncate max-w-32">
- {activeConversation?.title || t("embeddedChat.newChat")}
- </span>
- <ChevronDown size={10} className="shrink-0 text-foreground/30" />
- </button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start" sideOffset={4} className="min-w-44 max-w-56 p-1">
- <DropdownMenuItem
- onClick={() => onNewChat?.()}
- className="text-xs gap-2 rounded-md px-2 py-1.5"
- >
- <Plus size={10} className="text-foreground/40 shrink-0" />
- {t("embeddedChat.newChat")}
- </DropdownMenuItem>
- {noteConversations.length > 0 && (
- <>
- <DropdownMenuSeparator />
- {noteConversations.map((conv) => (
- <DropdownMenuItem
- key={conv.id}
- onClick={() => onSwitchConversation(conv.id)}
- className={cn(
- "text-xs gap-2 rounded-md px-2 py-1.5",
- conv.id === activeConversationId && "bg-foreground/4"
- )}
- >
- <span className="truncate flex-1">{conv.title}</span>
- <span className="text-[10px] text-foreground/30 shrink-0">
- {formatShortDate(conv.updated_at)}
- </span>
- </DropdownMenuItem>
- ))}
- </>
- )}
- </DropdownMenuContent>
- </DropdownMenu>
+ <ConversationPicker
+ conversations={noteConversations}
+ activeConversationId={activeConversationId}
+ onSwitchConversation={onSwitchConversation}
+ onNewChat={onNewChat}
+ titleClassName="max-w-32"
+ />
) : (
<span className="text-xs font-medium text-foreground/50">{t("embeddedChat.title")}</span>
);
diff --git a/src/components/notes/EmojiPickerInput.tsx b/src/components/notes/EmojiPickerInput.tsx
index 460660446..3b34c9d92 100644
--- a/src/components/notes/EmojiPickerInput.tsx
+++ b/src/components/notes/EmojiPickerInput.tsx
@@ -32,6 +32,7 @@ const EMOJI_CHOICES = [
];
interface EmojiPickerInputProps {
+ id?: string;
value: string;
onChange: (value: string) => void;
ariaLabel: string;
@@ -48,6 +49,7 @@ interface EmojiPickerInputProps {
// Emoji field with the OS emoji panel where one exists (macOS) and a 24-emoji
// grid fallback (Linux, or when the panel can't be shown).
export function EmojiPickerInput({
+ id,
value,
onChange,
ariaLabel,
@@ -72,6 +74,7 @@ export function EmojiPickerInput({
<Popover open={pickerOpen} onOpenChange={setOpen}>
<PopoverAnchor asChild>
<Input
+ id={id}
ref={inputRef}
autoFocus={autoFocus}
value={value}
diff --git a/src/components/notes/NoteEditor.tsx b/src/components/notes/NoteEditor.tsx
index 447035a89..322a4d841 100644
--- a/src/components/notes/NoteEditor.tsx
+++ b/src/components/notes/NoteEditor.tsx
@@ -42,7 +42,7 @@ import {
updateShareCache,
} from "../../stores/noteStore";
import { NoteSharingService } from "../../services/NoteSharingService";
-import { fetchSpaceRoster } from "../../hooks/useTeamRoster";
+import { fetchSpaceRoster } from "../../hooks/useSpaceRoster";
import { readIsSubscribed, subscribeIsSubscribed } from "../../lib/subscriptionFlag";
import { useAuth } from "../../hooks/useAuth";
import { RichTextEditor } from "../ui/RichTextEditor";
@@ -66,7 +66,7 @@ import ActionProcessingOverlay from "./ActionProcessingOverlay";
import NoteBottomBar from "./NoteBottomBar";
import EmbeddedChat, { type EmbeddedChatMode } from "./EmbeddedChat";
import { useEmbeddedChat } from "../../hooks/useEmbeddedChat";
-import { normalizeDbDate, formatRelativeTime } from "../../utils/dateFormatting";
+import { normalizeDbDate, formatRelativeTime, formatShortDate } from "../../utils/dateFormatting";
import { parseTranscriptSegments } from "../../utils/parseTranscriptSegments";
import {
applyTranscriptSpeakerPatch,
@@ -92,12 +92,6 @@ function formatNoteDate(dateStr: string): string {
return `${datePart} \u00b7 ${timePart}`;
}
-function formatShortDate(dateStr: string): string {
- const date = normalizeDbDate(dateStr);
- if (Number.isNaN(date.getTime())) return "";
- return date.toLocaleDateString(undefined, { month: "short", day: "numeric" });
-}
-
export interface Enhancement {
content: string;
isStale: boolean;
diff --git a/src/components/notes/PersonalNotesView.tsx b/src/components/notes/PersonalNotesView.tsx
index f88b3c3b1..7103b0347 100644
--- a/src/components/notes/PersonalNotesView.tsx
+++ b/src/components/notes/PersonalNotesView.tsx
@@ -55,10 +55,7 @@ import { useWorkspaceStore } from "../../stores/workspaceStore";
import { useAuth } from "../../hooks/useAuth";
import NotesOnboarding from "./NotesOnboarding";
import { isRegenerableNoteTitle } from "../../helpers/regenerableNoteTitle";
-import {
- markNotesStructureIntroSeen,
- shouldShowNotesStructureIntro,
-} from "../../lib/notesStructureIntro";
+import { markIntroSeen, NOTES_STRUCTURE_INTRO, shouldShowIntro } from "../../lib/versionedIntro";
function makeContentHash(content: string): string {
return String(content.length) + "-" + content.slice(0, 50);
@@ -124,7 +121,7 @@ export default function PersonalNotesView({
const teamSpacesAvailable = useTeamSpacesCapability();
const isTreeLoading = useIsTreeLoading();
const [structureIntroPending, setStructureIntroPending] = useState(() =>
- shouldShowNotesStructureIntro(localStorage)
+ shouldShowIntro(localStorage, NOTES_STRUCTURE_INTRO)
);
const [showStructureIntro, setShowStructureIntro] = useState(false);
@@ -209,7 +206,7 @@ export default function PersonalNotesView({
const handleStructureIntroOpenChange = useCallback((open: boolean) => {
setShowStructureIntro(open);
if (!open) {
- markNotesStructureIntroSeen(localStorage);
+ markIntroSeen(localStorage, NOTES_STRUCTURE_INTRO);
setStructureIntroPending(false);
}
}, []);
diff --git a/src/components/notes/ShareNoteDialog.tsx b/src/components/notes/ShareNoteDialog.tsx
index 296bf0d39..32922ba47 100644
--- a/src/components/notes/ShareNoteDialog.tsx
+++ b/src/components/notes/ShareNoteDialog.tsx
@@ -17,6 +17,7 @@ import {
NoteSharingService,
type AccessPrincipalSuggestion,
type ShareMutationResponse,
+ type ShareStateResponse,
} from "../../services/NoteSharingService.js";
import { syncService } from "../../services/SyncService.js";
import { CloudApiError } from "../../services/cloudApi.js";
@@ -32,6 +33,7 @@ import MemberAvatar from "../MemberAvatar";
import { emailDomain, isPersonalEmailDomain } from "../../utils/personalEmailDomains";
import type {
NoteAccessGrant,
+ NoteAccessState,
NoteItem,
NoteShareInvitation,
ShareVisibility,
@@ -115,6 +117,23 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteD
// While server state loads, the persisted flag keeps the footer honest.
const isPrivate = share ? share.visibility === "private" : !note.is_shared;
+ const refreshShareCache = useCallback(
+ async (
+ resolveFallbackAccess?: (current: NoteAccessState | undefined) => NoteAccessState | undefined
+ ): Promise<ShareStateResponse | null> => {
+ if (!cloudId) return null;
+ const refreshed = await NoteSharingService.getShareSettings(cloudId);
+ updateShareCache(cloudId, (entry) => ({
+ share: refreshed.share,
+ invitations: refreshed.invitations,
+ access: refreshed.access ?? resolveFallbackAccess?.(entry?.access) ?? entry?.access,
+ rawToken: entry?.rawToken ?? null,
+ }));
+ return refreshed;
+ },
+ [cloudId]
+ );
+
// The store's note can miss a cloud_id assigned by a background sync
// (markNoteSynced doesn't broadcast); read the DB before offering to sync.
useEffect(() => {
@@ -139,15 +158,9 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteD
let cancelled = false;
setLoading(true);
setLoadError(false);
- NoteSharingService.getShareSettings(cloudId)
+ refreshShareCache()
.then((res) => {
- if (cancelled) return;
- updateShareCache(cloudId, (entry) => ({
- share: res.share,
- invitations: res.invitations,
- access: res.access ?? entry?.access,
- rawToken: entry?.rawToken ?? null,
- }));
+ if (cancelled || !res) return;
const serverShared = res.share.visibility !== "private";
if (serverShared !== localIsSharedRef.current) {
void persistNoteShareState(
@@ -167,7 +180,7 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteD
return () => {
cancelled = true;
};
- }, [open, cloudId, note.id, loadAttempt]);
+ }, [open, cloudId, note.id, loadAttempt, refreshShareCache]);
useEffect(() => {
if (open) {
@@ -372,12 +385,8 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteD
setEmailInput("");
}
// Re-fetch invitations so any new + still-pending rows appear.
- const refreshed = await NoteSharingService.getShareSettings(cloudId);
- updateShareCache(cloudId, (entry) => ({
- share: refreshed.share,
- invitations: refreshed.invitations,
- rawToken: entry?.rawToken ?? null,
- }));
+ const refreshed = await refreshShareCache();
+ if (!refreshed) return;
// The invite itself is the sharing consent: a still-private note becomes
// invite-only once an invitation exists.
if (refreshed.share.visibility === "private" && res.created.length > 0) {
@@ -393,7 +402,7 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteD
} finally {
setSubmitting(false);
}
- }, [cloudId, canManageSharing, emailInput, applyVisibility, t]);
+ }, [cloudId, canManageSharing, emailInput, applyVisibility, refreshShareCache, t]);
const handlePrincipalGrant = useCallback(
async (principal: AccessPrincipalSuggestion) => {
@@ -407,17 +416,12 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteD
...(principal.email ? { email: principal.email } : {}),
permission: "viewer",
});
- const refreshed = await NoteSharingService.getShareSettings(cloudId);
- updateShareCache(cloudId, (entry) => ({
- share: refreshed.share,
- invitations: refreshed.invitations,
- access:
- refreshed.access ??
- (entry?.access
- ? { ...entry.access, grants: [...entry.access.grants, grant] }
- : cached.access),
- rawToken: entry?.rawToken ?? cached.rawToken,
- }));
+ const refreshed = await refreshShareCache((currentAccess) =>
+ currentAccess
+ ? { ...currentAccess, grants: [...currentAccess.grants, grant] }
+ : cached.access
+ );
+ if (!refreshed) return;
if (refreshed.share.visibility !== "private") {
void persistNoteShareState(note.id, { is_shared: 1 }).catch((err) =>
console.error("Share flag persist failed:", err)
@@ -432,7 +436,7 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteD
setSubmitting(false);
}
},
- [cloudId, cached, note.id, t]
+ [cloudId, cached, note.id, refreshShareCache, t]
);
const handleShareInput = useCallback(async () => {
@@ -565,13 +569,7 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteD
replaceAccessGrant(grant.id, null);
try {
await NoteSharingService.removeAccessGrant(cloudId, grant.id);
- const refreshed = await NoteSharingService.getShareSettings(cloudId);
- updateShareCache(cloudId, (entry) => ({
- share: refreshed.share,
- invitations: refreshed.invitations,
- access: refreshed.access ?? entry?.access,
- rawToken: entry?.rawToken ?? null,
- }));
+ await refreshShareCache();
} catch (err) {
console.error("Access grant removal failed:", err);
replaceAccessGrant(grant.id, grant);
@@ -580,7 +578,7 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteD
setBusyGrantId(null);
}
},
- [cloudId, replaceAccessGrant, t, toast]
+ [cloudId, refreshShareCache, replaceAccessGrant, t, toast]
);
const handleSyncAndShare = useCallback(async () => {
diff --git a/src/components/notes/SpaceMembersDialog.tsx b/src/components/notes/SpaceMembersDialog.tsx
index 038516bef..03aea4a74 100644
--- a/src/components/notes/SpaceMembersDialog.tsx
+++ b/src/components/notes/SpaceMembersDialog.tsx
@@ -52,6 +52,8 @@ export default function SpaceMembersDialog({ space, open, onOpenChange }: SpaceM
}))
);
const [workspaceTeams, setWorkspaceTeams] = useState<Team[]>([]);
+ const [teamsLoading, setTeamsLoading] = useState(false);
+ const [teamsError, setTeamsError] = useState(false);
const [inviteOpen, setInviteOpen] = useState(false);
const [inviteEmail, setInviteEmail] = useState<string | undefined>(undefined);
const [inviteTeamId, setInviteTeamId] = useState<string | null>(null);
@@ -75,6 +77,19 @@ export default function SpaceMembersDialog({ space, open, onOpenChange }: SpaceM
setExpandedOverrides((prev) => new Map(prev).set(teamId, !isTeamExpanded(teamId)));
};
+ const loadWorkspaceTeams = useCallback(async (workspaceId: string) => {
+ setTeamsLoading(true);
+ setTeamsError(false);
+ try {
+ setWorkspaceTeams(await TeamsService.list(workspaceId));
+ } catch {
+ setWorkspaceTeams([]);
+ setTeamsError(true);
+ } finally {
+ setTeamsLoading(false);
+ }
+ }, []);
+
useEffect(() => {
if (!open) {
setInviteEmail(undefined);
@@ -88,11 +103,9 @@ export default function SpaceMembersDialog({ space, open, onOpenChange }: SpaceM
if (space.workspace_id) {
void refreshMembers(space.workspace_id).catch(() => {});
// Any workspace member may list teams; counts feed the collapsed rows.
- void TeamsService.list(space.workspace_id)
- .then(setWorkspaceTeams)
- .catch(() => setWorkspaceTeams([]));
+ void loadWorkspaceTeams(space.workspace_id);
}
- }, [open, space.workspace_id, refreshMembers]);
+ }, [open, space.workspace_id, refreshMembers, loadWorkspaceTeams]);
// How many OTHER spaces each assigned team has access to — roster edits ripple there.
const otherSpacesByTeam = useMemo(() => {
@@ -237,6 +250,26 @@ export default function SpaceMembersDialog({ space, open, onOpenChange }: SpaceM
<DialogTitle>{t("notes.spaces.teamsMembers.title", { space: space.name })}</DialogTitle>
</DialogHeader>
+ {teamsError && space.workspace_id && (
+ <div className="rounded border border-border/70 dark:border-border-subtle/50 px-3 py-2.5 flex items-center justify-between gap-2">
+ <p className="text-xs text-muted-foreground">{t("notes.spaces.teams.loadError")}</p>
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={teamsLoading}
+ onClick={() => {
+ if (space.workspace_id) {
+ void loadWorkspaceTeams(space.workspace_id);
+ }
+ }}
+ className="h-6 px-2 text-xs shrink-0"
+ >
+ {teamsLoading && <Loader2 className="mr-1.5 h-3 w-3 animate-spin" />}
+ {t("common.retry")}
+ </Button>
+ </div>
+ )}
+
{space.teams.length === 0 && (
<p className="text-xs text-muted-foreground">
{t("notes.spaces.teamsMembers.noTeams")}
diff --git a/src/components/notes/SpacesTree.tsx b/src/components/notes/SpacesTree.tsx
index 0d77ae560..8a63354ba 100644
--- a/src/components/notes/SpacesTree.tsx
+++ b/src/components/notes/SpacesTree.tsx
@@ -1337,6 +1337,7 @@ export default function SpacesTree({
};
const { dragState, noteDragHandlers, dropTargetHandlers } = useNoteDragAndDrop({
+ untitledLabel: t("notes.list.untitled"),
onMoveToTarget: commitMoveNote,
onCrossSpaceDrop: (note: DraggedNoteInfo, target, commit) => {
confirmCrossSpaceMove(note.spaceId, target.spaceId, false, commit);
diff --git a/src/components/notes/UploadAudioView.tsx b/src/components/notes/UploadAudioView.tsx
index 4db8bfcf7..52a109578 100644
--- a/src/components/notes/UploadAudioView.tsx
+++ b/src/components/notes/UploadAudioView.tsx
@@ -328,17 +328,27 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
// Uploads and URL downloads are a personal flow: scope the folder list
// (and the by-name "Videos" destination lookup) to the private space so a
// same-named team folder can never capture them.
- (async () => {
- const spaces = (await window.electronAPI.getSpaces?.()) ?? [];
- const privateSpace = spaces.find((s) => s.kind === "private");
- const f = (await window.electronAPI.getFolders?.(privateSpace?.id ?? null)) ?? [];
- setFolders(f);
- const personal = findDefaultFolder(f);
- if (personal) {
- setSelectedFolderId(String(personal.id));
- setBatchFolderId(String(personal.id));
+ let cancelled = false;
+ const loadFolders = async () => {
+ try {
+ const spaces = (await window.electronAPI.getSpaces?.()) ?? [];
+ const privateSpace = spaces.find((space) => space.kind === "private");
+ const items = (await window.electronAPI.getFolders?.(privateSpace?.id ?? null)) ?? [];
+ if (cancelled) return;
+ setFolders(items);
+ const personal = findDefaultFolder(items);
+ if (personal) {
+ setSelectedFolderId(String(personal.id));
+ setBatchFolderId(String(personal.id));
+ }
+ } catch (error) {
+ if (!cancelled) console.error("Failed to load upload folders:", error);
}
- })();
+ };
+ void loadFolders();
+ return () => {
+ cancelled = true;
+ };
}, []);
useEffect(() => {
diff --git a/src/components/notes/overview/OverviewAskSection.tsx b/src/components/notes/overview/OverviewAskSection.tsx
index 5c5614c85..41770ca32 100644
--- a/src/components/notes/overview/OverviewAskSection.tsx
+++ b/src/components/notes/overview/OverviewAskSection.tsx
@@ -1,17 +1,10 @@
-import { ChevronDown, Plus, Sparkles } from "lucide-react";
+import { Sparkles } from "lucide-react";
import { useTranslation } from "react-i18next";
-import { cn } from "../../lib/utils";
import { ChatMessages } from "../../chat/ChatMessages";
import { ChatInput } from "../../chat/ChatInput";
import type { Message, AgentState } from "../../chat/types";
-import { formatShortDate } from "../../../utils/dateFormatting";
-import {
- DropdownMenu,
- DropdownMenuTrigger,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuSeparator,
-} from "../../ui/dropdown-menu";
+import type { ContainerConversationItem } from "../../../hooks/useContainerChat";
+import { ConversationPicker } from "../ConversationPicker";
const PROMPT_CHIP_KEYS = [
"notes.overview.ask.chips.catchUp",
@@ -24,13 +17,7 @@ interface OverviewAskSectionProps {
agentState: AgentState;
onTextSubmit: (text: string) => void;
onCancel: () => void;
- conversations: Array<{
- id: number;
- title: string;
- created_at: string;
- updated_at: string;
- message_count: number;
- }>;
+ conversations: ContainerConversationItem[];
activeConversationId: number | null;
onSwitchConversation: (id: number) => void;
onNewChat: () => void;
@@ -50,49 +37,15 @@ export function OverviewAskSection({
}: OverviewAskSectionProps) {
const { t } = useTranslation();
const hasMessages = messages.length > 0;
- const activeConversation = conversations.find((c) => c.id === activeConversationId);
const conversationPicker = (conversations.length > 0 || hasMessages) && (
<div className="flex items-center px-3 pt-2">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <button
- className="inline-flex items-center gap-1 text-xs font-medium text-foreground/50 hover:text-foreground/70 hover:bg-foreground/5 rounded-md px-1.5 py-0.5 -ml-1.5 transition-colors duration-150 outline-none"
- aria-label={t("embeddedChat.conversationSelector")}
- >
- <span className="truncate max-w-40">
- {activeConversation?.title || t("embeddedChat.newChat")}
- </span>
- <ChevronDown size={10} className="shrink-0 text-foreground/30" />
- </button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start" sideOffset={4} className="min-w-44 max-w-56 p-1">
- <DropdownMenuItem onClick={onNewChat} className="text-xs gap-2 rounded-md px-2 py-1.5">
- <Plus size={10} className="text-foreground/40 shrink-0" />
- {t("embeddedChat.newChat")}
- </DropdownMenuItem>
- {conversations.length > 0 && (
- <>
- <DropdownMenuSeparator />
- {conversations.map((conv) => (
- <DropdownMenuItem
- key={conv.id}
- onClick={() => onSwitchConversation(conv.id)}
- className={cn(
- "text-xs gap-2 rounded-md px-2 py-1.5",
- conv.id === activeConversationId && "bg-foreground/4"
- )}
- >
- <span className="truncate flex-1">{conv.title}</span>
- <span className="text-[10px] text-foreground/30 shrink-0">
- {formatShortDate(conv.updated_at)}
- </span>
- </DropdownMenuItem>
- ))}
- </>
- )}
- </DropdownMenuContent>
- </DropdownMenu>
+ <ConversationPicker
+ conversations={conversations}
+ activeConversationId={activeConversationId}
+ onSwitchConversation={onSwitchConversation}
+ onNewChat={onNewChat}
+ />
</div>
);
diff --git a/src/components/notes/overview/OverviewExplainerBanner.tsx b/src/components/notes/overview/OverviewExplainerBanner.tsx
index 21a8c5a60..57be868ce 100644
--- a/src/components/notes/overview/OverviewExplainerBanner.tsx
+++ b/src/components/notes/overview/OverviewExplainerBanner.tsx
@@ -2,9 +2,10 @@ import { useState } from "react";
import { X } from "lucide-react";
import { useTranslation } from "react-i18next";
import {
- markContainerOverviewIntroSeen,
- shouldShowContainerOverviewIntro,
-} from "../../../lib/containerOverviewIntro";
+ CONTAINER_OVERVIEW_INTRO,
+ markIntroSeen,
+ shouldShowIntro,
+} from "../../../lib/versionedIntro";
interface OverviewExplainerBannerProps {
kind: "team" | "private";
@@ -12,7 +13,9 @@ interface OverviewExplainerBannerProps {
export function OverviewExplainerBanner({ kind }: OverviewExplainerBannerProps) {
const { t } = useTranslation();
- const [visible, setVisible] = useState(() => shouldShowContainerOverviewIntro(localStorage));
+ const [visible, setVisible] = useState(() =>
+ shouldShowIntro(localStorage, CONTAINER_OVERVIEW_INTRO)
+ );
if (!visible) return null;
@@ -20,7 +23,7 @@ export function OverviewExplainerBanner({ kind }: OverviewExplainerBannerProps)
<div className="relative rounded-lg bg-primary/5 dark:bg-primary/8 border border-primary/10 dark:border-primary/15 px-4 py-3">
<button
onClick={() => {
- markContainerOverviewIntroSeen(localStorage);
+ markIntroSeen(localStorage, CONTAINER_OVERVIEW_INTRO);
setVisible(false);
}}
aria-label={t("notes.overview.banner.dismiss")}
diff --git a/src/components/notes/overview/OverviewNoteList.tsx b/src/components/notes/overview/OverviewNoteList.tsx
index 5822e6fb4..cba8d4155 100644
--- a/src/components/notes/overview/OverviewNoteList.tsx
+++ b/src/components/notes/overview/OverviewNoteList.tsx
@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
import MemberAvatar from "../../MemberAvatar";
import { groupItemsByDate } from "../../../utils/dateGrouping";
import { formatRelativeTime } from "../../../utils/dateFormatting";
-import { useSpaceRoster } from "../../../hooks/useTeamRoster";
+import { useSpaceRoster } from "../../../hooks/useSpaceRoster";
import { useAuth } from "../../../hooks/useAuth";
import type { NoteItem, SpaceItem } from "../../../types/electron";
diff --git a/src/components/settings/WorkspaceBillingCard.tsx b/src/components/settings/WorkspaceBillingCard.tsx
index 5a4081630..f34de7892 100644
--- a/src/components/settings/WorkspaceBillingCard.tsx
+++ b/src/components/settings/WorkspaceBillingCard.tsx
@@ -11,19 +11,11 @@ import {
DialogTitle,
} from "../ui/dialog";
import { useToast } from "../ui/useToast";
-import { WorkspacesService } from "../../services/WorkspacesService";
+import { WorkspacesService, type SeatPreview } from "../../services/WorkspacesService";
import { useWorkspaceStore } from "../../stores/workspaceStore";
import { formatAmount } from "../../utils/formatAmount";
import type { Workspace } from "../../types/electron";
-interface SeatPreview {
- next_quantity: number;
- current_quantity: number;
- seats_used: number;
- amount_due: number;
- currency: string;
-}
-
interface Props {
workspace: Workspace;
requestedAdditionalSeats?: number;
diff --git a/src/hooks/useContainerChat.ts b/src/hooks/useContainerChat.ts
index eb36cf570..74792e2b2 100644
--- a/src/hooks/useContainerChat.ts
+++ b/src/hooks/useContainerChat.ts
@@ -16,7 +16,7 @@ interface UseContainerChatOptions {
notes: NoteItem[];
}
-interface ContainerConversationItem {
+export interface ContainerConversationItem {
id: number;
title: string;
created_at: string;
@@ -79,21 +79,26 @@ export function useContainerChat({
},
});
- const fetchConversations = useCallback(async () => {
- const list = await window.electronAPI?.getConversationsForContainer?.(space.id, folderId);
- setConversations(list ?? []);
- }, [space.id, folderId]);
+ const fetchConversations = useCallback(
+ async (isStale?: () => boolean): Promise<void> => {
+ let list: ContainerConversationItem[];
+ try {
+ list = (await window.electronAPI?.getConversationsForContainer?.(space.id, folderId)) ?? [];
+ } catch {
+ list = [];
+ }
+ if (!isStale?.()) setConversations(list);
+ },
+ [space.id, folderId]
+ );
useEffect(() => {
let stale = false;
- (async () => {
- const list = await window.electronAPI?.getConversationsForContainer?.(space.id, folderId);
- if (!stale) setConversations(list ?? []);
- })();
+ void fetchConversations(() => stale);
return () => {
stale = true;
};
- }, [space.id, folderId]);
+ }, [fetchConversations]);
const switchConversation = useCallback(
async (id: number) => {
diff --git a/src/hooks/useNoteDragAndDrop.ts b/src/hooks/useNoteDragAndDrop.ts
index 182a50ef1..3830c14c3 100644
--- a/src/hooks/useNoteDragAndDrop.ts
+++ b/src/hooks/useNoteDragAndDrop.ts
@@ -26,6 +26,7 @@ interface DragState {
}
interface UseNoteDragAndDropOptions {
+ untitledLabel: string;
onMoveToTarget: (noteId: number, target: NoteMoveTarget) => void | Promise<void>;
/** Cross-space drops change the note's audience — the caller confirms, then calls commit(). */
onCrossSpaceDrop: (note: DraggedNoteInfo, target: NoteMoveTarget, commit: () => void) => void;
@@ -50,6 +51,7 @@ function targetKey(target: NoteMoveTarget): string {
}
export function useNoteDragAndDrop({
+ untitledLabel,
onMoveToTarget,
onCrossSpaceDrop,
canCrossSpaceDrop,
@@ -90,7 +92,7 @@ export function useNoteDragAndDrop({
e.dataTransfer.setData("application/x-note-id", String(note.id));
const ghost = document.createElement("div");
- const label = note.title || "Untitled";
+ const label = note.title || untitledLabel;
ghost.textContent = label.length > 24 ? label.slice(0, 24) + "…" : label;
ghost.style.cssText = `
position: fixed; top: -200px; left: -200px;
@@ -125,7 +127,7 @@ export function useNoteDragAndDrop({
enterCounterRef.current.clear();
},
}),
- [clearHoverTimeout]
+ [clearHoverTimeout, untitledLabel]
);
const commitDrop = useCallback(
diff --git a/src/hooks/useTeamRoster.ts b/src/hooks/useSpaceRoster.ts
similarity index 100%
rename from src/hooks/useTeamRoster.ts
rename to src/hooks/useSpaceRoster.ts
diff --git a/src/hooks/useUsage.ts b/src/hooks/useUsage.ts
index 8cb592f16..6b2970e6f 100644
--- a/src/hooks/useUsage.ts
+++ b/src/hooks/useUsage.ts
@@ -68,6 +68,7 @@ interface UseUsageResult {
}
const USAGE_CACHE_TTL = CACHE_CONFIG.API_KEY_TTL; // 1 hour
+const PAID_PLANS = new Set(["pro", "business", "enterprise"]);
export function useUsage(): UseUsageResult | null {
const { isSignedIn, isLoaded } = useAuth();
@@ -104,7 +105,7 @@ export function useUsage(): UseUsageResult | null {
entitlementSources: result.entitlementSources ?? {
personal:
result.isTrial === true ||
- (["pro", "business", "enterprise"].includes(result.plan ?? "free") &&
+ (PAID_PLANS.has(result.plan ?? "free") &&
["active", "trialing"].includes(result.status ?? "active")),
workspaceIds: [],
},
@@ -266,8 +267,7 @@ export function useUsage(): UseUsageResult | null {
const isSubscribed = data?.isSubscribed ?? false;
const isPersonallySubscribed = data?.entitlementSources.personal ?? false;
const status = data?.status ?? "active";
- const isPastDue =
- ["pro", "business", "enterprise"].includes(data?.plan ?? "free") && status === "past_due";
+ const isPastDue = PAID_PLANS.has(data?.plan ?? "free") && status === "past_due";
const isOverLimit = !isSubscribed && limit > 0 && wordsUsed >= limit;
const isApproachingLimit = !isSubscribed && limit > 0 && wordsUsed >= limit * 0.8 && !isOverLimit;
diff --git a/src/lib/containerOverviewIntro.ts b/src/lib/containerOverviewIntro.ts
deleted file mode 100644
index 724438c83..000000000
--- a/src/lib/containerOverviewIntro.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-type IntroStorage = Pick<Storage, "getItem" | "setItem">;
-
-export const CONTAINER_OVERVIEW_INTRO_VERSION = 1;
-export const CONTAINER_OVERVIEW_INTRO_STORAGE_KEY = "containerOverviewIntroVersion";
-
-export function shouldShowContainerOverviewIntro(
- storage: IntroStorage,
- version: number = CONTAINER_OVERVIEW_INTRO_VERSION
-): boolean {
- const seenVersion = Number(storage.getItem(CONTAINER_OVERVIEW_INTRO_STORAGE_KEY));
- return !Number.isFinite(seenVersion) || seenVersion < version;
-}
-
-export function markContainerOverviewIntroSeen(
- storage: IntroStorage,
- version: number = CONTAINER_OVERVIEW_INTRO_VERSION
-): void {
- storage.setItem(CONTAINER_OVERVIEW_INTRO_STORAGE_KEY, String(version));
-}
diff --git a/src/lib/notesStructureIntro.ts b/src/lib/notesStructureIntro.ts
deleted file mode 100644
index a8cf21bd4..000000000
--- a/src/lib/notesStructureIntro.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-type IntroStorage = Pick<Storage, "getItem" | "setItem">;
-
-export const NOTES_STRUCTURE_INTRO_VERSION = 1;
-export const NOTES_STRUCTURE_INTRO_STORAGE_KEY = "notesStructureIntroVersion";
-
-export function shouldShowNotesStructureIntro(
- storage: IntroStorage,
- version: number = NOTES_STRUCTURE_INTRO_VERSION
-): boolean {
- const seenVersion = Number(storage.getItem(NOTES_STRUCTURE_INTRO_STORAGE_KEY));
- return !Number.isFinite(seenVersion) || seenVersion < version;
-}
-
-export function markNotesStructureIntroSeen(
- storage: IntroStorage,
- version: number = NOTES_STRUCTURE_INTRO_VERSION
-): void {
- storage.setItem(NOTES_STRUCTURE_INTRO_STORAGE_KEY, String(version));
-}
diff --git a/src/lib/versionedIntro.ts b/src/lib/versionedIntro.ts
new file mode 100644
index 000000000..3b6c14ce1
--- /dev/null
+++ b/src/lib/versionedIntro.ts
@@ -0,0 +1,33 @@
+type IntroStorage = Pick<Storage, "getItem" | "setItem">;
+
+export interface VersionedIntro {
+ storageKey: string;
+ version: number;
+}
+
+export const CONTAINER_OVERVIEW_INTRO: VersionedIntro = {
+ storageKey: "containerOverviewIntroVersion",
+ version: 1,
+};
+
+export const NOTES_STRUCTURE_INTRO: VersionedIntro = {
+ storageKey: "notesStructureIntroVersion",
+ version: 1,
+};
+
+export function shouldShowIntro(
+ storage: IntroStorage,
+ intro: VersionedIntro,
+ version: number = intro.version
+): boolean {
+ const seenVersion = Number(storage.getItem(intro.storageKey));
+ return !Number.isFinite(seenVersion) || seenVersion < version;
+}
+
+export function markIntroSeen(
+ storage: IntroStorage,
+ intro: VersionedIntro,
+ version: number = intro.version
+): void {
+ storage.setItem(intro.storageKey, String(version));
+}
diff --git a/src/services/WorkspacesService.ts b/src/services/WorkspacesService.ts
index 9ee913b5e..90be804ca 100644
--- a/src/services/WorkspacesService.ts
+++ b/src/services/WorkspacesService.ts
@@ -1,6 +1,14 @@
import { cloudGet, cloudPost, cloudPatch, cloudDelete, type DataWrap } from "./cloudApi.js";
import type { Workspace, WorkspaceMember } from "../types/electron";
+export interface SeatPreview {
+ next_quantity: number;
+ current_quantity: number;
+ seats_used: number;
+ amount_due: number;
+ currency: string;
+}
+
async function list(): Promise<Workspace[]> {
const res = await cloudGet<DataWrap<Workspace[]>>("/api/workspaces");
return res.data;
@@ -59,27 +67,13 @@ async function billingPortal(workspaceId: string): Promise<string> {
return res.data.url;
}
-async function previewSeats(
- workspaceId: string,
- additionalSeats: number
-): Promise<{
- next_quantity: number;
- current_quantity: number;
- seats_used: number;
- amount_due: number;
- currency: string;
-}> {
- const res = await cloudPost<
- DataWrap<{
- next_quantity: number;
- current_quantity: number;
- seats_used: number;
- amount_due: number;
- currency: string;
- }>
- >(`/api/workspaces/${workspaceId}/billing/preview-seats`, {
- additional_seats: additionalSeats,
- });
+async function previewSeats(workspaceId: string, additionalSeats: number): Promise<SeatPreview> {
+ const res = await cloudPost<DataWrap<SeatPreview>>(
+ `/api/workspaces/${workspaceId}/billing/preview-seats`,
+ {
+ additional_seats: additionalSeats,
+ }
+ );
return res.data;
}
diff --git a/test/helpers/containerOverviewIntro.test.js b/test/helpers/containerOverviewIntro.test.js
deleted file mode 100644
index c352f1176..000000000
--- a/test/helpers/containerOverviewIntro.test.js
+++ /dev/null
@@ -1,45 +0,0 @@
-const test = require("node:test");
-const assert = require("node:assert/strict");
-
-const load = () => import("../../src/lib/containerOverviewIntro.ts");
-
-function memoryStorage(initial = {}) {
- const values = new Map(Object.entries(initial));
- return {
- getItem: (key) => values.get(key) ?? null,
- setItem: (key, value) => values.set(key, value),
- };
-}
-
-test("container overview intro is shown until the current version is recorded", async () => {
- const {
- CONTAINER_OVERVIEW_INTRO_STORAGE_KEY,
- CONTAINER_OVERVIEW_INTRO_VERSION,
- markContainerOverviewIntroSeen,
- shouldShowContainerOverviewIntro,
- } = await load();
- const storage = memoryStorage();
-
- assert.equal(shouldShowContainerOverviewIntro(storage), true);
- markContainerOverviewIntroSeen(storage);
- assert.equal(
- storage.getItem(CONTAINER_OVERVIEW_INTRO_STORAGE_KEY),
- String(CONTAINER_OVERVIEW_INTRO_VERSION)
- );
- assert.equal(shouldShowContainerOverviewIntro(storage), false);
-});
-
-test("a version bump reopens the container overview intro", async () => {
- const { CONTAINER_OVERVIEW_INTRO_STORAGE_KEY, shouldShowContainerOverviewIntro } = await load();
- const storage = memoryStorage({ [CONTAINER_OVERVIEW_INTRO_STORAGE_KEY]: "1" });
-
- assert.equal(shouldShowContainerOverviewIntro(storage, 1), false);
- assert.equal(shouldShowContainerOverviewIntro(storage, 2), true);
-});
-
-test("malformed stored versions do not suppress the intro", async () => {
- const { CONTAINER_OVERVIEW_INTRO_STORAGE_KEY, shouldShowContainerOverviewIntro } = await load();
- const storage = memoryStorage({ [CONTAINER_OVERVIEW_INTRO_STORAGE_KEY]: "not-a-number" });
-
- assert.equal(shouldShowContainerOverviewIntro(storage), true);
-});
diff --git a/test/helpers/noteCards.test.js b/test/helpers/noteCards.test.js
index 2d31dea26..2e4e75708 100644
--- a/test/helpers/noteCards.test.js
+++ b/test/helpers/noteCards.test.js
@@ -10,9 +10,10 @@ const completed = (name, metadata, result) => ({
result,
metadata,
});
+const extractCards = (toolCalls) => extractNoteCards(toolCalls, "Note");
test("note tools with single-object metadata still produce one card each", () => {
- const cards = extractNoteCards([
+ const cards = extractCards([
completed("create_note", { id: 7, title: "Kickoff" }),
completed("get_note", { id: 9 }, 'Retrieved note: "Roadmap"'),
]);
@@ -23,7 +24,7 @@ test("note tools with single-object metadata still produce one card each", () =>
});
test("search_notes array metadata produces a card per hit, skipping null and non-numeric ids", () => {
- const cards = extractNoteCards([
+ const cards = extractCards([
completed("search_notes", [
{ id: 3, title: "Sales sync" },
{ id: null, title: "Cloud-only hit" },
@@ -38,7 +39,7 @@ test("search_notes array metadata produces a card per hit, skipping null and non
});
test("search cards dedupe against note-tool cards and each other", () => {
- const cards = extractNoteCards([
+ const cards = extractCards([
completed("update_note", { id: 3, title: "Sales sync" }),
completed("search_notes", [
{ id: 3, title: "Sales sync" },
@@ -54,7 +55,7 @@ test("search cards dedupe against note-tool cards and each other", () => {
test("search cards cap at 5 across the whole turn", () => {
const hits = Array.from({ length: 9 }, (_, i) => ({ id: i + 1, title: `Note ${i + 1}` }));
- const cards = extractNoteCards([
+ const cards = extractCards([
completed("search_notes", hits.slice(0, 4)),
completed("search_notes", hits.slice(4)),
]);
@@ -62,7 +63,7 @@ test("search cards cap at 5 across the whole turn", () => {
});
test("incomplete or unknown tools produce nothing", () => {
- const cards = extractNoteCards([
+ const cards = extractCards([
{ ...completed("search_notes", [{ id: 1, title: "x" }]), status: "executing" },
completed("copy_to_clipboard", { id: 2 }),
]);
diff --git a/test/helpers/notesStructureIntro.test.js b/test/helpers/notesStructureIntro.test.js
deleted file mode 100644
index c30ce748e..000000000
--- a/test/helpers/notesStructureIntro.test.js
+++ /dev/null
@@ -1,45 +0,0 @@
-const test = require("node:test");
-const assert = require("node:assert/strict");
-
-const load = () => import("../../src/lib/notesStructureIntro.ts");
-
-function memoryStorage(initial = {}) {
- const values = new Map(Object.entries(initial));
- return {
- getItem: (key) => values.get(key) ?? null,
- setItem: (key, value) => values.set(key, value),
- };
-}
-
-test("notes structure intro is shown until the current version is recorded", async () => {
- const {
- NOTES_STRUCTURE_INTRO_STORAGE_KEY,
- NOTES_STRUCTURE_INTRO_VERSION,
- markNotesStructureIntroSeen,
- shouldShowNotesStructureIntro,
- } = await load();
- const storage = memoryStorage();
-
- assert.equal(shouldShowNotesStructureIntro(storage), true);
- markNotesStructureIntroSeen(storage);
- assert.equal(
- storage.getItem(NOTES_STRUCTURE_INTRO_STORAGE_KEY),
- String(NOTES_STRUCTURE_INTRO_VERSION)
- );
- assert.equal(shouldShowNotesStructureIntro(storage), false);
-});
-
-test("a version bump reopens the notes structure intro", async () => {
- const { NOTES_STRUCTURE_INTRO_STORAGE_KEY, shouldShowNotesStructureIntro } = await load();
- const storage = memoryStorage({ [NOTES_STRUCTURE_INTRO_STORAGE_KEY]: "1" });
-
- assert.equal(shouldShowNotesStructureIntro(storage, 1), false);
- assert.equal(shouldShowNotesStructureIntro(storage, 2), true);
-});
-
-test("malformed stored versions do not suppress the intro", async () => {
- const { NOTES_STRUCTURE_INTRO_STORAGE_KEY, shouldShowNotesStructureIntro } = await load();
- const storage = memoryStorage({ [NOTES_STRUCTURE_INTRO_STORAGE_KEY]: "not-a-version" });
-
- assert.equal(shouldShowNotesStructureIntro(storage), true);
-});
diff --git a/test/helpers/versionedIntro.test.js b/test/helpers/versionedIntro.test.js
new file mode 100644
index 000000000..51e1aef7e
--- /dev/null
+++ b/test/helpers/versionedIntro.test.js
@@ -0,0 +1,51 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+
+const load = () => import("../../src/lib/versionedIntro.ts");
+
+function memoryStorage(initial = {}) {
+ const values = new Map(Object.entries(initial));
+ return {
+ getItem: (key) => values.get(key) ?? null,
+ setItem: (key, value) => values.set(key, value),
+ };
+}
+
+test("versioned intros are shown until their current version is recorded", async () => {
+ const { CONTAINER_OVERVIEW_INTRO, markIntroSeen, shouldShowIntro } = await load();
+ const storage = memoryStorage();
+
+ assert.equal(shouldShowIntro(storage, CONTAINER_OVERVIEW_INTRO), true);
+ markIntroSeen(storage, CONTAINER_OVERVIEW_INTRO);
+ assert.equal(
+ storage.getItem(CONTAINER_OVERVIEW_INTRO.storageKey),
+ String(CONTAINER_OVERVIEW_INTRO.version)
+ );
+ assert.equal(shouldShowIntro(storage, CONTAINER_OVERVIEW_INTRO), false);
+});
+
+test("a version bump reopens an intro", async () => {
+ const { NOTES_STRUCTURE_INTRO, shouldShowIntro } = await load();
+ const storage = memoryStorage({ [NOTES_STRUCTURE_INTRO.storageKey]: "1" });
+
+ assert.equal(shouldShowIntro(storage, NOTES_STRUCTURE_INTRO, 1), false);
+ assert.equal(shouldShowIntro(storage, NOTES_STRUCTURE_INTRO, 2), true);
+});
+
+test("malformed versions do not suppress an intro", async () => {
+ const { CONTAINER_OVERVIEW_INTRO, shouldShowIntro } = await load();
+ const storage = memoryStorage({ [CONTAINER_OVERVIEW_INTRO.storageKey]: "not-a-number" });
+
+ assert.equal(shouldShowIntro(storage, CONTAINER_OVERVIEW_INTRO), true);
+});
+
+test("intro configurations use independent storage keys", async () => {
+ const { CONTAINER_OVERVIEW_INTRO, NOTES_STRUCTURE_INTRO, markIntroSeen, shouldShowIntro } =
+ await load();
+ const storage = memoryStorage();
+
+ markIntroSeen(storage, CONTAINER_OVERVIEW_INTRO);
+
+ assert.equal(shouldShowIntro(storage, CONTAINER_OVERVIEW_INTRO), false);
+ assert.equal(shouldShowIntro(storage, NOTES_STRUCTURE_INTRO), true);
+});