Skip to content

Commit 4246ea2

Browse files
Drop shell prefix from shared stores
Renames use-shell-{command,draft,navigation}-store to use-{command,draft,navigation}-store and use-shell-store to use-app-state, along with all exported symbols (useShellFooStore → useFooStore, shellStore → appStore, etc.). The "shell" prefix was vestigial after moving these out of features/shell/.
1 parent 8eeb786 commit 4246ea2

28 files changed

Lines changed: 201 additions & 212 deletions

app/src/features/editor/extensions/link-interactions.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import {
88
import { EditorView } from "@codemirror/view";
99
import { afterEach, describe, expect, it, vi } from "vitest";
1010
import {
11-
resetShellCommandState,
12-
useShellCommandStore,
13-
} from "@/shared/stores/use-shell-command-store";
14-
import { shellStore } from "@/shared/stores/use-shell-store";
11+
resetCommandState,
12+
useCommandStore,
13+
} from "@/shared/stores/use-command-store";
14+
import { appStore } from "@/shared/stores/use-app-state";
1515
import { WikiLinkGrammar } from "@/features/editor/extensions/markdown-decorations/wikilink-syntax";
1616

1717
const { invokeMock, openUrlMock } = vi.hoisted(() => ({
@@ -69,8 +69,8 @@ async function flush() {
6969
afterEach(() => {
7070
invokeMock.mockReset();
7171
openUrlMock.mockClear();
72-
resetShellCommandState();
73-
shellStore.setState({
72+
resetCommandState();
73+
appStore.setState({
7474
draftMarkdown: "",
7575
draftNoteId: null,
7676
draftWikilinkResolutions: [],
@@ -430,7 +430,7 @@ describe("Editor link interactions", () => {
430430
});
431431

432432
it("prefers unsaved draft wikilink resolutions before backend lookup", () => {
433-
shellStore.setState({
433+
appStore.setState({
434434
draftMarkdown: "[[Target]]",
435435
draftNoteId: "note-1",
436436
draftWikilinkResolutions: [
@@ -482,9 +482,7 @@ describe("Editor link interactions", () => {
482482
title: "Target",
483483
},
484484
});
485-
expect(
486-
useShellCommandStore.getState().createNoteFromWikilinkRequest,
487-
).toEqual({
485+
expect(useCommandStore.getState().createNoteFromWikilinkRequest).toEqual({
488486
location: 0,
489487
requestId: 1,
490488
sourceNoteId: "note-1",

app/src/features/editor/extensions/markdown-decorations/builders/links.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Decoration, EditorView } from "@codemirror/view";
1010
import type { SyntaxNode, SyntaxNodeRef } from "@lezer/common";
1111

1212
import { overlapsAny } from "@/features/editor/extensions/markdown-decorations/cursor";
13-
import { useShellDraftStore } from "@/shared/stores/use-shell-draft-store";
13+
import { useDraftStore } from "@/shared/stores/use-draft-store";
1414
import { utf8ByteOffsetForText } from "@/shared/lib/wikilinks";
1515
import type {
1616
BuilderContext,
@@ -66,8 +66,7 @@ export function resolveDraftWikiLinkTarget(
6666
return null;
6767
}
6868

69-
const { draftNoteId, draftWikilinkResolutions } =
70-
useShellDraftStore.getState();
69+
const { draftNoteId, draftWikilinkResolutions } = useDraftStore.getState();
7170
if (draftNoteId !== noteId) {
7271
return null;
7372
}

app/src/features/editor/extensions/note-autocomplete.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
matchWikiLinkCompletionAtCursor,
3030
utf8ByteOffsetForText,
3131
} from "@/shared/lib/wikilinks";
32-
import { useShellDraftStore } from "@/shared/stores/use-shell-draft-store";
32+
import { useDraftStore } from "@/shared/stores/use-draft-store";
3333
import { searchNoteTitles } from "@/shared/api/invoke";
3434

3535
const TAG_COMPLETION_TEXT_RE = /^[-/\p{L}\p{N}_]*$/u;
@@ -231,15 +231,15 @@ function buildWikiLinkCompletionSource(noteId: string | null) {
231231
console.debug(
232232
"[wikilinks] autocomplete selected wikilink target",
233233
{
234-
draftNoteId: useShellDraftStore.getState().draftNoteId,
234+
draftNoteId: useDraftStore.getState().draftNoteId,
235235
occurrenceId,
236236
location,
237237
noteId,
238238
targetNoteId: result.id,
239239
title: result.title,
240240
},
241241
);
242-
useShellDraftStore
242+
useDraftStore
243243
.getState()
244244
.actions.upsertDraftWikilinkResolution(noteId, {
245245
occurrenceId,

app/src/features/editor/hooks/use-find-bar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88

99
import { type NoteEditorHandle } from "@/features/editor/note-editor";
1010
import { useCommandRequestId } from "@/shared/hooks/use-command-request";
11-
import { useShellCommandStore } from "@/shared/stores/use-shell-command-store";
11+
import { useCommandStore } from "@/shared/stores/use-command-store";
1212
import {
1313
isEditorFindShortcut,
1414
isNotesSearchShortcut,
@@ -31,7 +31,7 @@ export function useFindBar({
3131
const [findQuery, setFindQuery] = useState("");
3232
const [activeFindMatchIndex, setActiveFindMatchIndex] = useState(0);
3333
const [findScrollRevision, setFindScrollRevision] = useState(0);
34-
const editorFindRequestId = useShellCommandStore(
34+
const editorFindRequestId = useCommandStore(
3535
(state) => state.editorFindRequestId,
3636
);
3737
const findInputRef = useRef<HTMLInputElement | null>(null);

app/src/features/editor/note-editor.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ import {
8181
import { useNoteEditorSearchSync } from "@/features/editor/hooks/use-note-editor-search-sync";
8282
import { useNoteEditorToolbarActions } from "@/features/editor/hooks/use-note-editor-toolbar-actions";
8383
import { uiStore } from "@/shared/stores/use-ui-store";
84-
import { useShellNavigationStore } from "@/shared/stores/use-shell-navigation-store";
84+
import { useNavigationStore } from "@/shared/stores/use-navigation-store";
8585
import {
8686
isEditorFindShortcut,
8787
isNotesSearchShortcut,
@@ -250,7 +250,7 @@ function focusEditorPreservingScroll(view: EditorView) {
250250
const scrollContainer = findEditorScrollContainer(view);
251251
const scrollTop = scrollContainer?.scrollTop ?? 0;
252252

253-
useShellNavigationStore.getState().actions.setFocusedPane("editor");
253+
useNavigationStore.getState().actions.setFocusedPane("editor");
254254
view.focus();
255255

256256
if (scrollContainer) {
@@ -262,7 +262,7 @@ function focusEditorAtEndPreservingScroll(view: EditorView) {
262262
const scrollContainer = findEditorScrollContainer(view);
263263
const scrollTop = scrollContainer?.scrollTop ?? 0;
264264

265-
useShellNavigationStore.getState().actions.setFocusedPane("editor");
265+
useNavigationStore.getState().actions.setFocusedPane("editor");
266266
view.dispatch({
267267
selection: EditorSelection.cursor(view.state.doc.length),
268268
scrollIntoView: false,
@@ -275,7 +275,7 @@ function focusEditorAtEndPreservingScroll(view: EditorView) {
275275
}
276276

277277
function focusEditorAtStart(view: EditorView) {
278-
useShellNavigationStore.getState().actions.setFocusedPane("editor");
278+
useNavigationStore.getState().actions.setFocusedPane("editor");
279279
view.focus();
280280
view.dispatch({
281281
selection: EditorSelection.cursor(0),
@@ -305,7 +305,7 @@ function handleSpecialMouseDownSelection(view: EditorView, event: MouseEvent) {
305305
if (horizontalRuleSelection) {
306306
event.preventDefault();
307307
event.stopPropagation();
308-
useShellNavigationStore.getState().actions.setFocusedPane("editor");
308+
useNavigationStore.getState().actions.setFocusedPane("editor");
309309
view.focus();
310310
view.dispatch({ selection: horizontalRuleSelection });
311311
return true;
@@ -320,7 +320,7 @@ function handleSpecialMouseDownSelection(view: EditorView, event: MouseEvent) {
320320
if (tableBoundarySelection) {
321321
event.preventDefault();
322322
event.stopPropagation();
323-
useShellNavigationStore.getState().actions.setFocusedPane("editor");
323+
useNavigationStore.getState().actions.setFocusedPane("editor");
324324
view.focus();
325325
view.dispatch({
326326
scrollIntoView: false,
@@ -368,7 +368,7 @@ export const NoteEditor = forwardRef<NoteEditorHandle, NoteEditorProps>(
368368
const vimCompartmentRef = useRef(new Compartment());
369369
const applyingExternalChangeRef = useRef(false);
370370
const lastLoadKeyRef = useRef(loadKey);
371-
const prevPaneRef = useRef(useShellNavigationStore.getState().focusedPane);
371+
const prevPaneRef = useRef(useNavigationStore.getState().focusedPane);
372372
const initialAutoFocusRef = useRef(autoFocus);
373373
const initialOnAutoFocusHandledRef = useRef(onAutoFocusHandled);
374374
const initialMarkdownRef = useRef(markdown);
@@ -568,9 +568,7 @@ export const NoteEditor = forwardRef<NoteEditorHandle, NoteEditorProps>(
568568
if (!uiState.notesPanelVisible) {
569569
uiState.actions.toggleFocusMode();
570570
}
571-
useShellNavigationStore
572-
.getState()
573-
.actions.setFocusedPane("notes");
571+
useNavigationStore.getState().actions.setFocusedPane("notes");
574572
blurEditorView(view);
575573
return true;
576574
},
@@ -662,7 +660,7 @@ export const NoteEditor = forwardRef<NoteEditorHandle, NoteEditorProps>(
662660
);
663661

664662
syncEditorPaneFocusState(view, prevPaneRef.current);
665-
const unsubscribeShell = useShellNavigationStore.subscribe((state) => {
663+
const unsubscribeShell = useNavigationStore.subscribe((state) => {
666664
prevPaneRef.current = state.focusedPane;
667665
syncEditorPaneFocusState(view, state.focusedPane);
668666
});
@@ -755,13 +753,13 @@ export const NoteEditor = forwardRef<NoteEditorHandle, NoteEditorProps>(
755753
});
756754

757755
if (autoFocus) {
758-
useShellNavigationStore.getState().actions.setFocusedPane("editor");
756+
useNavigationStore.getState().actions.setFocusedPane("editor");
759757
view.focus();
760758
onAutoFocusHandled?.();
761759
} else {
762760
requestAnimationFrame(() => {
763761
requestAnimationFrame(() => {
764-
if (useShellNavigationStore.getState().focusedPane !== "editor") {
762+
if (useNavigationStore.getState().focusedPane !== "editor") {
765763
blurEditorView(view);
766764
}
767765
});

app/src/features/editor/ui/editor-pane.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import {
1919
useUIActions,
2020
} from "@/shared/stores/use-ui-store";
2121
import { useCommandRequest } from "@/shared/hooks/use-command-request";
22-
import { useShellCommandStore } from "@/shared/stores/use-shell-command-store";
23-
import { useShellNavigationStore } from "@/shared/stores/use-shell-navigation-store";
22+
import { useCommandStore } from "@/shared/stores/use-command-store";
23+
import { useNavigationStore } from "@/shared/stores/use-navigation-store";
2424
import cometLogo from "@/assets/comet.svg";
2525
import { LogicalPosition } from "@tauri-apps/api/dpi";
2626
import {
@@ -128,7 +128,7 @@ export function EditorPane({
128128
const [toolbarContainer, setToolbarContainer] = useState<HTMLElement | null>(
129129
null,
130130
);
131-
const focusEditorRequest = useShellCommandStore(
131+
const focusEditorRequest = useCommandStore(
132132
(state) => state.focusEditorRequest,
133133
);
134134
const editorFontSize = useEditorFontSize();
@@ -137,7 +137,7 @@ export function EditorPane({
137137
const editorSpellCheck = useEditorSpellCheck();
138138
const editorVimMode = useEditorVimMode();
139139
const { setShowEditorToolbar: setShowToolbar } = useUIActions();
140-
const { setFocusedPane } = useShellNavigationStore((state) => state.actions);
140+
const { setFocusedPane } = useNavigationStore((state) => state.actions);
141141
const noteTitle = firstLineH1Title(markdown);
142142
const hasConflict = (noteConflict?.snapshotCount ?? 0) > 1;
143143
const viewableConflictSnapshots =

app/src/features/notes-pane/ui/note-row.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { GitMergeConflict, Pin } from "lucide-react";
44
import { motion } from "framer-motion";
55

66
import { uiStore, useSidebarVisible } from "@/shared/stores/use-ui-store";
7-
import { useShellNavigationStore } from "@/shared/stores/use-shell-navigation-store";
7+
import { useNavigationStore } from "@/shared/stores/use-navigation-store";
88
import { dispatchFocusEditor } from "@/shared/lib/pane-navigation";
99
import {
1010
type NoteListNavigationDirection,
@@ -57,7 +57,7 @@ export function NoteRow({
5757
const isActive = note.id === selectedNoteId;
5858
const cardPreview = noteCardPreview(note, searchWords);
5959
const sidebarVisible = useSidebarVisible();
60-
const { setFocusedPane } = useShellNavigationStore((state) => state.actions);
60+
const { setFocusedPane } = useNavigationStore((state) => state.actions);
6161

6262
return (
6363
<motion.div

app/src/features/notes-pane/ui/notes-pane-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Submenu,
88
} from "@tauri-apps/api/menu";
99

10-
import { useShellNavigationStore } from "@/shared/stores/use-shell-navigation-store";
10+
import { useNavigationStore } from "@/shared/stores/use-navigation-store";
1111
import {
1212
type NoteFilter,
1313
type NoteSortDirection,
@@ -123,7 +123,7 @@ export function handleNoteRowPointerDown(
123123
export function focusSelectedNoteRow(root?: ParentNode | null) {
124124
requestAnimationFrame(() => {
125125
requestAnimationFrame(() => {
126-
if (useShellNavigationStore.getState().focusedPane !== "notes") {
126+
if (useNavigationStore.getState().focusedPane !== "notes") {
127127
return;
128128
}
129129

@@ -143,7 +143,7 @@ export function focusSelectedNoteRow(root?: ParentNode | null) {
143143
export function focusNotesPaneTarget(scrollContainer: HTMLDivElement | null) {
144144
requestAnimationFrame(() => {
145145
requestAnimationFrame(() => {
146-
if (useShellNavigationStore.getState().focusedPane !== "notes") {
146+
if (useNavigationStore.getState().focusedPane !== "notes") {
147147
return;
148148
}
149149

app/src/features/notes-pane/ui/notes-pane.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import {
2626
useNoteFilter,
2727
useSearchQuery,
2828
useTagViewActive,
29-
} from "@/shared/stores/use-shell-store";
30-
import { useShellCommandStore } from "@/shared/stores/use-shell-command-store";
31-
import { useShellNavigationStore } from "@/shared/stores/use-shell-navigation-store";
29+
} from "@/shared/stores/use-app-state";
30+
import { useCommandStore } from "@/shared/stores/use-command-store";
31+
import { useNavigationStore } from "@/shared/stores/use-navigation-store";
3232
import {
3333
type NoteSortDirection,
3434
type NoteSortField,
@@ -100,14 +100,15 @@ export function NotesPane({
100100
const noteFilter = tagViewActive ? "all" : storeNoteFilter;
101101
const searchQuery = useSearchQuery();
102102
const creatingNoteId = useCreatingSelectedNoteId();
103-
const focusNotesPaneRequest = useShellCommandStore(
103+
const focusNotesPaneRequest = useCommandStore(
104104
(state) => state.focusNotesPaneRequest,
105105
);
106-
const focusNotesSearchRequestId = useShellCommandStore(
106+
const focusNotesSearchRequestId = useCommandStore(
107107
(state) => state.focusNotesSearchRequestId,
108108
);
109-
const { setFocusedPane, setSearchQuery: onChangeSearch } =
110-
useShellNavigationStore((state) => state.actions);
109+
const { setFocusedPane, setSearchQuery: onChangeSearch } = useNavigationStore(
110+
(state) => state.actions,
111+
);
111112
const { setNoteSortPrefs } = useUIActions();
112113

113114
const sortViewKey = noteFilter;

app/src/features/shell/hooks/use-draft-control.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
NoteConflictInfo,
77
WikiLinkResolutionInput,
88
} from "@/shared/api/types";
9-
import { useShellDraftStore } from "@/shared/stores/use-shell-draft-store";
9+
import { useDraftStore } from "@/shared/stores/use-draft-store";
1010
import { haveSameWikilinkResolutions } from "@/shared/lib/wikilink-resolutions";
1111

1212
export interface DraftControlDeps {
@@ -31,7 +31,7 @@ export function useDraftControl(deps: DraftControlDeps) {
3131

3232
const getCurrentDraftState = () => {
3333
const { draftMarkdown, draftNoteId, draftWikilinkResolutions } =
34-
useShellDraftStore.getState();
34+
useDraftStore.getState();
3535
if (!draftNoteId) {
3636
return null;
3737
}

0 commit comments

Comments
 (0)