Skip to content

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

fix(control-panel): show the New note button on every view (#2199)

Gabriel Stein9423e8f48d0d
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsx
index f1b5b72a4..43e5e6c3c 100644
--- a/src/components/ControlPanel.tsx
+++ b/src/components/ControlPanel.tsx
@@ -53,10 +53,12 @@ import ControlPanelTopBar from "./ControlPanelTopBar";
import { useControlPanelNavItems, type ControlPanelView } from "./controlPanelNav";
import MeetingRecordingMount from "./MeetingRecordingMount";
import MeetingRecordingPill from "./notes/MeetingRecordingPill";
+import NewNoteMenu from "./notes/NewNoteMenu";
import { getCachedPlatform } from "../utils/platform";
import { isAccessibilitySkipped } from "../utils/permissions";
import { useGpuBannerAvailability } from "../hooks/useGpuBannerAvailability";
+import { useCreateNote } from "../hooks/useCreateNote";
import {
setActiveNoteId,
setActiveFolderId,
@@ -155,7 +157,6 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro
folderId: number;
event: any;
} | null>(null);
- const [topBarActions, setTopBarActions] = useState<HTMLDivElement | null>(null);
const [gpuBannerDismissed, setGpuBannerDismissed] = useState(
() => localStorage.getItem("gpuBannerDismissedUnified") === "true"
);
@@ -196,6 +197,12 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro
} = useUpdater();
const agentAllowedByPolicy = usePolicyStore(isAgentAllowed);
+ const { createNote } = useCreateNote();
+ // The note is created before the view switches so Notes mounts with it already open.
+ const handleNewNote = useCallback(async () => {
+ await createNote();
+ setActiveView("personal-notes");
+ }, [createNote]);
const policyActionsAllowed = usePolicyStore((state) => isPolicyActionAllowed(state));
useEffect(() => {
if (!isControlPanelViewAllowed(activeView, agentAllowedByPolicy, policyActionsAllowed)) {
@@ -1047,7 +1054,12 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro
onOpenSearch={() => setShowSearch(true)}
isSidePanelLayout={isSidePanelLayout}
onExitSidePanel={handleExitSidePanel}
- actionsSlotRef={setTopBarActions}
+ actions={
+ <NewNoteMenu
+ onNewNote={handleNewNote}
+ onNewChat={agentAllowedByPolicy ? () => setActiveView("chat") : undefined}
+ />
+ }
/>
<div className="scrollbar-hidden flex-1 overflow-y-auto">
{updateRequiredByOrg && (
@@ -1204,8 +1216,6 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro
onMeetingRecordingRequestHandled={handleMeetingRecordingRequestHandled}
invitationEntry={invitationNotesEntry}
onInvitationEntryHandled={() => setInvitationNotesEntry(null)}
- topBarActions={topBarActions}
- onNewChat={agentAllowedByPolicy ? () => setActiveView("chat") : undefined}
/>
</Suspense>
)}
diff --git a/src/components/ControlPanelTopBar.tsx b/src/components/ControlPanelTopBar.tsx
index 98d8948c5..0f5c7adf9 100644
--- a/src/components/ControlPanelTopBar.tsx
+++ b/src/components/ControlPanelTopBar.tsx
@@ -24,8 +24,8 @@ interface ControlPanelTopBarProps {
/** Meeting mode or a narrow window with an open note: sidebar hidden, back button shown. */
isSidePanelLayout: boolean;
onExitSidePanel: () => void;
- /** Receives the slot, right of the search bar, that the active page portals its actions into. */
- actionsSlotRef?: React.Ref<HTMLDivElement>;
+ /** Global actions, right of the search bar; hidden with it in the side-panel layout. */
+ actions?: React.ReactNode;
}
export default function ControlPanelTopBar({
@@ -37,7 +37,7 @@ export default function ControlPanelTopBar({
onOpenSearch,
isSidePanelLayout,
onExitSidePanel,
- actionsSlotRef,
+ actions,
}: ControlPanelTopBarProps) {
const { t } = useTranslation();
// With the sidebar out of the way the container's start edge sits under the
@@ -115,15 +115,16 @@ export default function ControlPanelTopBar({
)}
<div className="col-start-3 flex items-center gap-2">
- {!isSidePanelLayout && (
+ {!isSidePanelLayout && actions && (
<div
- ref={actionsSlotRef}
data-no-window-drag=""
style={noDragStyle}
- // macOS keeps no window controls here, so page actions take the far
+ // macOS keeps no window controls here, so the actions take the far
// end; elsewhere they sit beside the search, left of the controls.
className={cn("flex items-center", platform === "darwin" && "ms-auto")}
- />
+ >
+ {actions}
+ </div>
)}
{platform !== "darwin" && (
<div data-no-window-drag="" style={noDragStyle} className="ms-auto">
diff --git a/src/components/notes/NewNoteMenu.tsx b/src/components/notes/NewNoteMenu.tsx
index c17ed013a..92426fc99 100644
--- a/src/components/notes/NewNoteMenu.tsx
+++ b/src/components/notes/NewNoteMenu.tsx
@@ -32,7 +32,7 @@ interface NewNoteMenuProps {
onNewChat?: () => void;
}
-/** The Notes topbar's split "New note" button; the chevron offers the other things to create. */
+/** The topbar's split "New note" button; the chevron offers the other things to create. */
export default function NewNoteMenu({ onNewNote, onNewChat }: NewNoteMenuProps) {
const { t } = useTranslation();
const canCreateTeamSpace = useCanCreateTeamSpace();
diff --git a/src/components/notes/PersonalNotesView.tsx b/src/components/notes/PersonalNotesView.tsx
index d133f428b..b0bf0dcbd 100644
--- a/src/components/notes/PersonalNotesView.tsx
+++ b/src/components/notes/PersonalNotesView.tsx
@@ -1,11 +1,9 @@
import { useState, useEffect, useRef, useCallback, useMemo } from "react";
-import { createPortal } from "react-dom";
import { useTranslation } from "react-i18next";
import { useShallow } from "zustand/react/shallow";
import { Plus, Sparkles } from "../icons";
import { useToast } from "../ui/useToast";
import NoteEditor from "./NoteEditor";
-import NewNoteMenu from "./NewNoteMenu";
import SpacesTree from "./SpacesTree";
import { ContainerOverview } from "./overview/ContainerOverview";
import NotesStructureIntroDialog from "./NotesStructureIntroDialog";
@@ -64,6 +62,7 @@ import {
setSessionExpectedCount,
} from "../../stores/meetingRecordingStore";
import { useNotesOnboarding } from "../../hooks/useNotesOnboarding";
+import { startRecordingForNote, useCreateNote } from "../../hooks/useCreateNote";
import { useTeamSpacesCapability } from "../../hooks/useTeamSpacesCapability";
import { useAuth } from "../../hooks/useAuth";
import { usePolicySnapshot, useTranscriptionContextAllowed } from "../../hooks/usePolicy";
@@ -127,10 +126,6 @@ interface PersonalNotesViewProps {
onMeetingRecordingRequestHandled?: () => void;
invitationEntry?: { workspaceId: string; teamIds: string[]; spaceIds: string[] } | null;
onInvitationEntryHandled?: () => void;
- /** The topbar slot the New note button portals into; null while the topbar hides it. */
- topBarActions?: HTMLElement | null;
- /** Opens a new chat in the Chat tab; omitted when policy turns the assistant off. */
- onNewChat?: () => void;
}
export default function PersonalNotesView({
@@ -139,8 +134,6 @@ export default function PersonalNotesView({
onMeetingRecordingRequestHandled,
invitationEntry,
onInvitationEntryHandled,
- topBarActions,
- onNewChat,
}: PersonalNotesViewProps) {
const isMeetingMode = useIsMeetingMode();
const isNarrowWindow = useIsNarrowWindow();
@@ -366,24 +359,7 @@ export default function PersonalNotesView({
});
}, [activeNote?.calendar_event_id]);
- const startRecordingForNote = useCallback(async (note: NoteItem | null) => {
- const seedSegments = note?.transcript ? parseTranscriptSegments(note.transcript) : [];
- await storeStartRecording({
- noteId: note?.id ?? null,
- noteTitle: note?.title ?? null,
- folderId: note?.folder_id ?? null,
- seedSegments,
- diarizationEnabled: note?.diarization_enabled == null ? null : note.diarization_enabled === 1,
- expectedCount: resolveExpectedSpeakerCount(note),
- expectedCountIsExplicit: isExplicitSpeakerCount(note?.expected_speaker_count),
- autoEndEligible: isMeetingAutoEndEligible(note),
- });
- }, []);
-
- const startRecording = useCallback(
- () => startRecordingForNote(activeNote ?? null),
- [activeNote, startRecordingForNote]
- );
+ const startRecording = useCallback(() => startRecordingForNote(activeNote ?? null), [activeNote]);
const stopRecording = useCallback(async () => {
await storeStopRecording();
@@ -519,43 +495,13 @@ export default function PersonalNotesView({
return () => flushPendingSaves("unmount");
}, [flushPendingSaves]);
- const handleNewNoteIn = useCallback(
- async (spaceId: number, folderId: number | null) => {
- const result = await window.electronAPI.saveNote(
- t("notes.list.untitledNote"),
- "",
- "personal",
- null,
- null,
- folderId,
- spaceId
- );
- if (result.success && result.note) {
- setActiveContext(result.note.space_id, result.note.folder_id);
- revealContainer(result.note.space_id, result.note.folder_id);
- setActiveNoteId(result.note.id);
- // A new note is a recording waiting to happen: start it unless one is already live.
- if (meetingRecordingAllowed && !isTranscribing) void startRecordingForNote(result.note);
- }
- },
- [t, meetingRecordingAllowed, isTranscribing, startRecordingForNote]
- );
+ const { createNote, createNoteIn } = useCreateNote();
const privateSpaceId = useMemo(
() => spaces.find((s) => s.kind === "private")?.id ?? null,
[spaces]
);
- const handleNewNoteInPrivate = useCallback(() => {
- if (privateSpaceId == null) return;
- handleNewNoteIn(privateSpaceId, null);
- }, [privateSpaceId, handleNewNoteIn]);
-
- const handleNewNote = useCallback(() => {
- if (activeContext) handleNewNoteIn(activeContext.spaceId, activeContext.folderId);
- else handleNewNoteInPrivate();
- }, [activeContext, handleNewNoteIn, handleNewNoteInPrivate]);
-
const handleNotesAdded = useCallback(async () => {
if (activeFolderId) {
await initializeNotes(null, 50, activeFolderId);
@@ -777,11 +723,6 @@ export default function PersonalNotesView({
return (
<div className="flex h-full">
- {topBarActions &&
- createPortal(
- <NewNoteMenu onNewNote={handleNewNote} onNewChat={onNewChat} />,
- topBarActions
- )}
<div
className="shrink-0 overflow-hidden transition-[width] duration-300 ease-out"
style={{ width: isSidePanelLayout ? 0 : "13rem" }}
@@ -806,7 +747,7 @@ export default function PersonalNotesView({
onDeleteNote={handleDelete}
onMoveNote={handleMoveNote}
onCreateFolderAndMove={handleCreateFolderAndMove}
- onNewNote={handleNewNoteIn}
+ onNewNote={createNoteIn}
onShowStructureIntro={() => setShowStructureIntro(true)}
/>
</div>
@@ -878,7 +819,7 @@ export default function PersonalNotesView({
space={overviewSpace}
folder={overviewFolder}
onOpenNote={setActiveNoteId}
- onNewNote={handleNewNote}
+ onNewNote={createNote}
onAddExisting={activeFolderId != null ? () => setShowAddNotesDialog(true) : undefined}
/>
) : (
@@ -989,7 +930,7 @@ export default function PersonalNotesView({
</p>
<div className="flex items-center gap-2">
<button
- onClick={handleNewNote}
+ onClick={createNote}
className="flex items-center gap-1.5 px-4 h-7 rounded-md bg-primary/8 dark:bg-primary/10 border border-primary/12 dark:border-primary/15 text-xs font-medium text-primary/70 hover:bg-primary/12 hover:text-primary hover:border-primary/20 transition-colors"
>
<Plus size={11} />
diff --git a/src/hooks/useCreateNote.ts b/src/hooks/useCreateNote.ts
new file mode 100644
index 000000000..762569d0a
--- /dev/null
+++ b/src/hooks/useCreateNote.ts
@@ -0,0 +1,67 @@
+import { useCallback } from "react";
+import { useTranslation } from "react-i18next";
+import type { NoteItem } from "../types/electron";
+import {
+ revealContainer,
+ setActiveContext,
+ setActiveNoteId,
+ useActiveContext,
+} from "../stores/noteStore";
+import { startRecording, useMeetingRecordingStore } from "../stores/meetingRecordingStore";
+import { useTranscriptionContextAllowed } from "./usePolicy";
+import { parseTranscriptSegments } from "../utils/parseTranscriptSegments";
+import { isExplicitSpeakerCount, resolveExpectedSpeakerCount } from "../utils/participants";
+import { isMeetingAutoEndEligible } from "../helpers/meetingRecordingSession";
+
+/** Start a meeting recording seeded with the note's transcript and speaker setup. */
+export function startRecordingForNote(note: NoteItem | null): Promise<boolean> {
+ return startRecording({
+ noteId: note?.id ?? null,
+ noteTitle: note?.title ?? null,
+ folderId: note?.folder_id ?? null,
+ seedSegments: note?.transcript ? parseTranscriptSegments(note.transcript) : [],
+ diarizationEnabled: note?.diarization_enabled == null ? null : note.diarization_enabled === 1,
+ expectedCount: resolveExpectedSpeakerCount(note),
+ expectedCountIsExplicit: isExplicitSpeakerCount(note?.expected_speaker_count),
+ autoEndEligible: isMeetingAutoEndEligible(note),
+ });
+}
+
+/**
+ * Creates a note, opens it, and starts recording into it. A null space resolves
+ * to the private space in the database, so this works before the Notes tree loads.
+ */
+export function useCreateNote() {
+ const { t } = useTranslation();
+ const activeContext = useActiveContext();
+ const isRecording = useMeetingRecordingStore((s) => s.isRecording);
+ const recordingAllowed = useTranscriptionContextAllowed("meeting");
+
+ const createNoteIn = useCallback(
+ async (spaceId: number | null, folderId: number | null) => {
+ const result = await window.electronAPI.saveNote(
+ t("notes.list.untitledNote"),
+ "",
+ "personal",
+ null,
+ null,
+ folderId,
+ spaceId
+ );
+ if (!result.success || !result.note) return;
+ setActiveContext(result.note.space_id, result.note.folder_id);
+ revealContainer(result.note.space_id, result.note.folder_id);
+ setActiveNoteId(result.note.id);
+ // A new note is a recording waiting to happen: start it unless one is already live.
+ if (recordingAllowed && !isRecording) void startRecordingForNote(result.note);
+ },
+ [t, recordingAllowed, isRecording]
+ );
+
+ const createNote = useCallback(
+ () => createNoteIn(activeContext?.spaceId ?? null, activeContext?.folderId ?? null),
+ [activeContext, createNoteIn]
+ );
+
+ return { createNote, createNoteIn };
+}