Skip to content

feat: improve diagram creation and quick views - #111

Merged
peter6055 merged 10 commits into
mainfrom
feat/issues-106-110
Jul 9, 2026
Merged

peter6055 merged 10 commits into
mainfrom
feat/issues-106-110

Conversation

@peter6055

@peter6055 peter6055 commented Jul 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Redesigns New Diagram into Templates, Start from scratch, and Other Mermaid/code-only paths
  • Adds a shared diagram catalogue for labels, capabilities, defaults, templates, and code-only Mermaid types
  • Treats blank diagrams as an intentional editor empty state with starter CTAs
  • Opens dashboard diagram links in new tabs using real anchors
  • Adds persisted starring for diagrams and folders plus All Files/Recent/Starred quick views
  • Refines the dashboard header/search row so search fills the content width, sort/view controls align right, and header action buttons share width
  • Adds dashboard header coverage for quick views, scoped search, keyboard search shortcuts, and narrow-screen create controls

Verification

  • npm run prepush
  • npx playwright test --config=/tmp/livemaid-playwright-existing-server.config.cjs against the existing 3434 dev server
  • Playwright layout measurements for the search row at 1600px, 1280px, 760px, and 390px

Notes

  • npm run lint reports existing warnings but no errors during prepush.
  • The default E2E config could not start 3435 while Next detected the existing workspace dev server on 3434, so the targeted dashboard spec was rerun against 3434 with a temporary config.

Closes #106
Closes #107
Closes #108
Closes #109
Closes #110

Summary by CodeRabbit

  • New Features
    • Added a blank-diagram workspace with starter actions, plus capability badges in the editor.
    • Introduced catalog-driven diagram creation and expanded diagram type detection (e.g., new prefixes and “Blank Diagram”).
    • Added starring for diagrams and folders, with dashboard Quick Views (All/Recent/Starred) and opening diagrams in a new tab.
  • Bug Fixes
    • Tightened demo-mode validation for diagram edits.
    • Improved starred/starredAt validation and normalization across diagram and folder flows.
  • Documentation
    • Updated README for starring, Quick Views, and refreshed supported diagram guidance.
  • Tests
    • Added coverage for catalog/template validation, type detection, and starred normalization.

@railway-app
railway-app Bot temporarily deployed to livemaid / livemaid-pr-111 July 8, 2026 00:13 Destroyed
@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds a shared diagram catalog, treats blank diagrams as an empty state, adds starring for diagrams and folders, and updates dashboard browsing and open behavior to use quick views and new-tab editor links.

Changes

Diagram Workflows and Dashboard Behavior

Layer / File(s) Summary
Catalog-driven creation
src/lib/diagrams/catalog.ts, src/app/api/diagrams/route.ts, src/components/Dashboard.tsx, src/components/DiagramCard.tsx, src/components/editor/EditorHeader.tsx, src/components/editor/LiveMaidEditor.tsx, src/test/diagram-catalog.test.ts, README.md
Adds shared catalog/template helpers, uses them in diagram creation, and updates capability display, tests, and docs to match the new create flow.
Blank diagram state
src/lib/diagrams/utils.ts, src/hooks/useEditorState.ts, src/components/editor/EditorCanvas.tsx, src/components/editor/LiveMaidEditor.tsx
Treats empty code as a blank diagram, skips Mermaid rendering for blank input, and shows a dedicated empty-state canvas with starter actions.
Diagram and folder starring
src/lib/api/storageTypes.ts, src/app/api/diagrams/[id]/route.ts, src/app/api/folders/[id]/route.ts, src/app/api/folders/route.ts, src/components/DiagramCard.tsx, src/components/FolderCard.tsx, src/components/Dashboard.tsx
Adds starred metadata to stored documents and folders, supports star toggles in the APIs, and wires star actions through the dashboard and cards.
Dashboard quick views and new-tab opens
src/components/Dashboard.tsx, src/components/DiagramCard.tsx
Adds All/Recent/Starred quick views, updates filtering and titles, and changes diagram opens and recent items to new-tab links.

Estimated code review effort: 4 (Complex) | ~75 minutes

Possibly related PRs

Poem

I hopped through tabs with whiskers bright,
Found blank pages waking into light.
Stars now twinkle, views run free,
New diagrams bloom in harmony,
Thump-thump — the canvas purrs just right 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Implements the linked objectives: create flow, blank-state handling, new-tab opens, starring, and sidebar quick views with shared catalog/tests.
Out of Scope Changes check ✅ Passed The changes shown are all aligned with the stated diagram-creation, editor, dashboard, and metadata goals.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly covers the main diagram creation and quick view changes in this PR.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/hooks/useEditorState.ts (1)

43-50: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Blank short-circuit doesn't reset theme/font state.

Clearing parseError/svgContent/renderIdRef is correct, but currentTheme/currentFont retain their last-rendered values when transitioning to blank. If the user then starts a brand-new diagram, the header may briefly show a stale theme/font from the previous content until the next successful render recalculates them. Low-impact but worth a defensive reset for consistency.

♻️ Optional fix
     if (mermaidCode.trim().length === 0) {
       setParseError(null);
       setSvgContent("");
+      setCurrentTheme("default");
+      setCurrentFont("Default");
       renderIdRef.current = null;
       if (onResetSelection) onResetSelection();
       return;
     }
As per coding guidelines, "Before implementing Mermaid logic, read `reference/standards/mermaid.md` and do not guess Mermaid syntax" — please confirm this blank short-circuit was validated against that standard.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/hooks/useEditorState.ts` around lines 43 - 50, The blank-state early
return in useEditorState should also defensively reset currentTheme and
currentFont, since they currently keep stale values after the diagram is
cleared. Update the empty-input branch in the editor state logic to clear those
theme/font fields alongside parseError, svgContent, and renderIdRef, and keep
the onResetSelection behavior unchanged. Confirm this change only affects the
blank short-circuit path in useEditorState and is consistent with the Mermaid
standards referenced for this logic.

Source: Coding guidelines

src/lib/diagrams/utils.ts (1)

82-83: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Only C4Context has a friendly label; other C4 variants fall through to generic formatting.

C4Container, C4Component, C4Dynamic, and C4Deployment are now detected by the regex at Line 82-83 but aren't present in diagramTypeLabel's KNOWN map (only C4Context is, Line 121), so they'll render as auto-spaced labels (e.g. "C4 Dynamic") instead of a consistent "C4 Diagram" style label.

♻️ Proposed fix
-    C4Context: "C4 Diagram",
+    C4Context: "C4 Diagram",
+    C4Container: "C4 Diagram",
+    C4Component: "C4 Diagram",
+    C4Dynamic: "C4 Diagram",
+    C4Deployment: "C4 Diagram",

Also applies to: 121-121

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/diagrams/utils.ts` around lines 82 - 83, The C4 variant detection in
diagramTypeLabel currently recognizes C4Container, C4Component, C4Dynamic, and
C4Deployment, but only C4Context has a friendly label in the KNOWN map, so the
other variants fall back to generic auto-spacing. Update diagramTypeLabel’s
KNOWN mapping to include all matched C4 variants (or normalize them to the same
friendly label) so they render consistently instead of as separate spaced names.
src/lib/api/storageTypes.ts (1)

259-260: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

starred/starredAt invariant not enforced in normalization.

normalizeDiagramDocument/normalizeFolder independently coerce starred and starredAt without correlating them, unlike the PUT API handlers which always null out starredAt when unstarred. If raw/persisted data ever has starred: false with a stale starredAt string (e.g., direct storage edits or legacy data), normalization will surface an inconsistent state (unstarred item carrying a starred timestamp).

🛡️ Proposed fix to enforce the invariant at normalization time
-    starred: Boolean(raw.starred),
-    starredAt: typeof raw.starredAt === "string" ? raw.starredAt : null,
+    starred: Boolean(raw.starred),
+    starredAt: Boolean(raw.starred) && typeof raw.starredAt === "string" ? raw.starredAt : null,

(apply the same pattern to normalizeFolder)

Also applies to: 275-276

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/api/storageTypes.ts` around lines 259 - 260, normalizeDiagramDocument
and normalizeFolder currently coerce starred and starredAt independently, which
can expose stale starredAt values for unstarred items. Update the normalization
logic in both functions so starredAt is only retained when the normalized
starred flag is true, and otherwise is forced to null, matching the invariant
already enforced by the PUT handlers. Use the existing starred/starredAt
handling in storageTypes.ts as the place to apply the correlated normalization.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/diagrams/utils.ts`:
- Around line 80-88: determineDiagramType currently falls back to "blank" for
non-empty input that does not match any known diagram declaration, which causes
malformed or comment-only content to be treated the same as truly empty code.
Update the fallback in determineDiagramType in utils.ts to return a distinct
value such as "unknown", and make sure useEditorState and any header/card label
logic handle that new value separately from "blank" so only empty diagrams show
Blank Diagram.

---

Nitpick comments:
In `@src/hooks/useEditorState.ts`:
- Around line 43-50: The blank-state early return in useEditorState should also
defensively reset currentTheme and currentFont, since they currently keep stale
values after the diagram is cleared. Update the empty-input branch in the editor
state logic to clear those theme/font fields alongside parseError, svgContent,
and renderIdRef, and keep the onResetSelection behavior unchanged. Confirm this
change only affects the blank short-circuit path in useEditorState and is
consistent with the Mermaid standards referenced for this logic.

In `@src/lib/api/storageTypes.ts`:
- Around line 259-260: normalizeDiagramDocument and normalizeFolder currently
coerce starred and starredAt independently, which can expose stale starredAt
values for unstarred items. Update the normalization logic in both functions so
starredAt is only retained when the normalized starred flag is true, and
otherwise is forced to null, matching the invariant already enforced by the PUT
handlers. Use the existing starred/starredAt handling in storageTypes.ts as the
place to apply the correlated normalization.

In `@src/lib/diagrams/utils.ts`:
- Around line 82-83: The C4 variant detection in diagramTypeLabel currently
recognizes C4Container, C4Component, C4Dynamic, and C4Deployment, but only
C4Context has a friendly label in the KNOWN map, so the other variants fall back
to generic auto-spacing. Update diagramTypeLabel’s KNOWN mapping to include all
matched C4 variants (or normalize them to the same friendly label) so they
render consistently instead of as separate spaced names.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ef1b14d9-d16f-4e12-ac68-6dff1b658afa

📥 Commits

Reviewing files that changed from the base of the PR and between 372a3cc and 2c40bff.

📒 Files selected for processing (15)
  • src/app/api/diagrams/[id]/route.ts
  • src/app/api/diagrams/route.ts
  • src/app/api/folders/[id]/route.ts
  • src/app/api/folders/route.ts
  • src/components/Dashboard.tsx
  • src/components/DiagramCard.tsx
  • src/components/FolderCard.tsx
  • src/components/editor/EditorCanvas.tsx
  • src/components/editor/EditorHeader.tsx
  • src/components/editor/LiveMaidEditor.tsx
  • src/hooks/useEditorState.ts
  • src/lib/api/storageTypes.ts
  • src/lib/diagrams/catalog.ts
  • src/lib/diagrams/utils.ts
  • src/test/diagram-catalog.test.ts

Comment thread src/lib/diagrams/utils.ts
@railway-app
railway-app Bot temporarily deployed to livemaid / livemaid-pr-111 July 8, 2026 00:37 Destroyed
@railway-app
railway-app Bot temporarily deployed to livemaid / livemaid-pr-111 July 8, 2026 00:38 Destroyed
@railway-app

railway-app Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the livemaid-pr-111 environment in livemaid

Service Status Web Updated (UTC)
livemaid ✅ Success (View Logs) Web Jul 9, 2026 at 1:34 am

@railway-app
railway-app Bot temporarily deployed to livemaid / livemaid-pr-111 July 8, 2026 00:49 Destroyed
@railway-app
railway-app Bot temporarily deployed to livemaid / livemaid-pr-111 July 8, 2026 00:52 Destroyed
@railway-app
railway-app Bot temporarily deployed to livemaid / livemaid-pr-111 July 8, 2026 03:21 Destroyed
@railway-app
railway-app Bot temporarily deployed to livemaid / livemaid-pr-111 July 8, 2026 10:19 Destroyed
@railway-app
railway-app Bot temporarily deployed to livemaid / livemaid-pr-111 July 8, 2026 13:25 Destroyed
@railway-app
railway-app Bot temporarily deployed to livemaid / livemaid-pr-111 July 9, 2026 01:33 Destroyed
@peter6055w

Copy link
Copy Markdown
Collaborator

/coderabbitai review

@peter6055
peter6055 enabled auto-merge (squash) July 9, 2026 08:07
@railway-app
railway-app Bot temporarily deployed to livemaid / livemaid-pr-111 July 9, 2026 08:12 Destroyed
@peter6055
peter6055 merged commit 009acfd into main Jul 9, 2026
5 checks passed
@peter6055
peter6055 deleted the feat/issues-106-110 branch July 9, 2026 08:17

This branch was successfully deployed

No deployments
livemaid / livemaid-pr-111 — 58eceab6 Deployed Jul 9, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment