Commit Graph

6 Commits

Author SHA1 Message Date
fullex
9b9570116a refactor(db): replace libsql with better-sqlite3 + sqlite-vec (#16626) 2026-07-02 13:21:13 +08:00
SuYao
6c61f33c18 feat(data-api): per-topic virtual-root message tree (structural single-root invariant) (#15951)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: jdzhang <625013594@qq.com>
Co-authored-by: jd <59188306+zhangjiadi225@users.noreply.github.com>
Co-authored-by: fullex <106392080+0xfullex@users.noreply.github.com>
Signed-off-by: suyao <sy20010504@gmail.com>
Signed-off-by: jdzhang <625013594@qq.com>
2026-06-17 18:20:35 +08:00
SuYao
5706307451 refactor(ai-service): consolidate AI runtime to main process (#14911)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: fullex <106392080+0xfullex@users.noreply.github.com>
Signed-off-by: suyao <sy20010504@gmail.com>
2026-06-05 00:06:51 +08:00
SuYao
1ccb306b30 feat(topics): migrate ordering + pin to canonical fractional-indexing pattern (#14627)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: fullex <106392080+0xfullex@users.noreply.github.com>
2026-04-30 21:18:25 +08:00
fullex
5677ab62bd refactor(data-api): tighten R1/R3 violations in agent/topic/message data
Apply NOT NULL constraints where NULL has no domain meaning:
- agent / agentSession: description, instructions, mcps, allowedTools,
  configuration, accessiblePaths, slashCommands (session only)
- agentGlobalSkill.tags
- message.searchableText, message.siblingsGroupId
- topic.name, topic.{isNameManuallyEdited, sortOrder, isPinned, pinnedOrder}
- miniapp.sortOrder

Drop rowMapper "?? fallback" patterns; preserve genuine T|null contracts
(agentSessionMessage.agentSessionId now passes NULL through, with the Zod
entity tightened to .nullable() to match).

Migrate product-chosen DB DEFAULTs to the service layer:
- agentTask.status DB DEFAULT removed; service was already supplying 'active'
- agentGlobalSkill.isEnabled DB DEFAULT flipped from true to false to match
  SkillService.install behavior

Drop Zod .default([]) from CreateAgentSchema.accessiblePaths so the
service-layer computeWorkspacePaths() is the single runtime default source.

Update FTS5 triggers to COALESCE the group_concat result to '' so
messages with no main_text blocks don't violate the new NOT NULL on
searchable_text.

Refs: docs/references/data/best-practice-default-values-and-nullability.md
2026-04-29 08:35:46 -07:00
fullex
8c83072887 feat(test-infra): introduce setupTestDatabase harness
Adds a unified, file-backed SQLite test harness under tests/helpers/db/
that provisions a real database per test file using the production
migrations + CUSTOM_SQL_STATEMENTS, wires it through
MockMainDbServiceUtils.setDb() so production code reaches it via
application.get('DbService').getDb() transparently, truncates user
tables on beforeEach, and cleans up on afterAll. Replaces the need for
hand-written CREATE TABLE SQL and inline vi.mock('@application')
overrides in consumer tests.

Companion changes:

- Register @test-helpers/* path alias (electron.vite.config.ts,
  tsconfig.node.json paths + include, vitest.config.ts main project
  include).
- Relax the global vi.mock stubs for node:fs, node:os, node:path in
  tests/main.setup.ts so third-party libraries (drizzle-orm migrator
  etc.) can read real files. The six existing tests that depended on
  the previous fully-stubbed modules now declare a local
  vi.mock('node:fs', ...) via the new createNodeFsMock helper at
  tests/helpers/mocks/nodeFsMock.ts.
- Self-tests under tests/helpers/db/__tests__/testDatabase.test.ts
  cover PRAGMA state, truncate semantics, FTS5 trigger cascades,
  NULL-searchableText handling, application-mock routing, and
  replay-array accumulation guards.
2026-04-15 09:33:37 -07:00