Skip to content

Conversation

@yujonglee
Copy link
Contributor

No description provided.

Introduce a first-class enhanced_notes table and migrate existing enhanced_md into it so that multiple per-session summaries can be managed. Update editor/tab types to use a discriminated EditorView (raw/transcript/enhanced with enhancedNoteId) and propagate enhancedNoteId through Enhanced, EnhancedEditor, StreamingView, header, and session components so the UI targets specific enhanced notes. Add hooks (useEnhancedNotes, create/delete/rename helpers), auto-enhance flow to create and start enhancement tasks for new enhanced notes, task arg/schema changes to carry enhancedNoteId, indexing/relationships in the store, and a one-time migration to move enhanced_md into enhanced_notes.

This change was needed to support multiple, identifiable enhanced notes per session (with ordering, titles, and individual enhancement tasks) instead of a single enhanced_md blob on sessions. It also ensures UI hotkeys and tab switching work with multiple enhanced notes and preserves existing data via migration.
Simplify auto-enhance flow and remove unused UI lookup

Remove duplicated store manipulation and unused UI cell lookups by extracting enhanced note creation into useCreateEnhancedNote. Use a ref to track started tasks to prevent infinite retries and simplify effect dependencies. This reduces code duplication, removes an unnecessary position lookup in the header, and makes task startup logic more robust and easier to maintain.
Fix type errors and remove migration code

Address various TypeScript type errors surfaced by pnpm -F desktop typecheck and simplify code for this greenfield project by removing legacy data migration logic.

- Corrected runtime checks to use discriminated union shapes (e.g. currentTab.type and tab.state.editor?.type) to satisfy type narrowing and avoid TypeErrors.
- Fixed several component prop/signature mismatches (removed unused sessionId from EnhancedEditor props) and updated keys/isActive checks to use view.type.
- Cleaned up imports (removed unused useCallback import) and adjusted hook usage to provide valid IDs to hooks to prevent undefined or empty-string arguments.
- Rewrote enhanced note position calculation to count rows instead of relying on an index API that caused typing issues.
- Removed one-time migration of enhanced_md to enhanced_notes and its schema flag (enhanced_notes_migrated) because this is a greenfield project and migration is unnecessary.

These changes eliminate type errors and remove unnecessary migration logic while keeping behavior consistent for a new project.
qqwd
wip
Introduce enhanced_notes to the devtool seed data to support richer meeting/session notes in the desktop app. Added curated sample enhanced_notes JSON, a Zod schema for curated enhanced notes, loader logic to map sessions and templates to enhanced_notes entries, and included enhanced_notes in debug/random seed versions. Also implemented a shared enhanced-note builder, wiring it into builders/index and the random data generator so enhanced notes are produced for sessions (including markdown→Tiptap JSON conversion). This enables seeded enhanced note data for development and testing.
Add store lookup and archive behavior when deleting a template.
Use the main store to check for any enhanced_notes rows that
reference the template_id. If related notes are found, set the
template to archived instead of deleting it; otherwise perform the
existing delete. Ensure callbacks and dependencies are updated.

chore(imports): reorder chat imports to fix linting

Reorder imports in chat session and view files to match project
import ordering (useToolRegistry and useShell moved back into place).

chore(seed): simplify template seed data construction

Extracted the template data object into a local `data` variable and
return it to reduce repetition when seeding template entries.
Wq
Wq
@yujonglee yujonglee closed this Nov 17, 2025
@yujonglee yujonglee deleted the enhanced-notes-multiple-per-session branch November 17, 2025 04:45
@coderabbitai
Copy link

coderabbitai bot commented Nov 17, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR introduces a new enhanced notes feature to the desktop app. It refactors the editor view system to use discriminated unions with type fields, adds enhanced notes storage with Tinybase schema and CRUD hooks, updates components to reference enhanced notes by ID, and modifies the auto-enhance flow to create and track enhanced notes separately from sessions.

Changes

Cohort / File(s) Summary
Import reordering
apps/desktop/src/components/chat/session.tsx, apps/desktop/src/components/chat/view.tsx
Reordered import statements without functional changes.
Type system refactoring
apps/desktop/src/store/zustand/tabs/schema.ts
Replaced EditorView from simple string enum to discriminated union with type field; added type-guard helpers (isEnhancedView, isRawView, isTranscriptView); updated TabInput editor state type.
Tab and view logic updates
apps/desktop/src/components/main/body/sessions/floating/index.tsx, apps/desktop/src/components/main/body/sessions/index.tsx, apps/desktop/src/components/main/body/sessions/shared.tsx
Updated conditionals to use type-based discriminators instead of string comparisons; added optional chaining for editor state checks; changed default tab fallback logic to check enhanced notes.
Enhanced notes components
apps/desktop/src/components/main/body/sessions/note-input/enhanced/editor.tsx, apps/desktop/src/components/main/body/sessions/note-input/enhanced/index.tsx, apps/desktop/src/components/main/body/sessions/note-input/enhanced/streaming.tsx
Updated props and signatures to accept and propagate enhancedNoteId; changed task ID generation to use enhancedNoteId instead of sessionId.
Note input header refactoring
apps/desktop/src/components/main/body/sessions/note-input/header.tsx
Added enhancedNoteId prop to HeaderTabEnhanced; refactored regeneration logic with error handling; added CreateOtherFormatButton component for alternative format generation; updated title resolution to use UI storage.
Tab navigation updates
apps/desktop/src/components/main/body/sessions/note-input/index.tsx
Replaced string-based tab switching with type-based discriminators; reworked hotkey logic (Alt+S, Alt+M, Alt+T) with index-based navigation; updated Editor rendering to pass enhancedNoteId.
Enhanced notes hook infrastructure
apps/desktop/src/hooks/useEnhancedNotes.ts
New hook module providing CRUD operations: useCreateEnhancedNote, useDeleteEnhancedNote, useRenameEnhancedNote, useEnhancedNotes, useEnhancedNote; all scoped per session with Tinybase store integration.
Auto-enhance flow update
apps/desktop/src/hooks/useAutoEnhance.ts
Refactored to create enhanced notes via new hook; changed from immediate enhancement task to two-step process: create note, then start enhancement task with enhancedNoteId; added state tracking to prevent duplicate task starts.
Tinybase schema and relationships
apps/desktop/src/store/tinybase/schema-external.ts, apps/desktop/src/store/tinybase/main.ts
Added enhancedNoteSchema with fields (user_id, created_at, session_id, content, template_id, position, title); added enhanced_notes table; introduced enhancedNotesBySession index and enhancedNoteToSession relationship; added archived field to template schema.
AI task configuration
apps/desktop/src/store/zustand/ai-task/task-configs/enhance-transform.ts, apps/desktop/src/store/zustand/ai-task/task-configs/index.ts
Updated enhance task args to include enhancedNoteId; modified transformArgs to destructure and propagate enhancedNoteId in transformed output.
Seed data and template utilities
apps/desktop/src/devtool/seed/data/curated.json, apps/desktop/src/devtool/seed/data/schema.gen.json, apps/desktop/src/devtool/seed/data/schema.ts, apps/desktop/src/devtool/seed/data/loader.ts
Added enhanced_notes field to curated data schema and loader; created CuratedEnhancedNoteSchema with session, content, position, template, title fields; extended seed loading pipeline to populate enhanced_notes.
Enhanced note builders
apps/desktop/src/devtool/seed/shared/enhanced-note.ts, apps/desktop/src/devtool/seed/shared/builders.ts, apps/desktop/src/devtool/seed/shared/index.ts
New utility createEnhancedNote for generating enhanced note data with markdown-to-JSON conversion; added buildEnhancedNotesForSessions for bulk generation with configurable notes-per-session and template probability.
Seed version updates
apps/desktop/src/devtool/seed/versions/debug.ts, apps/desktop/src/devtool/seed/versions/random.ts
Added enhanced_notes to DEBUG_DATA and RANDOM_DATA seed objects; RANDOM_DATA uses buildEnhancedNotesForSessions with 0–3 notes per session and 30% template probability.
Template and misc updates
apps/desktop/src/devtool/seed/shared/template.ts, apps/desktop/src/devtool/seed/script.ts, apps/desktop/src/routes/app/settings/_layout.tsx
Refactored template return payload construction; removed debug console.log from seed script; added guarded delete flow to archive templates with related enhanced notes instead of deleting them.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Header as Header / Tab UI
    participant Enhanced as Enhanced Component
    participant CreateNote as useCreateEnhancedNote
    participant Task as AI Task System
    participant Store as Tinybase Store

    User->>Header: Click regenerate on enhanced note
    Header->>Header: handleRegenerateClick()
    Header->>Task: Start enhance task<br/>(with enhancedNoteId)
    Task->>Store: Execute task using<br/>enhancedNoteId
    Store->>Store: Update enhanced_notes<br/>with generated content
    Task-->>Header: Task complete
    Header->>Enhanced: Re-render with updated<br/>content from store

    User->>Header: Alt+S (cycle enhanced tabs)
    Header->>Header: Find next enhanced tab<br/>by type==='enhanced'
    Header->>Header: Switch to enhanced editor
    Enhanced->>Store: Load note by<br/>enhancedNoteId
    Store-->>Enhanced: Return content & metadata

    User->>Header: Click create other format
    Header->>Header: Show format templates<br/>in popover
    User->>Header: Select template
    Header->>CreateNote: createEnhancedNote<br/>(sessionId, templateId)
    CreateNote->>Store: Insert new enhanced_note
    Store-->>CreateNote: Return enhancedNoteId
    Header->>Header: Switch tab to new<br/>enhanced note
    Header->>Task: Start enhance task<br/>for new note
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Areas requiring extra attention:

  • Type system migration (apps/desktop/src/store/zustand/tabs/schema.ts): Discriminated union refactoring for EditorView; verify all consumers correctly check view.type instead of direct comparisons.
  • Enhanced notes creation and lifecycle (apps/desktop/src/hooks/useEnhancedNotes.ts, apps/desktop/src/hooks/useAutoEnhance.ts): New CRUD hooks and two-step enhancement process; ensure state coordination across renders and task lifecycle handling.
  • AI task integration (apps/desktop/src/store/zustand/ai-task/task-configs/, apps/desktop/src/hooks/useAutoEnhance.ts): Verify enhancedNoteId is correctly passed through task args transformation and consumed downstream; check prevent-duplicate-task logic.
  • Component tab navigation (apps/desktop/src/components/main/body/sessions/note-input/index.tsx): Hotkey refactoring to index-based filtering; ensure tab switching logic handles edge cases when tabs list is empty or filtered differently.
  • Tinybase schema and store wiring (apps/desktop/src/store/tinybase/main.ts, apps/desktop/src/store/tinybase/schema-external.ts): New enhanced_notes table, indexes, and relationships; verify relationship definitions and index keys are correct for queries and filtering.
  • Template archiving logic (apps/desktop/src/routes/app/settings/_layout.tsx): New conditional flow to archive instead of delete; ensure rollback/error handling if archive operation fails.

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enhanced-notes-multiple-per-session

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c6f2d6 and 936b4bf.

📒 Files selected for processing (29)
  • apps/desktop/src/components/chat/session.tsx (1 hunks)
  • apps/desktop/src/components/chat/view.tsx (1 hunks)
  • apps/desktop/src/components/main/body/sessions/floating/index.tsx (1 hunks)
  • apps/desktop/src/components/main/body/sessions/index.tsx (1 hunks)
  • apps/desktop/src/components/main/body/sessions/note-input/enhanced/editor.tsx (2 hunks)
  • apps/desktop/src/components/main/body/sessions/note-input/enhanced/index.tsx (2 hunks)
  • apps/desktop/src/components/main/body/sessions/note-input/enhanced/streaming.tsx (1 hunks)
  • apps/desktop/src/components/main/body/sessions/note-input/header.tsx (5 hunks)
  • apps/desktop/src/components/main/body/sessions/note-input/index.tsx (4 hunks)
  • apps/desktop/src/components/main/body/sessions/shared.tsx (1 hunks)
  • apps/desktop/src/devtool/seed/data/curated.json (1 hunks)
  • apps/desktop/src/devtool/seed/data/loader.ts (5 hunks)
  • apps/desktop/src/devtool/seed/data/schema.gen.json (2 hunks)
  • apps/desktop/src/devtool/seed/data/schema.ts (2 hunks)
  • apps/desktop/src/devtool/seed/script.ts (0 hunks)
  • apps/desktop/src/devtool/seed/shared/builders.ts (3 hunks)
  • apps/desktop/src/devtool/seed/shared/enhanced-note.ts (1 hunks)
  • apps/desktop/src/devtool/seed/shared/index.ts (1 hunks)
  • apps/desktop/src/devtool/seed/shared/template.ts (1 hunks)
  • apps/desktop/src/devtool/seed/versions/debug.ts (1 hunks)
  • apps/desktop/src/devtool/seed/versions/random.ts (4 hunks)
  • apps/desktop/src/hooks/useAutoEnhance.ts (2 hunks)
  • apps/desktop/src/hooks/useEnhancedNotes.ts (1 hunks)
  • apps/desktop/src/routes/app/settings/_layout.tsx (1 hunks)
  • apps/desktop/src/store/tinybase/main.ts (6 hunks)
  • apps/desktop/src/store/tinybase/schema-external.ts (6 hunks)
  • apps/desktop/src/store/zustand/ai-task/task-configs/enhance-transform.ts (1 hunks)
  • apps/desktop/src/store/zustand/ai-task/task-configs/index.ts (1 hunks)
  • apps/desktop/src/store/zustand/tabs/schema.ts (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

2 participants