فهرست منبع

chore(tauri): cleanup exit docs, TagView LIMIT, test isolation, unused isIndexing

- lib.rs: document why exit_app uses std::process::exit(0) over Tauri APIs
- TagView.vue: add LIMIT 50 to tag query
- indexer.test.ts: add beforeEach DB cleanup between tests
- workspace.ts: remove unused isIndexing ref from reindex()
Zander Hawke 20 ساعت پیش
والد
کامیت
77fe2a40d3

+ 8 - 0
apps/tauri/src-tauri/src/lib.rs

@@ -57,6 +57,14 @@ struct FsEvent {
 }
 
 /// Exit the application process.
+///
+/// Uses `std::process::exit(0)` rather than Tauri's graceful `app.exit()` /
+/// `app.terminate()` to avoid depending on `tauri::AppHandle` in the command
+/// signature (which complicates testing). The downside is that `process::exit`
+/// bypasses `applicationWillTerminate` on macOS, so any in-flight `fs::write`
+/// or pending auto-saves are dropped. This is acceptable for a notes app since
+/// auto-save is 500ms-debounced and the write is fast; worst case, a single
+/// keystroke's worth of content is lost.
 #[tauri::command]
 fn exit_app() {
     std::process::exit(0)

+ 2 - 1
apps/tauri/src/components/TagView.vue

@@ -56,7 +56,8 @@ async function load() {
        FROM blocks b
        JOIN links l ON l.source_block_id = b.id
        WHERE l.link_type = 'tag' AND l.target = ?
-       ORDER BY b.modified_at DESC`,
+       ORDER BY b.modified_at DESC
+       LIMIT 50`,
       [props.tag],
     )
     blocks.value = rows.map((r) => ({

+ 20 - 1
apps/tauri/src/lib/indexer.test.ts

@@ -1,5 +1,13 @@
 import Database from "better-sqlite3"
-import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"
+import {
+  afterAll,
+  beforeAll,
+  beforeEach,
+  describe,
+  expect,
+  it,
+  vi,
+} from "vitest"
 
 // Mock @enesis/editor — its dependency chain pulls in Vue files that vitest
 // can't parse without a Vue plugin.
@@ -87,6 +95,11 @@ function opts(files: Record<string, string>, workspacePath = "/ws") {
 }
 
 describe("syncIndex", () => {
+  // Each test starts with a clean database so state doesn't leak between them
+  beforeEach(async () => {
+    await db.execute("DELETE FROM pages")
+  })
+
   it("indexes new files", async () => {
     const o = opts({ "pages/New.md": "# Hello World" })
     await syncIndex(o, db)
@@ -201,6 +214,12 @@ describe("fullReindex", () => {
 })
 
 describe("migrateContentHash via initIndex", () => {
+  // This is the one integration-style test in the suite: it creates a real DB
+  // file on disk with the old schema, opens it through initIndex (which runs
+  // migrateContentHash), and verifies the column was added. Writing a temp
+  // file is unavoidable because initIndex opens the DB via a path string.
+  // If the test process is killed mid-run, the temp dir leaks — acceptable
+  // for a dev-only test.
   it("adds content_hash column to existing old-schema database", async () => {
     // Build the old schema manually (without content_hash)
     const raw = new Database(":memory:")

+ 5 - 12
apps/tauri/src/stores/workspace.ts

@@ -39,7 +39,6 @@ export const useWorkspaceStore = defineStore("workspace", () => {
   const files = ref<WorkspaceFile[]>([])
   const currentFilePath = ref<string | null>(null)
   const loading = ref(false)
-  const isIndexing = ref(false)
   const db = ref<Database | null>(null)
 
   const { readFile, writeFile, listDirectory, createDirectory } =
@@ -229,16 +228,11 @@ export const useWorkspaceStore = defineStore("workspace", () => {
 
   async function reindex() {
     if (!db.value || !workspacePath.value) return
-    isIndexing.value = true
-    try {
-      await fullReindex(
-        { listDirectory, readFile, workspacePath: workspacePath.value },
-        db.value,
-      )
-      await scanFiles()
-    } finally {
-      isIndexing.value = false
-    }
+    await fullReindex(
+      { listDirectory, readFile, workspacePath: workspacePath.value },
+      db.value,
+    )
+    await scanFiles()
   }
 
   async function scanFiles() {
@@ -325,7 +319,6 @@ export const useWorkspaceStore = defineStore("workspace", () => {
     pages,
     currentFilePath,
     loading,
-    isIndexing,
     reindex,
     db,
     recentWorkspaces,

+ 6 - 0
skills-lock.json

@@ -1,6 +1,12 @@
 {
   "version": 1,
   "skills": {
+    "ngit": {
+      "source": "DanConwayDev/ngit-cli",
+      "sourceType": "github",
+      "skillPath": "skills/ngit/SKILL.md",
+      "computedHash": "fdaedb292cbfb33b6c20f6b033a5244660b7bf344bb862d583dd3338292a16b4"
+    },
     "nuxt-ui": {
       "source": "nuxt/ui",
       "sourceType": "github",