Skip to content

Fix dossier quick notes persistence and test stubs#2

Open
HomenShum wants to merge 104 commits intomainfrom
codex/fix-dossier-view-content-overwriting-issue
Open

Fix dossier quick notes persistence and test stubs#2
HomenShum wants to merge 104 commits intomainfrom
codex/fix-dossier-view-content-overwriting-issue

Conversation

@HomenShum
Copy link
Owner

Summary

  • prevent ProseMirror snapshots from overwriting dossier content and validate quick note creation permissions
  • request quick note documents from the dossier viewer via mutation and ensure they exist before mounting the editor
  • stub BlockNote dependencies in Vitest so UnifiedEditor can be mocked during tests

Testing

  • npm run test:run

https://chatgpt.com/codex/tasks/task_e_68f41cb377148324b5b6f12f0e1a68d4

HomenShum and others added 30 commits September 17, 2025 03:33
docs(README): replace top link with clickable demo thumbnail
…Fixed drag and drop - changed the window-level onDrop handler in DocumentsHomeHub to:

preventDefault only (to avoid accidental browser navigation)
not call stopPropagation (so drop reaches Dropzone roots)
not manually forward files to onDrop (let the local dropzones handle the event)
“Find documents about nodebench” → should do local doc search, not web.
“Search the web for nodebench benchmarks” → should take web.search path.
“Create a doc about nodebench improvements” → should classify to doc.create.
“Insert an outline into the current doc” → should classify to doc.edit if a doc is selected.
…and kind cycling; auto-generate on analyze\n\n- Header: move tags UI here; replace input/select with ghost add pill; click pill text to rename; click left strip to change kind; remove tag via \n- Backend (Convex): add updateTagKind and removeTagFromDocument; canonicalize kinds; wire actions\n- FileViewer: dispatch nodebench:generateTags after analysis\n- Docs: add CHANGELOG.md (2025-09-17) with screenshots; README now shows short preview and links to CHANGELOG\n
… (event conflict, streaming awaits, tool schema, plan step kind)
…mponents/views; remove old top-level viewer components; update layout/navigation and MiniEditorPopover; update Convex file/document APIs; chore: package.json
…resetChip; right-align hero date; remove top gap in Calendar hub; apply PageHeroHeader to PublicDocuments
…shot; center Tasks prompt; Final Output copy/collapse; run history; timeline freeze; no-op on missing task metrics
…p walkthrough to README; reflect in CHANGELOG (2025-09-23)
… README; tidy preview timeline; update 2025-09-23 CHANGELOG with tests and docs notes
Place Timeline in its own card at the top; keep Final Output below; render Run History below Final Output regardless of editor presence. Also fix Save-as-Final click handler to be void-returning. Update DESIGN_SPECS/FOLDER_STRUCTURES.
- In Fit mode, compute [start,end] tightly around tasks with symmetric pad; only include now when tasks are running.
- Use >=1s pad min.
- Fix useMemo deps to use wm.
- No UI changes.
…oad-driven code.exec\n\nchore(promptPlan): enforce channel wiring and add payload examples for web.fetch/code.exec\n\nrefactor: align Gemini generateContent call shape with repo usage
- Add validation to detect unresolved template syntax ( or {{channel:...}})
- Provide clear error messages when upstream nodes haven't completed
- Add maxBytes parameter with 1MB default limit
- Improve trace logging for local/static/remote fetches
- Prevent ENOENT errors from attempting to open template strings as file paths

chore: remove non-essential refactoring summary .md files
chore: update .gitignore to exclude temporary summary files
- Replaced 092325  v0.5.0
- Replaced v2025.09.19  v0.6.0
- Replaced v2025.09.19-2  v0.7.0
- Added v0.8.0 for timeline improvements
- All tags now follow v0.x.x semantic versioning
…y\n\n- v0.5.0 Initial multi-agent (2025-09-19) [05e5a95]\n- v0.6.0  Timeline upgrades (2025-09-19-2) [b55a950]\n- v0.7.0  Early prototype (092325) [dc817ec]
ci: add tag chronology validation workflow
chore: add scripts/release.js to auto-generate notes and tag consistently
Major Features:
- Multi-agent workflows with web search, image collection, parallel visual LLM analysis
- Code execution support (Google Genai/GPT-5-mini) with Plotly visualizations
- Cross-model comparison and conversational follow-up
- Analytics tracking (convex/analytics.ts)

Agent Improvements:
- Enhanced planner with better tool orchestration (agents/core/plan.ts)
- Improved OpenAI tool integration with structured outputs (agents/tools/openai.ts)
- Linkup search with image collection support (agents/tools/search.ts)
- Structured output validation and schema handling (agents/tools/structured.ts)
- New multimodal GLM demo scenario (task_spec_multimodal_glm.json)

UI/UX Updates:
- Unified layout with Documents/Calendar/Agents hubs (MainLayout.tsx)
- Enhanced Agent Dashboard with real-time progress tracking
- Improved Timeline/Gantt visualization with execution metrics
- Updated Calendar and Documents home hubs with better navigation
- Refined PageHeroHeader and TopDividerBar components
- Timeline Roadmap view enhancements

Backend Updates:
- Convex RAG improvements with better context handling
- Updated agent prompt planning (convex/agents/promptPlan.ts)
- Analytics integration for usage tracking

Documentation:
- Updated README with multi-agent capabilities and Grok 4 Fast default
- Enhanced DESIGN_SPECS and FOLDER_STRUCTURES
- Updated agents/README with new scenarios
- Added .gitignore rules to exclude unnecessary docs and temp files
…Add src/components/AIChatPanel/index.ts barrel export\n- Ensure tests can import AIChatPanel via Vite alias\n\nContext: continuing test stabilization work (FastAgentPanel streaming fix, helper updates, agent dashboard/timeline, trip-planning graph).
HomenShum and others added 26 commits October 16, 2025 15:04
…ling

Changes:
1. StepTimeline.tsx
   - Added 'args' field to TimelineStep interface
   - Store tool arguments separately from description
   - Pass actual args to popover (not description string)
   - Enables proper Arguments tab display in popover

2. FastAgentPanel.UIMessageBubble.tsx
   - Removed media extraction from final answer text
   - Media is displayed in tool results via ToolResultPopover
   - Simplified final answer rendering
   - Removed unused imports

Benefits:
- Tool arguments now display correctly in popover Arguments tab
- Cleaner separation of concerns (media in tool results, not final answer)
- Reduced complexity in final answer rendering
- Better data flow from tool execution to popover display
Changes:
1. ToolResultPopover.tsx
   - Add null/undefined checks for cleanedResult
   - Show 'No result available' message when result is empty
   - Only show Output section when result has content
   - Better UX for tools that are still executing or returned no data

2. StepTimeline.tsx
   - Try both 'result' and 'output' fields from ToolUIPart
   - Add debug logging for undefined results
   - Help diagnose AI SDK v5 data structure

Benefits:
- No more empty <pre> tags in popover
- Clear message when tool has no result
- Better debugging for data structure issues
…ion from tool results

FIXES:
1. SEC Filing Search Error - Added content-type validation and try-catch for JSON parsing
   - Prevents 'Unexpected token <' errors when SEC API returns HTML
   - Applied to searchSecFilings() and getCompanyInfo() in convex/tools/secFilingTools.ts
   - Returns user-friendly error messages instead of JSON parse crashes

2. Media Not Displaying - Changed media extraction source from final text to tool results
   - Agent synthesizes new answer, losing media markers from raw tool output
   - Now extracts media from message.parts (tool-result parts) instead of visibleText
   - Supports multiple tools contributing media in single message
   - Added debug logging for troubleshooting

CHANGES:
- convex/tools/secFilingTools.ts: Added error handling (lines 125-133, 160-168, 368-376)
- src/components/FastAgentPanel/FastAgentPanel.UIMessageBubble.tsx: Changed media extraction (lines 476-511)
- Added comprehensive documentation files for debugging and reference

TESTING:
- Test SEC filing search: 'Find SEC filings for AAPL'
- Test media display: 'Find YouTube videos about machine learning'
- Check console logs for extraction counts and error messages
- Fixed Document Agent userId context (security/privacy fix)
  - Injected userId into context for all 4 delegation tools
  - Updated query validators to accept both IDs and strings
  - Files: convex/agents/specializedAgents.ts, convex/documents.ts

- Achieved 100% test pass rate
  - E2E tests: 12/12 passing
  - Quality evaluation tests: 5/5 passing
  - Critical criteria: 25/25 passing

- Fixed test timeouts
  - Global timeout: 240s
  - E2E tests: 1200s
  - Quality evaluation: 600s

- Added comprehensive test suite
  - E2E coordinator agent tests
  - LLM quality evaluation tests
  - Component tests for UI elements

- Enhanced FastAgentPanel UI
  - Added VideoCard, SourceCard, RichMediaSection components
  - Improved media extraction and rendering
  - Added CollapsibleAgentProgress component
  - Better error handling and loading states

- Documentation
  - 8 comprehensive reports (2,500+ lines)
  - All test results documented
  - Production readiness confirmed
  - Deployment checklist included

Status: Ready for production deployment
…ors for Fast Agent Panel

Major UX Enhancements:
- Agents now execute immediately with best interpretation instead of asking clarification questions
- Typing indicators display contextual intent (e.g., 'Helping you with researching Ditto.ai, Eric Liu...')
- Images and media displayed prominently in carousels without requiring clicks

Agent Improvements (convex/agents/specializedAgents.ts):
- Web Agent: Added best-effort entity resolution, multi-entity research support, increased step limit to 8
- Media Agent: Added best-effort execution, entity resolution guidelines
- SEC Agent: Implemented progressive disclosure pattern for company disambiguation
- Document Agent: Added best-effort document resolution
- All agents: Clarifications moved to END of responses instead of beginning

UI Enhancements (src/components/FastAgentPanel/):
- UIMessageStream: Added extractIntent() function with 8 intent patterns (research, search, images, videos, documents, SEC filings, news, fallback)
- Typing indicators now show 'Helping you with [intent]...' instead of generic 'Streaming...'
- Enhanced logging for media extraction and image counts
- Improved media marker removal to prevent duplicate display

Documentation:
- BEST_EFFORT_EXECUTION_GUIDE.md: Comprehensive guide on best-effort execution approach
- TYPING_INDICATOR_ENHANCEMENT.md: Intent-based typing indicator implementation guide
- COMPREHENSIVE_TEST_RESULTS_WITH_DIAGRAMS.md: Test results with visual diagrams

Benefits:
 Zero-click access to information - no clarification questions blocking progress
 Immediate value - users get actionable information in first response
 Contextual feedback - users see what agent is doing based on their query
 Rich media display - images/videos in carousels without clicks
 Progressive disclosure - findings first, clarifications last
 Confidence-based execution - >70% confidence = proceed, <70% = note

Testing:
- All existing E2E tests remain compatible
- Intent extraction supports 8 patterns with fallback
- No performance impact on message rendering
…tern

- Transform single-column layout to 65/35 split-panel design
- Left panel: Chat transcript with lightweight media reference cards
- Right panel: Dedicated media gallery with collapsible sections
- Add DossierHeader component with metadata, status, and actions
- Add DossierTranscript component for EditorJS content rendering
- Add DossierMediaGallery component with video player modal and image lightbox
- Add MediaReferenceCard component for inline media references
- Add mediaExtractor utility for extracting media from EditorJS blocks
- Implement resizable panels with double-click reset and auto-save layout
- Add media highlighting system for gallery section navigation
- Preserve existing EditorJS parsing and backend mutations
- Add --accent-primary-bg CSS variable for highlighting
…ern)

- Add toggle button to Media Gallery header matching FileViewer's Quick notes pattern
- Update left panel padding to use consistent p-4 like FileViewer
- Fix left panel overflow handling with nested overflow-y-auto container
- Add right panel header with title and collapse/expand toggle button
- Add min-h-[240px] to gallery content wrapper for consistent spacing
- Add toggleGallery function to handle panel collapse/expand state
- Import ChevronLeft and ChevronRight icons for toggle button
- Ensure right panel uses p-4 padding and overflow-auto like FileViewer
…e analysis

MAJOR CHANGES:
- Implement vertical split in right panel: Media Gallery (top) + Quick Notes (bottom)
- Add file analysis capability with customizable AI prompt (matches FileViewer pattern)
- Rename right panel to 'Research Panel' with unified header
- Add analysis button with prompt popover and 'Remember as default' option
- Implement dual panel management: horizontal (left/right) + vertical (gallery/notes)
- Add toggleRightPanel function for collapsing entire research panel
- Add toggleGallery function for collapsing media gallery within research panel
- Implement vertical layout persistence with autoSaveId='dossierViewer:v'
- Add separate resize handles for horizontal and vertical splits
- Add UnifiedEditor in quickNote mode for research notes
- Add Sparkles and Loader2 icons for analysis UI
- Improve right panel header with analysis button and collapse toggle
- Add media gallery sub-header with collapse toggle
- Add quick notes sub-header
- Maintain media highlighting system across vertical split
- Preserve all existing transcript and media extraction functionality
React hooks must be called unconditionally on every render. The early return
statements for loading and error states were happening before useMemo hooks,
causing 'Rendered fewer hooks than expected' error.

CHANGES:
- Move useMemo hooks (extractedMedia, mediaCounts) before early returns
- Move early return checks to after all hooks are called
- Use optional chaining for blocks: editorJsContent?.blocks || []
- Maintain same loading/error UI behavior
The issue was that the early return for loading state was happening before
hooks were called, causing React to complain about hook count mismatch.

CHANGES:
- Move document loading check to BEFORE parsing (early return with spinner)
- Parse content and call all hooks AFTER loading check
- Move content validation check to AFTER hooks
- Simplify blocks assignment with proper type checking
- Ensure all hooks are called unconditionally on every render

This ensures:
1. Loading state returns early (no hooks called yet)
2. All hooks are called unconditionally
3. Content validation happens after hooks
4. No duplicate rendering of content + error message
…erViewer

PROBLEM IDENTIFIED:
The previous fix still had early returns BEFORE useMemo hooks were called,
violating React's Rules of Hooks. When document was null (loading state),
we returned early and skipped useMemo calls. When document loaded, we called
useMemo for the first time, causing React to see different hook counts.

ROOT CAUSE:
- Line 124-131: Early return if !document (BEFORE useMemo hooks)
- Lines 146-147: useMemo hooks (NOT called when document is null)
- This caused 'Rendered fewer hooks than expected' error

SOLUTION:
- Move ALL parsing logic into useMemo hooks (lines 105-123)
- useMemo hooks now called UNCONDITIONALLY on every render
- Early returns moved to AFTER all hooks (lines 147-163)
- Use document?.content with optional chaining in useMemo dependencies

HOOK ORDER (ALWAYS CONSISTENT):
1. useQuery, useAction (lines 25-26)
2. useState hooks (lines 37-42, 49, 56-57)
3. useRef hooks (lines 46-48, 53-55)
4. useMemo - editorJsContent (lines 105-115)
5. useMemo - blocks (lines 117-119)
6. useMemo - extractedMedia, mediaCounts (lines 122-123)
7. THEN early returns (lines 147-163)

This ensures React sees the same number of hooks on every render.
…I analysis

LAYOUT CHANGES:
- Swap panels: Media gallery now on left (65%), research panel on right (35%)
- Add vertical split in research panel: transcript (top 50%) + quick notes (bottom 50%)
- Implement dual panel system with horizontal and vertical resizable splits
- Add UnifiedEditor in quickNote mode with autoCreateIfEmpty prop

AI ANALYSIS FEATURE:
- Add Sparkles button in research panel header to trigger analysis
- Implement multi-file selection interface with checkboxes
- Support parallel analysis of videos, images, and documents
- Add customizable analysis prompt with localStorage persistence (nb:dossierAnalysisPrompt)
- Show real-time progress indicator during parallel analysis
- Display individual file analysis results (map phase)
- TODO: Add final LLM synthesis of all results (reduce phase)

TECHNICAL IMPLEMENTATION:
- Import useAction for api.fileAnalysis.analyzeFileWithGenAI
- Add AnalysisPopover component with file selection UI
- Implement toggleNotes and toggleResearch panel controls
- Add vertical panel state management (vGroupRef, notesPanelRef)
- Use autoSaveId for both horizontal (dossierViewer:h) and vertical (dossierViewer:v) layouts
- Build selectable files list from extracted media assets
- Handle URL-based analysis for videos and documents

UI/UX ENHANCEMENTS:
- Add ChevronUp/ChevronDown icons for vertical panel toggle
- Add Loader2 spinner during analysis with progress bar
- Show file type badges (video/image/document) in selection list
- Implement Select All / Deselect All toggle
- Add Remember as default checkbox for analysis prompt
- Display analyzing count (e.g., 'Analyzing 3 of 5 files...')

PRESERVED FUNCTIONALITY:
- Keep all existing media extraction and counting logic
- Maintain media highlighting system for gallery navigation
- Preserve video player modal and image lightbox
- Keep DossierHeader with metadata and actions
- Maintain EditorJS content parsing and rendering
The left panel media gallery was not visible because the wrapper div had
overflow-hidden which prevented the DossierMediaGallery's internal
overflow-y-auto from working. Changed to flex flex-col to allow proper
content flow while maintaining height constraints.
…Research Panel and Gallery with empty transcript

- Replace early 'No content available' return with empty blocks fallback
- Ensures Media Gallery and Quick Notes still render even without transcript content
- Keeps header and layout functional across dossier types
- Remove early return on document loading to avoid hook order changes
- Use useEffect (not useMemo) for localStorage side-effect to set default prompt
- Guard document access with optional chaining in header and content parsing
- Keep layout rendering even when content is empty
…as none

- Query api.documents.getLinkedAssets(dossierId) for child media-asset documents
- Map assetMetadata to gallery assets (youtube  video, image  image, others  documents)
- Merge EditorJS-extracted media with linked assets and render combined
- Update counts, selection list, and gallery props to use merged media
- Handle paragraph blocks that include plain links or <a href> HTML
- Robust URL detection + de-duplication
- Increases coverage when non-YouTube videos/files are recorded as paragraphs
- Log total blocks and block type distribution
- Log extraction results from EditorJS blocks (videos/images/documents)
- Log extraction results from Convex linked assets
- Log final merged media counts
- Log individual media items found (sample video/image/document)
- Log paragraph URL extraction

This will help identify why gallery shows 'No media assets' despite dossier having 16 media items.
- Log document query result including content presence and length
- This will help identify if content is being saved but not retrieved
- Or if getById query is filtering out the content field
ROOT CAUSE:
- UnifiedEditor (ProseMirror) was using the same documentId as the dossier
- When ProseMirror initialized, it created an empty snapshot and overwrote the EditorJS content
- This caused the media gallery to show 'No media assets' after the first render

SOLUTION:
- Create separate 'quick-notes' document linked to the dossier via parentDossierId
- UnifiedEditor now uses the quick-notes document instead of the main dossier
- This preserves the EditorJS content in the dossier while allowing ProseMirror editing in Quick Notes

CHANGES:
- Added getOrCreateQuickNotes mutation to create/retrieve linked quick-notes document
- Updated schema to include 'quick-notes' as a valid dossierType
- DossierViewer now queries for quick-notes doc and passes its ID to UnifiedEditor
- Updated getLinkedAssets return type to include quick-notes type

This fixes the bug where media extraction worked perfectly on first render (42 items found)
but then dropped to 0 items on second render when ProseMirror overwrote the content.
- Removed all console.log statements added for debugging
- Media extraction now works silently and efficiently
- Code is cleaner and production-ready
@vercel
Copy link

vercel bot commented Oct 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
nodebench-ai Error Error Oct 19, 2025 5:32pm

💡 Enable Vercel Agent with $100 free credit for automated AI reviews

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant