Note for agents: each time you are asked to update the documentation, if you found a ts or tsx file not specified here, you have to add it.
Mandatory doc navigation for new chats: start with docs/START-HERE.md — it provides the full bootstrap sequence and routes to all other docs.
package.json- Scripts for dev/build/test/smoke.
- Electron entry configured via
main.
vite.config.ts- Preact plugin and Vitest config.
postcss.config.js- Tailwind PostCSS plugin.
tsconfig.electron.json- Compiles main/preload/shared contracts to
dist-electron.
- Compiles main/preload/shared contracts to
electron/main.ts- App lifecycle and BrowserWindow creation.
- Wires smoke hooks and editor context-menu helpers.
- Emits native fullscreen state changes to renderer.
- Registers IPC handlers.
electron/window-config.ts- BrowserWindow security-related defaults.
electron/main-process/context-menu.ts- Native editor context menu: flat workspace commands (toggle split, toggle fullscreen, toggle focus mode) dispatched to renderer via
WORKSPACE_CONTEXT_MENU_EVENT. - Includes the
Paste Markdownmenu entry for editable contexts; the menu dispatches{ type: 'paste-markdown' }to the renderer when selected.
- Native editor context menu: flat workspace commands (toggle split, toggle fullscreen, toggle focus mode) dispatched to renderer via
electron/main-process/smoke-hooks.ts- Startup smoke hooks.
electron/main-process/window-close.ts- Window close handler: intercepts
closeevent, checks cached dirty state, shows native save dialog, and callswin.destroy()to force close.
- Window close handler: intercepts
electron/ipc.ts- Thin IPC registration/orchestration.
electron/ipc/spellcheck.ts- Spellcheck IPC handlers: reads and applies Electron session spellchecker settings for renderer settings UI, including normalized responses used by optimistic renderer updates.
electron/ipc-runtime.ts- Active project/index runtime state + watcher lifecycle.
electron/ipc-errors.ts- Shared IPC error envelope helper.
electron/preload.cts- Typed
window.tramaApibridge. - Includes fullscreen command and fullscreen-change subscription bridge.
- Typed
electron/ipc/handlers/ping-handler.ts- Ping endpoint.
electron/ipc/handlers/project-handlers/project-open-handler.ts- Open project + scan + reconcile + watcher start.
electron/ipc/handlers/project-handlers/project-folder-dialog-handler.ts- Native folder picker endpoint.
- Enforces required project folders (
book,lore,outline) by prompting to create missing folders or reselect another directory.
electron/ipc/handlers/project-handlers/document-handlers.ts- Read/save/create/rename/delete document + create folder handlers.
electron/ipc/handlers/project-handlers/folder-handlers.ts- Folder rename handler with subtree internal-write tagging and index/tag reconcile.
electron/ipc/handlers/project-handlers/index-handler.ts- Get index handler.
electron/ipc/handlers/project-handlers/order-handlers.ts- File reorder handler (
handleReorderFiles) for drag-and-drop reorder in sidebar.
- File reorder handler (
electron/ipc/handlers/ai-handlers.ts- AI import/export handlers: preview import, execute import, and backend export formatting endpoint.
electron/ipc/handlers/book-export-handler.ts- Book export handler: validates request payload and delegates multi-format book export to service with consistent error envelopes.
electron/ipc/handlers/zulu-handlers.ts- ZuluPad import handlers: opens native file picker for
.zulufiles, previews parsed pages, and executes multi-file import with configurable tag generation.
- ZuluPad import handlers: opens native file picker for
electron/services/project-scanner.ts- Recursive markdown scan + tree data (including empty folders).
electron/services/document-repository.ts- Read/save/create/rename/delete markdown files + folder rename/create.
- Persists markdown images to project-local
res/*.pngfiles on save and resolves them back to embedded data URLs on read.
electron/services/document-image-persistence.ts- Repository helper for markdown image persistence: rewrites embedded images to
res/*.png, rehydrates local image links back to embedded PNG data URLs, and collects associated image paths for delete flows.
- Repository helper for markdown image persistence: rewrites embedded images to
electron/services/frontmatter.ts- YAML frontmatter parse/serialize.
electron/services/index-service.ts.trama.index.jsonload/save/reconcile.- Architecture:
docs/architecture/project-index-architecture.md.
electron/services/watcher-service.ts- Chokidar wrapper + internal/external write classification.
electron/services/ai-import-service.ts- Parses AI clipboard blocks, builds preview metadata, and executes multi-file import writes.
electron/services/ai-export-service.ts- Formats selected files into
=== ARCHIVO: ... ===blocks, validates relative paths against project root, and supports frontmatter include/exclude mode.
- Formats selected files into
electron/services/zulu-import-service.ts- ZuluPad import service: parses
.zuluXML content into pages, generates frontmatter with optional tags, and writes markdown files to the target folder.
- ZuluPad import service: parses
electron/services/book-export-service.ts- Book export orchestrator: scans
book/, builds ordered chapter models, sanitizes per format, dispatches renderer (md/html/docx/epub/pdf), and writes output artifact.
- Book export orchestrator: scans
electron/services/book-export-image-source-transform.ts- Shared markdown image-source rewriting helpers: converts local image references to embedded data URLs during chapter build and rewrites sources to EPUB-compatible
file://URLs when packaging.
- Shared markdown image-source rewriting helpers: converts local image references to embedded data URLs during chapter build and rewrites sources to EPUB-compatible
electron/services/book-export-order.ts- Book export ordering logic: derives base order from tree and applies per-folder
corkboardOrderfrom index with stable fallback.
- Book export ordering logic: derives base order from tree and applies per-folder
electron/services/book-export-sanitize.ts- Book export sanitize pipeline: strips frontmatter for all formats, strips HTML comments only for markdown output, and normalizes line endings/trailing whitespace.
electron/services/book-export-directives.ts- Shared directive parsing helpers for
trama:center,trama:spacer, andtrama:pagebreak, including canonical comment tokens and HTML artifact variants.
- Shared directive parsing helpers for
electron/services/book-export-pdf-fonts.ts- PDF font loading strategy: registers
@pdf-lib/fontkit, resolves Unicode-capable system serif fonts, and falls back to standard fonts.
- PDF font loading strategy: registers
electron/services/book-export-pdf-inline.ts- PDF inline text helpers: markdown inline tokenization (
**bold**/__bold__), line wrapping, and width measurement for mixed regular/bold runs.
- PDF inline text helpers: markdown inline tokenization (
electron/services/book-export-pdf-font-utils.ts- Font normalization utilities:
normalizeForFont,safeTextForFont,normalizeRunsForFonts. Shared between PDF rendering functions.
- Font normalization utilities:
electron/services/book-export-pdf-utils.ts- Core PDF writer implementation:
createPdfWriter,PdfWriterinterface,PdfLayoutState, and all drawing functions (drawRuns, drawHeading, drawPdfImage, etc.)
- Core PDF writer implementation:
electron/services/book-export-pdf-renderer.ts- Re-export barrel for PDF book rendering. Exports
PdfWriter,PdfLayoutStatetypes andrenderPdfBook,createPdfWriterfrombook-export-pdf-utils.ts. Usespdf-libwith pagination, directive-aware spacing/page breaks, wrapped inline formatting, and chapter boundary page management. - Uses Unicode-capable system serif fonts when available (fallback to standard fonts).
- Re-export barrel for PDF book rendering. Exports
docs/architecture/book-export-architecture.md- Canonical reference for the book export pipeline. Explains the file layout, PDF render pipeline, data models, directive mapping, image handling, page metrics, and test coverage.
docs/architecture/ai-import-export-architecture.md- AI import/export clipboard pipeline. Covers format grammar, import preview/execute flow, export formatting, path validation, IPC contract, and test coverage.
src/app.tsx- Top-level app composition.
src/spellcheck/use-spellcheck-settings.ts- Renderer hook for spellcheck preferences: boot-time sync against Electron session, local persistence, enable/disable, language updates, and optimistic UI updates with rollback on IPC failure.
src/features/project-editor/use-project-editor.ts- Main feature hook (state + effects + action integration).
src/features/project-editor/project-editor-view.tsx- Screen-level composition (sidebar + editor + status).
src/features/project-editor/project-editor-dialogs.tsx- Centralized overlay/dialog composition for AI import/export and markdown book export modals plus toast notifications.
src/features/project-editor/use-project-editor-ui-actions.ts- Composes UI actions.
updateEditorValue(value, pane?)supports pane-targeted updates; split-pane call sites should pass explicit pane.revertChanges(pane?)— Discards unsaved changes and reloads the file from disk. ReusesloadDocumentunder the hood.
src/features/project-editor/use-project-editor-focus-actions.ts- Fullscreen/focus-mode action hooks. When enabling focus, auto-collapses the sidebar.
src/features/project-editor/use-project-editor-file-actions.ts- Rename/delete file actions.
- For file delete, forwards the optional
deleteAssociatedImageschoice to IPC.
src/features/project-editor/project-editor-image-save.ts- Renderer-side save helper that converts any non-PNG embedded image data URLs into PNG data URLs before persistence, matching the
res/*.pngstorage contract.
- Renderer-side save helper that converts any non-PNG embedded image data URLs into PNG data URLs before persistence, matching the
src/features/project-editor/use-project-editor-folder-actions.ts- Folder rename action with dirty-subtree guard and split-layout remap before project reopen.
src/features/project-editor/project-editor-folder-logic.ts- Pure helpers for folder-prefix path remap (
isPathInsideFolder,remapFolderPrefix, layout remap).
- Pure helpers for folder-prefix path remap (
src/features/project-editor/project-editor-logic.ts- Pure workspace helpers:
deriveActivePaneDocument(active pane projection),canSelectFile,reconcileWorkspaceLayout,buildConflictCopyPath, and layout persistence.
- Pure workspace helpers:
src/features/project-editor/use-project-editor-ui-actions-helpers.ts- Helper hooks for editor view actions:
useSelectFileAction,useRevertChangesAction(callsloadDocumentwhen pane is dirty, discarding unsaved changes),useEditorViewActions,useWorkspaceLayoutActions.
- Helper hooks for editor view actions:
src/features/project-editor/use-project-editor-create-actions.ts- Create article/category actions.
src/features/project-editor/use-project-editor-sidebar-actions.ts- Sidebar UI actions. Blocks sidebar expand while focus mode is active.
src/features/project-editor/use-project-editor-layout-actions.ts- Workspace split and pane activation actions.
src/features/project-editor/use-project-editor-open-project.ts- Open-project flow and pane/layout reconciliation.
src/features/project-editor/use-project-editor-fullscreen-effect.ts- Renderer subscription to native fullscreen state changes.
src/features/project-editor/use-project-editor-shortcuts-effect.ts- Global workspace shortcuts (split/fullscreen/focus/pane switch).
src/features/project-editor/use-project-editor-close-effect.ts- Notifies dirty state to main process via
notifyCloseStateIPC and exposeswindow.__tramaSaveAllfor the close handler to invoke saves before closing.
- Notifies dirty state to main process via
src/features/project-editor/use-workspace-layout-state.ts- Persist workspace layout (
trama.workspace.layout.v1).
- Persist workspace layout (
docs/architecture/split-pane-coordination.md- Canonical reference for the split pane per-pane state model. Documents the two-layer state model (layout vs document), all 7 formal contracts, state projection map, and key implementation files.
src/features/project-editor/use-sidebar-ui-state.ts- Persist sidebar UI (
trama.sidebar.ui.v1).
- Persist sidebar UI (
src/features/project-editor/use-ai-import.ts- Renderer hook for AI import dialog state and calls to preview/execute import IPC actions.
src/features/project-editor/use-ai-export.ts- Renderer hook for AI export dialog state, IPC export call, and clipboard copy flow.
src/features/project-editor/use-book-export.ts- Renderer hook for book export dialog state: selected format, optional metadata (title/author), default output path handling, IPC export call, and success toast flow.
src/features/project-editor/use-zulu-import.ts- Renderer hook for ZuluPad import dialog state: file selection, preview, and execution via IPC.
src/features/project-editor/use-project-editor-state.ts- Core local state for the editor feature (panes, loading/saving flags, conflict state, status messages).
- Derives active editor state (
selectedPath/editorValue/isDirty) fromworkspaceLayout.activePane. - Returns 6 memoized sub-states (
documentState,paneState,layoutState,sidebarState,projectState,uiState) alongside the legacyvaluesobject for granular dependency tracking in action hooks.
src/features/project-editor/use-project-editor-sub-state-hooks.ts- Memoized sub-state builders extracted from
useProjectEditorStateto prevent false re-render cascades. - Exports
useDocumentState,usePaneState,useLayoutState,useSidebarSt,useProjectSt,useUiSt, andgetVisibleSidebarPaths.
- Memoized sub-state builders extracted from
src/features/project-editor/use-project-editor-actions.ts- Composes UI actions and core operations (load/save/open/clear) and wires them into the state.
- Receives
paneWorkspacefromuseProjectEditor.
src/features/project-editor/use-project-editor-autosave-effect.ts- Minimal Preact adapter: detects dirty → calls
paneWorkspace.scheduleAutosave, detects clean/unmount → callspaneWorkspace.cancelAutosave. Timer logic lives inPaneWorkspace.
- Minimal Preact adapter: detects dirty → calls
src/features/project-editor/pane/- Private module for pane coordination. All pane state, flush, save, and autosave access goes through this module.
pane/index.ts— barrel exportingPaneWorkspace,usePaneWorkspace, and public typespane/pane-workspace.ts— coordinator class with read methods (getPaneDocument,isPaneDirty) and write methods (savePaneIfDirty,saveAllDirtyPanes,scheduleAutosave,updatePaneContent, etc.);markPaneSavedis privatepane/use-pane-workspace.ts— factory hook that encapsulates Preact setter injection, creating aPaneWorkspaceinstance viauseMemopane/pane-save-logic.ts—executePaneSave(internal, not exported from barrel)
src/features/project-editor/use-project-editor-external-events-effect.ts- Subscribes to external file events (watcher) and handles reloads/conflicts/tree refresh.
src/features/project-editor/use-project-editor-context-menu-effect.ts- Handles workspace-level context menu commands (split/fullscreen/focus/split ratio).
src/features/project-editor/use-project-editor-fullscreen-effect.ts- Listens for native fullscreen changes and mirrors them into UI state.
src/features/project-editor/use-project-editor-shortcuts-effect.ts- Global keyboard shortcuts handling for editor workspace actions.
src/features/project-editor/use-project-editor-open-project.ts- Orchestrates opening a project: load snapshot, reconcile layout, preload inactive pane.
src/features/project-editor/use-project-editor-ui-actions.ts- High-level UI action builders used by components (pick folder, select file, save, create, rename, delete, focus/fullscreen toggles).
src/features/project-editor/use-project-editor-create-actions.ts- Helpers to create new articles and category folders in the project.
src/features/project-editor/use-project-editor-file-actions.ts- File operations (rename, delete) with status updates and project reopen flows.
src/features/project-editor/use-project-editor-conflict-actions.ts- Actions to resolve external edit conflicts (reload, keep, save-as-copy, compare).
src/features/project-editor/use-project-editor-layout-actions.ts- Workspace layout actions (assign file to pane, toggle split, set ratio, switch active pane).
src/features/project-editor/use-project-editor-focus-actions.ts- Focus-mode controls (enable/disable, set scope: line/sentence/paragraph). Auto-collapses sidebar on focus enable.
src/features/project-editor/components/workspace-editor-panels.tsx- Single/split editor rendering and pane interactions.
- Split-pane dirty routing source of truth: each pane editor must route onChange to its own pane (
updateEditorValue(..., pane)).
src/features/project-editor/components/editor-panel.tsx- Editor panel shell, sync labels, save affordance.
src/features/project-editor/components/ai-import-dialog.tsx- Modal dialog for AI import text input, mode selector (
replace/append), preview trigger, and import confirmation.
- Modal dialog for AI import text input, mode selector (
src/features/project-editor/components/ai-import-preview-section.tsx- Preview summary/list for parsed import files (new vs existing).
src/features/project-editor/components/ai-export-dialog.tsx- Export dialog controller (portal, close behavior, keyboard handling) wired to export hook actions.
src/features/project-editor/components/ai-export-dialog-body.tsx- Export dialog UI body with multi-select file list, include-frontmatter option, and export/cancel actions.
src/features/project-editor/components/book-export-dialog.tsx- Markdown book export modal controller (portal, close behavior, keyboard handling).
src/features/project-editor/components/book-export-dialog-body.tsx- Book export dialog body with project root display, optional metadata inputs, output path input, and export/cancel actions.
src/features/project-editor/components/zulu-import-dialog.tsx- Modal dialog for ZuluPad file import: file selection trigger, target folder input, tag mode selector, preview state, and import execution portal.
src/features/project-editor/components/zulu-import-dialog-body.tsx- ZuluPad import dialog body: file info display, folder/tag configuration form, actions row, and preview/execute sub-components.
src/features/project-editor/components/rich-markdown-editor.tsx- Quill-based rich Markdown editor component (lifecycle, toolbar integration, focus-mode hookup).
src/features/project-editor/components/rich-markdown-editor-core.ts- Core editor lifecycle and sync logic (initialize Quill, apply markdown, enable/disable, register typography handlers).
- Also listens for workspace
paste-markdowncommands and handles reading/parsing clipboard Markdown and inserting HTML into Quill.
src/features/project-editor/components/rich-markdown-editor-external-sync.ts- External-value sync hook: compares canonical values via
normalizeEditorDocumentValue+areEquivalentEditorValues, preserves Quill selection, managesisApplyingExternalValueRefflag.
- External-value sync hook: compares canonical values via
src/features/project-editor/components/rich-markdown-editor-serialization.ts- Editor debounced serialization session: registers text-change listener, manages debounce timer and flush lifecycle, and hydrates image placeholders before forwarding to parent state via
onChange.
- Editor debounced serialization session: registers text-change listener, manages debounce timer and flush lifecycle, and hydrates image placeholders before forwarding to parent state via
src/features/project-editor/components/rich-markdown-editor-value-sync.ts- Canonical editor-value helpers: normalize image-bearing markdown into placeholder form and compare equivalent external/editor values without triggering destructive re-renders.
src/features/project-editor/components/rich-markdown-editor-layout-blots.ts- Registers Quill
BlockEmbed-based layout directive blots (center,spacer,pagebreak, unknown) so directive objects survive Quill canonicalization.
- Registers Quill
src/features/project-editor/components/rich-markdown-editor-layout-clipboard.ts- Adds clipboard matcher logic that maps directive artifact nodes into embed Delta ops consumed by layout directive blots.
src/features/project-editor/components/rich-markdown-editor-layout-keyboard.ts- Registers explicit ArrowLeft/ArrowRight keyboard bindings so pagebreak embeds are traversed atomically in one cursor step.
src/features/project-editor/components/rich-markdown-editor-layout-actions.ts- Toolbar-triggered insertion helpers for center boundaries, spacer directives, and pagebreak directives.
src/features/project-editor/components/rich-markdown-editor-layout-centering.ts- Synchronizes centered styling for editor blocks located between
center:startandcenter:endboundary artifacts.
- Synchronizes centered styling for editor blocks located between
src/features/project-editor/components/rich-markdown-editor-commands.ts- Handles workspace context-menu commands (
paste-markdown,copy-as-markdown) and clipboard serialization/paste flow for the rich editor.
- Handles workspace context-menu commands (
src/features/project-editor/components/rich-markdown-editor-find.tsx- In-document find hook: Ctrl/Cmd+F (find) and Ctrl/Cmd+H (find+replace) activation, query/match state, replace actions, and integration between floating UI and editor selection.
src/features/project-editor/components/rich-markdown-editor-find-state.ts- Shared find/replace state helpers: search state hook (
useSearchState), replace actions hook (useReplaceActions), Quill text helpers, and keyboard modifier detection.
- Shared find/replace state helpers: search state hook (
src/features/project-editor/components/rich-markdown-editor-find-overlay.tsx- Floating find bar UI (find input, replace input, counter, prev/next, replace, replace all, close, toggle-replace) plus active-match overlay rendering.
src/features/project-editor/components/rich-markdown-editor-find-visual.ts- Active-match visual sync helpers: computes Quill bounds and keeps highlighted match visible while preserving input focus.
- Includes focus-mode-aware centering via
handleFocusModeMatch().
src/features/project-editor/components/rich-markdown-editor-typography.ts- Smart typography auto-replacement on user input:
--→—,<<→«,>>→». Each substitution is isolated as its own Ctrl+Z undo entry viahistory.cutoff().
- Smart typography auto-replacement on user input:
src/features/project-editor/components/rich-markdown-editor-focus-scope.ts- Focus-mode hook orchestration: applies emphasis classes and wires scroll centering, selection tracking, and listener setup.
- Coordinates between focus scope helpers and centered scroll updates.
src/features/project-editor/components/rich-markdown-editor-focus-scope-helpers.ts- Focus scope helper functions: applies/clears CSS class emphasis, manages CSS Highlights API, handles fallback text emphasis.
- Contains
getSelectionViewportRect()for real DOM viewport geometry of the current selection.
src/features/project-editor/components/rich-markdown-editor-focus-scope-scroll.ts- Centered scroll logic: computes target scroll position to keep active line centered vertically.
- Uses requestAnimationFrame phases to recalculate after padding changes; expands top/bottom edge space dynamically.
src/features/project-editor/components/rich-markdown-editor-focus-scope-geometry.ts- Geometry helpers for focus-mode (text offset resolution, visual line/sentence boundary calculations).
src/features/project-editor/components/rich-markdown-editor-toolbar.ts- Injects and synchronizes toolbar controls (save button, revert button, sync indicator) into the Quill toolbar.
src/features/project-editor/components/sidebar/sidebar-panel.tsx- Sidebar shell/orchestrator.
src/features/project-editor/components/sidebar/sidebar-panel-body.tsx- Active section body composition. Thin adapter that converts raw sidebar callback strings through
sidebar-path-scoping.tsbefore invoking project-level actions.
- Active section body composition. Thin adapter that converts raw sidebar callback strings through
src/features/project-editor/components/sidebar/sidebar-panel-logic.ts- Section scoping + filter-state helpers. Delegates path branding/scoping to
sidebar-path-scoping.ts.
- Section scoping + filter-state helpers. Delegates path branding/scoping to
src/features/project-editor/components/sidebar/sidebar-path-scoping.ts- Canonical sidebar path-scoping module. Owns branded path types (
SectionRelativePath,ProjectRelativePath,SidebarSectionRoot) and all conversions between section-relative/project-relative paths, reorder payload scoping, and create-path building.
- Canonical sidebar path-scoping module. Owns branded path types (
src/features/project-editor/components/sidebar/sidebar-rail.tsx- Section rail and collapse toggle.
src/features/project-editor/components/sidebar/sidebar-explorer-content.tsx- Explorer container and dialog orchestration.
src/features/project-editor/components/sidebar/sidebar-explorer-body.tsx- Explorer body (path, filter, tree, state hints, menus/dialogs).
src/features/project-editor/components/sidebar/sidebar-tree.tsx- Interactive tree rows, keyboard nav, right-click file hook, and drag-and-drop reorder state. Drag handler logic lives in
use-sidebar-tree-drag-handlers.ts.
- Interactive tree rows, keyboard nav, right-click file hook, and drag-and-drop reorder state. Drag handler logic lives in
src/features/project-editor/components/sidebar/sidebar-tree-logic.ts- Pure tree build/flatten helpers.
src/features/project-editor/components/sidebar/sidebar-tree-sort.tssortTreeRowsByOrder()— reorders sidebar tree rows bycorkboardOrderfrom index. Re-exported viasidebar-tree-logic.ts.
docs/architecture/sidebar-drag-drop-architecture.md- Comprehensive reference for sidebar drag-and-drop architecture: drop position model, data flow for reorder vs move, path scoping rules, IPC contracts, component hierarchy, and Slice 1 implementation details.
src/features/project-editor/components/sidebar/sidebar-tree-row-button.tsx- Individual tree row with drag handle, drag event handlers, and drop-indicator CSS classes (
is-drop-before,is-drop-after,is-drop-onFolder).
- Individual tree row with drag handle, drag event handlers, and drop-indicator CSS classes (
src/features/project-editor/components/sidebar/drop-indicator.tsx- Drop indicator position type model (
before|after|onFolder|onSection). Visual rendering is handled by CSS classes onSidebarTreeRowButton.
- Drop indicator position type model (
src/features/project-editor/components/sidebar/use-sidebar-tree-expanded-folders.ts- Expanded folder state management, including rename remap consumption via sidebar folder-rename events.
src/features/project-editor/components/sidebar/use-sidebar-tree-drag-handlers.ts- Drag-and-drop handler logic (dragStart, dragOver, drop) and drop position calculation, extracted from
sidebar-tree.tsx.
- Drag-and-drop handler logic (dragStart, dragOver, drop) and drop position calculation, extracted from
src/features/project-editor/components/sidebar/sidebar-file-drop-logic.ts- Pure helpers for file drop handling: cross-folder move + reorder (
handleFileCrossFolderDrop) and same-folder reorder (handleFileSameFolderReorder).
- Pure helpers for file drop handling: cross-folder move + reorder (
src/features/project-editor/components/sidebar/sidebar-folder-rename-events.ts- One-shot folder rename event bridge used to remap expanded folder state after refresh.
src/features/project-editor/components/sidebar/sidebar-filter.tsx- Filter input UI.
src/features/project-editor/components/sidebar/use-sidebar-filter-shortcut.ts- Legacy sidebar filter shortcut helper (Ctrl/Cmd+F), currently not wired after in-document find shortcut reassignment.
src/features/project-editor/components/sidebar/use-sidebar-responsive-collapse.ts- Auto-collapse on narrow viewport.
src/features/project-editor/components/sidebar/sidebar-create-dialog.tsx- Create modal dialog.
src/features/project-editor/components/sidebar/use-sidebar-create-dialog.ts- Create modal state logic.
src/features/project-editor/components/sidebar/sidebar-file-context-menu.tsx- Right-click file action menu.
src/features/project-editor/components/sidebar/use-sidebar-file-context-menu.ts- Context menu state/handlers.
src/features/project-editor/components/sidebar/sidebar-folder-context-menu.tsx- Right-click folder action menu (rename in V1).
src/features/project-editor/components/sidebar/use-sidebar-folder-context-menu.ts- Folder context-menu state/handlers.
src/features/project-editor/components/sidebar/sidebar-file-actions-dialog.tsx- Rename/delete confirmation/input dialog.
- File delete dialog optionally offers deleting linked
res/*.pngimages.
src/features/project-editor/components/sidebar/use-sidebar-file-actions-dialog.ts- Rename/delete dialog state.
- Loads linked image info before file delete confirmation so the user can choose whether associated images are removed.
src/features/project-editor/components/sidebar/sidebar-folder-actions-dialog.tsx- Folder rename input dialog.
src/features/project-editor/components/sidebar/use-sidebar-folder-actions-dialog.ts- Folder rename dialog state.
src/features/project-editor/components/sidebar/sidebar-footer-actions.tsx- Create buttons (
+Article,+Category).
- Create buttons (
src/features/project-editor/components/sidebar/sidebar-settings-content.tsx- Sidebar settings panel (width slider, theme/focus controls, and spellcheck settings UI).
src/features/project-editor/components/sidebar/sidebar-settings-subcomponents.tsx- Split-out sub-components for settings: theme preference buttons, focus scope select, spellcheck language select, spellcheck controls, panel width control.
src/features/project-editor/components/sidebar/theme-setting.tsx- Theme settings section (theme preference buttons with resolved theme display).
src/features/project-editor/components/sidebar/spellcheck-setting.tsx- Spellcheck settings section (spellcheck controls wrapper).
src/features/project-editor/components/sidebar/focus-scope-setting.tsx- Focus scope settings section (focus scope select wrapper).
src/features/project-editor/components/sidebar/panel-width-setting.tsx- Panel width settings section (panel width control wrapper).
src/features/project-editor/components/sidebar/sidebar-transfer-content.tsx- Transfer section composition: separate
Project interchange(AI import/export) andBook exportblocks with format selector + export trigger.
- Transfer section composition: separate
src/shared/ipc.ts- IPC channel constants, Zod schemas, shared envelope/types.
src/shared/project-sections.ts- Single source of truth for relevant project sections (
book,outline,lore). - Exports
RELEVANT_SECTION_NAMES,RELEVANT_SECTION_ROOTSandisRelevantPath()helper.
- Single source of truth for relevant project sections (
src/shared/workspace-context-menu.ts- Event bridge contract between Electron context menu and the renderer:
WORKSPACE_CONTEXT_MENU_EVENTconstant andWorkspaceContextCommandunion type. - The
WorkspaceContextCommandincludes the{ type: 'paste-markdown' }case used by the native menu and editor listeners.
- Event bridge contract between Electron context menu and the renderer:
src/shared/markdown-layout-directives.ts- Shared parser/serializer helpers for invisible markdown layout directives (
center,spacer,pagebreak) and editor artifact mapping.
- Shared parser/serializer helpers for invisible markdown layout directives (
src/shared/markdown-layout-directives-artifact-node.ts- Artifact-node serializer for converting directive blot/artifact DOM nodes back into canonical markdown comments.
src/shared/markdown-layout-directives-spacing.ts- Markdown post-serialization normalization that converts repeated blank-line runs into canonical
trama:spacerdirectives.
- Markdown post-serialization normalization that converts repeated blank-line runs into canonical
src/shared/zulu-parser.ts.zuluXML parser: extracts page titles and content from ZuluPad document format.
src/types/trama-api.d.ts- Global declaration for
window.tramaApi.
- Global declaration for
Core and regression suites:
tests/ipc-contract.test.tstests/fullscreen-ipc.test.tstests/use-project-editor.test.tstests/workspace-layout-persistence.test.tstests/project-editor-conflict-flow.test.tstests/project-editor-logic.test.tstests/project-folder-dialog-handler.test.tstests/rich-markdown-editor.test.tstests/rich-markdown-editor-tag-overlay.test.tstests/paste-markdown.test.tstests/focus-mode-scope.test.tstests/rich-markdown-editor-focus-rendering.test.ts- CSS Highlights API priority, fallback overlay, scope change marker behavior.
tests/rich-markdown-editor-focus-split-pane.test.ts- Split pane focus regression: active/inactive pane behavior,
isActivestrict equality (=== false), CSS class application for.is-focus-mode-inactivedimming.
- Split pane focus regression: active/inactive pane behavior,
tests/sidebar-tree.test.tstests/sidebar-path-scoping-types.test.ts- Runtime smoke coverage for the new path-scoping seam plus compile-time brand assertions enforced through
tests/typescript-compile.test.ts.
- Runtime smoke coverage for the new path-scoping seam plus compile-time brand assertions enforced through
tests/sidebar-filter.test.tstests/sidebar-panels.test.tstests/spellcheck-settings.test.tstests/sidebar-scroll-regression.test.tstests/workspace-keyboard-shortcuts.test.tstests/frontmatter-parser.test.tstests/index-reconciliation.test.tstests/theme-preference.test.tstests/startup-smoke.test.tstests/electron-smoke.test.tstests/typescript-compile.test.tstests/ai-import-parser.test.ts- Parser coverage for
=== ARCHIVO: ... ===clipboard format and edge cases.
- Parser coverage for
tests/ai-export-service.test.ts- Export formatter service coverage (multi-file output, frontmatter toggle, path hardening, missing file behavior).
tests/ai-export-ipc-handler.test.ts- IPC envelope validation for export handler success/error payload paths.
tests/book-export-ipc-handler.test.ts- Book export IPC coverage: payload validation, markdown export success, phase C format exports (
html/docx/epub/pdf), and failure envelope behavior.
- Book export IPC coverage: payload validation, markdown export success, phase C format exports (
tests/book-export-order.test.ts- Book export order coverage: base tree ordering, index override, and non-book path filtering.
tests/book-export-sanitize.test.ts- Book export sanitize coverage: frontmatter/tag removal, markdown-only comment stripping, and whitespace normalization.
tests/book-export-renderers.test.ts- Renderer coverage for markdown/html/docx/epub/pdf outputs, including directive conversion and binary artifact generation.
tests/book-export-image-utils.test.ts- Image utility coverage: PNG/JPEG dimension parsing from bytes, DOCX proportional size calculation, and markdown reference-style image extraction.
tests/use-ai-export.test.ts- Renderer export hook coverage for IPC call shape, clipboard copy, and error state handling.
tests/folder-rename-repository.test.ts- Repository-level folder rename coverage (success + validation/collision failures).
tests/folder-rename-ipc-handler.test.ts- IPC folder rename envelope coverage and on-disk subtree move assertions.
tests/project-editor-folder-logic.test.ts- Pure path-remap coverage for folder rename in split-layout state.
tests/order-handlers.test.ts- IPC handler coverage for
handleReorderFiles(saves order to index, handles empty folder path, rejects no-active-project, rejects invalid payload).
- IPC handler coverage for
tests/drag-drop-sidebar.test.ts- Sidebar drag-drop logic coverage (folder vs file drop targets, before/after position reorder logic, tree row filtering).
tests/markdown-layout-directives.test.ts- Unit coverage for directive extraction, warning behavior, artifact rendering, and canonical serialization helpers.
tests/ai-import-service.test.ts- Import service coverage: replace mode overwrites existing file content, append mode appends with separator, preview correctly classifies new vs existing files.
tests/ai-import-ipc-handler.test.ts- IPC handler coverage: rejects invalid
importModewithVALIDATION_ERROR, append mode produces expected written content via IPC.
- IPC handler coverage: rejects invalid
tests/pane-workspace.test.ts- Unit tests for
PaneWorkspacecoordinator class: mutation methods (updatePaneContent,loadPaneDocument,clearPanes,updatePaneMeta), save/isDirty contracts, autosave timer lifecycle.
- Unit tests for
tests/use-pane-workspace.test.ts- Unit tests for the
usePaneWorkspacefactory hook: stable identity across re-renders, proper passing of bindings/refs/saveFn toPaneWorkspace.
- Unit tests for the
tests/use-ai-import.test.ts- Renderer import hook coverage:
importModeforwarded to preview IPC call,importModeforwarded to execute IPC call, log message format matches created/appended/replaced/skipped/errors counts.
- Renderer import hook coverage:
tests/window-close.test.ts- Regression tests for window close behavior: dirty state IPC notification,
__tramaSaveAllglobal function, parallel save of dirty panes.
- Regression tests for window close behavior: dirty state IPC notification,
tests/rich-markdown-editor-value-sync.test.ts- Unit coverage for canonical editor-value normalization and equivalence between base64 markdown images and
IMAGE_PLACEHOLDERmarkdown.
- Unit coverage for canonical editor-value normalization and equivalence between base64 markdown images and
docs/architecture/rich-editor-hotspots.md- Fast routing document for the editor's fragile seams: debounce, external sync, pane persistence, layout-vs-document state, focus geometry, and command bridge.
docs/architecture/window-close-architecture.md- Documents the window close architecture: main-process close handler, renderer dirty-state notification via IPC,
__tramaSaveAllbridge, promise-chain cancel pattern, and key files.
- Documents the window close architecture: main-process close handler, renderer dirty-state notification via IPC,
docs/architecture/zulu-import-architecture.md- Canonical reference for the ZuluPad import pipeline. Explains parser logic, encoding detection, tag generation, line ending normalization, IPC contract, file map, and UI flow.
dist/-> renderer build.dist-electron/-> transpiled Electron and shared runtime files.- Required preload artifact:
dist-electron/electron/preload.cjs.