Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Issue

Why is this change needed?

This change improves the schema input UX in Paste Schema mode by replacing the native textarea with a CodeMirror editor that provides syntax highlighting. This makes it easier for users to paste and edit schemas by providing visual feedback about the schema structure.

What changed?

  • Replaced native textarea with CodeMirror editor in PasteSessionFormPresenter
  • Created useSchemaEditor hook to manage CodeMirror lifecycle, initialization, and updates
  • Added custom editor theme (editorTheme.ts) that matches the existing design system with SQL syntax highlighting
  • Updated CSS to style the CodeMirror editor wrapper with hover and focus states
  • Added hidden input field to ensure form submission still works since the textarea was replaced with a div
  • Updated Storybook stories with new examples (though they don't pre-populate content yet)

Implementation notes

Current language support

  • SQL (PostgreSQL): Full syntax highlighting using @codemirror/lang-sql
  • ⚠️ schema.rb, Prisma, TBLS: Currently fall back to plain text (no syntax highlighting yet)

Editor lifecycle

The editor uses two useEffect hooks:

  1. Creates/destroys editor when format, disabled state, or value changes
  2. Updates editor content when value prop changes externally

⚠️ Note: The first useEffect includes value in its dependency array, which means the editor will be completely recreated on every value change. This ensures the editor stays in sync but may affect performance and cursor position.

Human review checklist

Critical items to verify:

  1. Form submission works - Schema content is properly submitted via the hidden input field
  2. ⚠️ Editor behavior - Check if the editor recreates too frequently or loses cursor position when typing
  3. Disabled state - Verify the editor is properly disabled when isPending is true
  4. ⚠️ Value synchronization - The second useEffect might be redundant since the first one already updates the value
  5. Syntax highlighting - SQL syntax highlighting works for PostgreSQL format

Nice to have:

  • Add syntax highlighting for other formats (schema.rb, Prisma, TBLS) in a follow-up PR
  • Improve Storybook stories with sample schema content
  • Consider optimizing the editor lifecycle to avoid full recreation on value changes

Session: https://app.devin.ai/sessions/71f18788a3764820b71d56d129f91793
Requested by: @MH4GF ([email protected])

- Replace native textarea with CodeMirror editor in PasteSessionFormPresenter
- Add useSchemaEditor hook with syntax highlighting support for SQL (PostgreSQL)
- Implement custom editor theme matching existing design system
- Support for multiple schema formats (SQL, schema.rb, Prisma, TBLS)
- Maintain existing functionality: value binding, validation, disabled state
- Update Storybook stories to showcase CodeMirror integration
- Add proper CSS styling for editor wrapper with hover and focus states

Resolves #5972

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link

vercel bot commented Oct 29, 2025

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

Project Deployment Preview Comments Updated (UTC)
liam-app Ready Ready Preview Comment Nov 5, 2025 2:45am
liam-assets Ready Ready Preview Comment Nov 5, 2025 2:45am
liam-storybook Ready Ready Preview Comment Nov 5, 2025 2:45am
2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
liam-docs Ignored Ignored Preview Nov 5, 2025 2:45am
liam-erd-sample Skipped Skipped Nov 5, 2025 2:45am

@giselles-ai
Copy link

giselles-ai bot commented Oct 29, 2025

Finished running flow.

Step Status Updated(UTC)
1 Oct 29, 2025 9:30am
2 Oct 29, 2025 9:32am
3 Oct 29, 2025 9:32am

@supabase
Copy link

supabase bot commented Oct 29, 2025

Updates to Preview Branch (devin/1761729885-codemirror-paste-schema-editor) ↗︎

Deployments Status Updated
Database Wed, 05 Nov 2025 02:41:52 UTC
Services Wed, 05 Nov 2025 02:41:52 UTC
APIs Wed, 05 Nov 2025 02:41:52 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Wed, 05 Nov 2025 02:41:54 UTC
Migrations Wed, 05 Nov 2025 02:41:54 UTC
Seeding Wed, 05 Nov 2025 02:41:54 UTC
Edge Functions Wed, 05 Nov 2025 02:41:54 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 29, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Note

Free review on us!

CodeRabbit is offering free reviews until Thu Nov 06 2025 to showcase some of the refinements we've made.

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

@giselles-ai
Copy link

giselles-ai bot commented Oct 29, 2025

Check changeset necessity

Status: NOT REQUIRED

Reason:

  • Changes are limited to the app code under frontend/apps/app, which maps to the ignored package "@liam-hq/app".
  • No modifications to target publishable packages: @liam-hq/cli, @liam-hq/erd-core, @liam-hq/schema, or @liam-hq/ui.
  • Although the change is user-facing (integrating CodeMirror in the app UI), it does not affect any published package APIs or behavior.
  • Storybook story updates are development-only and do not impact publishable packages.

Changeset (copy & paste):

<!-- No changeset required: only @liam-hq/app (ignored) changed -->

- Use ref for onChange callback to avoid editor recreation
- Remove value and onChange from create/destroy effect dependencies
- Add 'use client' directive to PasteSessionFormPresenter
- Wrap handleSchemaEditorChange in useCallback for stable identity
- Add biome-ignore comment for intentional dependency exclusion

This fixes the browser error caused by infinite re-render loop when
the editor was being destroyed and recreated on every keystroke.

Co-Authored-By: [email protected] <[email protected]>
Resolved conflicts in PasteSessionFormPresenter.module.css:
- Kept CodeMirror editor styles (.schemaEditorWrapper)
- Removed old textarea styles (.schemaTextarea)
- Updated disabled state styling for editor wrapper

Co-Authored-By: [email protected] <[email protected]>
devin-ai-integration bot and others added 2 commits November 4, 2025 06:12
Resolved conflicts in PasteSessionFormPresenter.module.css:
- Replaced formatSelectorWrapper/formatSelect with formatDropdown
- Removed old schemaTextarea placeholder styles

Co-Authored-By: [email protected] <[email protected]>
- Add max-height: 600px to constrain editor height
- Add overflow: auto and resize: vertical for scrolling and manual resizing
- Remove white focus border by setting focus-within to base border color
- Add global CSS rules for CodeMirror internal classes
- Remove outline from .cm-editor.cm-focused to eliminate focus ring

These changes address user feedback:
1. Prevent text from displaying at full length (now constrained by max-height)
2. Allow manual resizing like the original textarea
3. Remove white border that appears on focus

Co-Authored-By: [email protected] <[email protected]>
…editor

The white focus outline was coming from the browser's default [contenteditable]:focus rule, not from .cm-editor.cm-focused. Added CSS rule to override the contenteditable focus outline within the schema editor wrapper.

Co-Authored-By: [email protected] <[email protected]>
@vercel vercel bot temporarily deployed to Preview – liam-erd-sample November 5, 2025 02:40 Inactive
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