Skip to content

fix(docs-panel): correct folder nesting by fixing Drizzle camelCase field access#4

Merged
TYBLHQY merged 1 commit into
masterfrom
worktree-fix-docs-panel-folder-nesting
Jul 18, 2026
Merged

fix(docs-panel): correct folder nesting by fixing Drizzle camelCase field access#4
TYBLHQY merged 1 commit into
masterfrom
worktree-fix-docs-panel-folder-nesting

Conversation

@TYBLHQY

@TYBLHQY TYBLHQY commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Problem

In the docs panel, all folders appeared at root level regardless of their parent-child relationships. Subfolders were not nested inside parent folders.

Root Cause

Drizzle ORM with better-sqlite3 returns rows with camelCase property names matching the schema definitions, not the raw SQL snake_case column names:

// schema.ts — Drizzle uses these property names when returning rows
parentId: text(parent_id),
sortOrder: integer(sort_order),

However, folder.store.ts was reading snake_case keys from the returned rows:

// ❌ folder.store.ts — always undefined, defaulting to '' → root level
parentId: f.parent_id,
sortOrder: f.sort_order,

Since f.parent_id was always undefined, every folder was treated as having no parent, so they all appeared at root level in the tree.

Fix

  • src/stores/folder.store.ts: Use f.parentId / f.sortOrder (camelCase) in both loadFolders and createFolder, with nullish coalescing defaults
  • src/types/ipc.ts: Align FolderRowIPC and DocumentIPCItem interfaces with the actual camelCase keys returned by Drizzle ORM

Verification

  • TypeScript compiles clean (npx tsc --noEmit)
  • No other snake_case field references remain in the frontend that depend on these types

🤖 Generated with Claude Code

…ield access

The folders table schema uses camelCase property names (parentId, sortOrder)
but folder.store.ts was reading snake_case keys (parent_id, sort_order) from
Drizzle ORM rows. Since Drizzle maps schema property names, not raw column
names, the snake_case lookups always returned undefined — causing every folder
to appear at root level in the tree regardless of its actual parent.

Fixes:
- folder.store.ts: use f.parentId / f.sortOrder in loadFolders and createFolder
- ipc.ts: align FolderRowIPC and DocumentIPCItem interfaces with actual camelCase
  keys returned by Drizzle ORM

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@TYBLHQY
TYBLHQY marked this pull request as ready for review July 18, 2026 22:54
@TYBLHQY
TYBLHQY merged commit 312bdf2 into master Jul 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant