Skip to content

feat: Allow to edit a column from the schema visualiser - #43592

Merged
djhi merged 7 commits into
masterfrom
fe-2422-add-inline-column-edit-button-in-schema-visualiser
Mar 10, 2026
Merged

djhi merged 7 commits into
masterfrom
fe-2422-add-inline-column-edit-button-in-schema-visualiser

Conversation

@djhi

@djhi djhi commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Problem

Editing a column from the schema visualiser requires many clicks

Solution

When hovering over a column in the schema visualiser, an edit button should appear on the right side. Clicking this button should open the column edit pane on the right side of the screen. This would reduce the number of clicks required and allow users to make edits directly from the visualiser instead of using it only as a visual aid.

@supabase

supabase Bot commented Mar 10, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@vercel

vercel Bot commented Mar 10, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment Mar 10, 2026 3:04pm
studio-staging Ready Ready Preview, Comment Mar 10, 2026 3:04pm
7 Skipped Deployments
Project Deployment Actions Updated (UTC)
cms Ignored Ignored Mar 10, 2026 3:04pm
studio Ignored Ignored Mar 10, 2026 3:04pm
design-system Skipped Skipped Mar 10, 2026 3:04pm
docs Skipped Skipped Mar 10, 2026 3:04pm
learn Skipped Skipped Mar 10, 2026 3:04pm
ui-library Skipped Skipped Mar 10, 2026 3:04pm
zone-www-dot-com Skipped Skipped Mar 10, 2026 3:04pm

Request Review

@coderabbitai

coderabbitai Bot commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Per-column "Edit" button in the schema table to open a side-panel editor for column properties.
    • Side-panel editor now displays and lets you edit column details (name, description).
  • Bug Fixes

    • Table/column data now refreshes reliably after column updates so changes appear immediately.
  • Tests

    • Added end-to-end CRUD tests for column and related database operations with more precise selectors.

Walkthrough

Adds a ColumnEditionContext (type, provider, hook) and integrates it into the schema graph and table node UI so per-column "Edit" actions call a unified onEditColumn(tableId, columnId) handler. SchemaGraph sets selectedTable and delegates to the table editor snapshot (snap.onEditColumn), and a SidePanelEditor displays the selected table/column for editing. getTables() now returns full PostgresTable[] (including columns). E2E tests expanded/renamed to cover column CRUD flows and column description edits.

Sequence Diagram

sequenceDiagram
    actor User
    participant TableNode as SchemaTableNode
    participant Context as ColumnEditionContext
    participant Graph as SchemaGraph
    participant Snap as TableEditorSnapshot
    participant SidePanel as SidePanelEditor
    participant ColumnEditor as ColumnEditor
    participant API as Backend/API

    User->>TableNode: Click "Edit" on column
    TableNode->>Context: onEditColumn(tableId, columnId)
    Context->>Graph: forward onEditColumn
    Graph->>Graph: find table & set selectedTable
    Graph->>Snap: snap.onEditColumn(tableId, columnId)
    Graph->>SidePanel: open with selectedTable
    SidePanel->>ColumnEditor: render column details
    User->>ColumnEditor: submit edits
    ColumnEditor->>API: send update
    API->>API: persist & invalidate table list
    API-->>ColumnEditor: return success
    ColumnEditor->>SidePanel: close/refresh
    SidePanel->>Graph: trigger UI update
Loading

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.

@github-actions

github-actions Bot commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  155 passed
flaky  1 flaky
skipped  4 skipped

Details

stats  160 tests across 20 suites
duration  10 minutes, 4 seconds
commit  75ed140

Flaky tests

Features › table-editor.spec.ts › table editor › add enums and show enums on table

Skipped tests

Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@djhi
djhi marked this pull request as ready for review March 10, 2026 14:28
@djhi
djhi requested a review from a team as a code owner March 10, 2026 14:28

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/studio/components/interfaces/Database/Schemas/ColumnEditionContext.tsx`:
- Around line 1-2: The file imports ReactNode from react-markdown internals;
update the import so ReactNode is imported from 'react' instead (keep
createContext and useContext imports unchanged) — locate the import statement
that references ReactNode (used in this file alongside createContext/useContext)
and change its source to 'react' to match the rest of the codebase.

In `@apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx`:
- Around line 215-227: The new onEditColumn entry in columnEditionContext
bypasses the existing write guards and should be blocked when edits are not
allowed; modify the onEditColumn implementation to check the existing
canUpdateTables and isSchemaLocked flags (computed earlier in the component)
before proceeding: if !canUpdateTables or isSchemaLocked return early; otherwise
locate the table/column as now, call setSelectedTable(table) and
snap.onEditColumn(column). Ensure you reference the same variables
(canUpdateTables, isSchemaLocked, columnEditionContext, onEditColumn,
setSelectedTable, snap.onEditColumn) so the hover action respects schema
write/lock rules.
- Around line 199-213: The effect that loads nodes/edges should re-fit the
viewport when the user changes schemas: update the useEffect watching
isSuccessTables/isSuccessSchemas/tables/resolvedTheme to also include
selectedSchema, and after getGraphDataFromTables resolves and
reactFlowInstance.setNodes/setEdges, call reactFlowInstance.fitView (using the
same setTimeout used for first load) whenever selectedSchema changed (or
whenever not isFirstLoad.current) so the newly loaded graph is centered;
reference isFirstLoad, selectedSchema, getGraphDataFromTables,
reactFlowInstance.setNodes/setEdges, and reactFlowInstance.fitView to locate and
implement the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 0409c930-ef4a-478a-bce2-de2b00978d2c

📥 Commits

Reviewing files that changed from the base of the PR and between 92bdbb2 and 339bb81.

📒 Files selected for processing (7)
  • apps/studio/components/interfaces/Database/Schemas/ColumnEditionContext.tsx
  • apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx
  • apps/studio/components/interfaces/Database/Schemas/SchemaTableNode.tsx
  • apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
  • apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
  • apps/studio/data/tables/tables-query.ts
  • e2e/studio/features/database.spec.ts

Comment on lines +199 to 213
const isFirstLoad = useRef(true)
useEffect(() => {
if (isSuccessTables && isSuccessSchemas && tables.length > 0) {
const schema = schemas.find((s) => s.name === selectedSchema) as PostgresSchema
getGraphDataFromTables(ref as string, schema, tables).then(({ nodes, edges }) => {
reactFlowInstance.setNodes(nodes)
reactFlowInstance.setEdges(edges)
setTimeout(() => reactFlowInstance.fitView({})) // it needs to happen during next event tick
// Prevent resetting a view after first load to avoid layout changes after editing a column
if (isFirstLoad.current) {
isFirstLoad.current = false
setTimeout(() => reactFlowInstance.fitView({})) // it needs to happen during next event tick
}
})
}
}, [isSuccessTables, isSuccessSchemas, tables, resolvedTheme])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Re-fit the viewport when selectedSchema changes.

Once isFirstLoad.current flips to false, every later schema switch reuses the previous viewport. After the first visit, changing schemas can leave the newly loaded graph off-screen until the user manually recenters it.

Possible fix
-  const isFirstLoad = useRef(true)
+  const lastFittedSchema = useRef<string | undefined>(undefined)
   useEffect(() => {
     if (isSuccessTables && isSuccessSchemas && tables.length > 0) {
       const schema = schemas.find((s) => s.name === selectedSchema) as PostgresSchema
       getGraphDataFromTables(ref as string, schema, tables).then(({ nodes, edges }) => {
         reactFlowInstance.setNodes(nodes)
         reactFlowInstance.setEdges(edges)
-        // Prevent resetting a view after first load to avoid layout changes after editing a column
-        if (isFirstLoad.current) {
-          isFirstLoad.current = false
+        // Recenter on first load per schema, but not on every table refresh
+        if (lastFittedSchema.current !== selectedSchema) {
+          lastFittedSchema.current = selectedSchema
           setTimeout(() => reactFlowInstance.fitView({})) // it needs to happen during next event tick
         }
       })
     }
-  }, [isSuccessTables, isSuccessSchemas, tables, resolvedTheme])
+  }, [isSuccessTables, isSuccessSchemas, tables, resolvedTheme, selectedSchema])
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx` around
lines 199 - 213, The effect that loads nodes/edges should re-fit the viewport
when the user changes schemas: update the useEffect watching
isSuccessTables/isSuccessSchemas/tables/resolvedTheme to also include
selectedSchema, and after getGraphDataFromTables resolves and
reactFlowInstance.setNodes/setEdges, call reactFlowInstance.fitView (using the
same setTimeout used for first load) whenever selectedSchema changed (or
whenever not isFirstLoad.current) so the newly loaded graph is centered;
reference isFirstLoad, selectedSchema, getGraphDataFromTables,
reactFlowInstance.setNodes/setEdges, and reactFlowInstance.fitView to locate and
implement the change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this true? Can you test this @djhi ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It isn't

Comment on lines +215 to +227
const columnEditionContext = useMemo<ColumnEditionContextType>(
() => ({
onEditColumn: (tableId, columnId) => {
const table = tables.find((table) => table.id === tableId)
if (!table || table.columns == null) return
const column = table.columns.find((column) => column.id === columnId)
if (!column) return
setSelectedTable(table)
snap.onEditColumn(column)
},
}),
[tables, snap]
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Guard the new edit entry point with the existing write/lock checks.

This handler ignores canUpdateTables and isSchemaLocked, so the new hover action can still open a writable column editor for protected schemas and for users without table write access. The schema visualizer already computes those conditions above; this path needs to enforce them too.

Minimal guard
   const columnEditionContext = useMemo<ColumnEditionContextType>(
     () => ({
       onEditColumn: (tableId, columnId) => {
+        if (!canUpdateTables || isSchemaLocked) return
         const table = tables.find((table) => table.id === tableId)
         if (!table || table.columns == null) return
         const column = table.columns.find((column) => column.id === columnId)
         if (!column) return
         setSelectedTable(table)
         snap.onEditColumn(column)
       },
     }),
-    [tables, snap]
+    [canUpdateTables, isSchemaLocked, tables, snap]
   )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const columnEditionContext = useMemo<ColumnEditionContextType>(
() => ({
onEditColumn: (tableId, columnId) => {
const table = tables.find((table) => table.id === tableId)
if (!table || table.columns == null) return
const column = table.columns.find((column) => column.id === columnId)
if (!column) return
setSelectedTable(table)
snap.onEditColumn(column)
},
}),
[tables, snap]
)
const columnEditionContext = useMemo<ColumnEditionContextType>(
() => ({
onEditColumn: (tableId, columnId) => {
if (!canUpdateTables || isSchemaLocked) return
const table = tables.find((table) => table.id === tableId)
if (!table || table.columns == null) return
const column = table.columns.find((column) => column.id === columnId)
if (!column) return
setSelectedTable(table)
snap.onEditColumn(column)
},
}),
[canUpdateTables, isSchemaLocked, tables, snap]
)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx` around
lines 215 - 227, The new onEditColumn entry in columnEditionContext bypasses the
existing write guards and should be blocked when edits are not allowed; modify
the onEditColumn implementation to check the existing canUpdateTables and
isSchemaLocked flags (computed earlier in the component) before proceeding: if
!canUpdateTables or isSchemaLocked return early; otherwise locate the
table/column as now, call setSelectedTable(table) and snap.onEditColumn(column).
Ensure you reference the same variables (canUpdateTables, isSchemaLocked,
columnEditionContext, onEditColumn, setSelectedTable, snap.onEditColumn) so the
hover action respects schema write/lock rules.

@awaseem awaseem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Image

This looks not great, we should be hiding the text underneath

Comment on lines +199 to 213
const isFirstLoad = useRef(true)
useEffect(() => {
if (isSuccessTables && isSuccessSchemas && tables.length > 0) {
const schema = schemas.find((s) => s.name === selectedSchema) as PostgresSchema
getGraphDataFromTables(ref as string, schema, tables).then(({ nodes, edges }) => {
reactFlowInstance.setNodes(nodes)
reactFlowInstance.setEdges(edges)
setTimeout(() => reactFlowInstance.fitView({})) // it needs to happen during next event tick
// Prevent resetting a view after first load to avoid layout changes after editing a column
if (isFirstLoad.current) {
isFirstLoad.current = false
setTimeout(() => reactFlowInstance.fitView({})) // it needs to happen during next event tick
}
})
}
}, [isSuccessTables, isSuccessSchemas, tables, resolvedTheme])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this true? Can you test this @djhi ?

onEditColumn: (tableId, columnId) => {
const table = tables.find((table) => table.id === tableId)
if (!table || table.columns == null) return
const column = table.columns.find((column) => column.id === columnId)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: spacing here, it cleans it up a bit

await page.getByRole('button', { name: 'View saml_providers', exact: true }).click()
})

test('columns actions work as expected', async ({ page, ref }) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx (1)

215-229: ⚠️ Potential issue | 🟠 Major

Guard onEditColumn with permission checks.

The onEditColumn handler bypasses the existing canUpdateTables and isSchemaLocked checks that protect other edit actions in this component. Users without write permissions or accessing protected schemas can trigger the column editor.

Proposed fix
   const columnEditionContext = useMemo<ColumnEditionContextType>(
     () => ({
       onEditColumn: (tableId, columnId) => {
+        if (!canUpdateTables || isSchemaLocked) return
         const table = tables.find((table) => table.id === tableId)
         if (!table || table.columns == null) return

         const column = table.columns.find((column) => column.id === columnId)
         if (!column) return

         setSelectedTable(table)
         snap.onEditColumn(column)
       },
     }),
-    [tables, snap]
+    [canUpdateTables, isSchemaLocked, tables, snap]
   )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx` around
lines 215 - 229, The onEditColumn handler inside columnEditionContext must
enforce the same permission and lock checks as other edit flows: before finding
the table/column, check canUpdateTables() and !isSchemaLocked(), and return
early if the user cannot edit; only then call setSelectedTable(table) and
snap.onEditColumn(column). Update the columnEditionContext closure (the
onEditColumn function) to reference the existing canUpdateTables and
isSchemaLocked helpers so unauthorized or locked-schema users cannot open the
column editor.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx`:
- Around line 215-229: The onEditColumn handler inside columnEditionContext must
enforce the same permission and lock checks as other edit flows: before finding
the table/column, check canUpdateTables() and !isSchemaLocked(), and return
early if the user cannot edit; only then call setSelectedTable(table) and
snap.onEditColumn(column). Update the columnEditionContext closure (the
onEditColumn function) to reference the existing canUpdateTables and
isSchemaLocked helpers so unauthorized or locked-schema users cannot open the
column editor.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 9816c535-6c6c-4106-bb0d-d63934317b9d

📥 Commits

Reviewing files that changed from the base of the PR and between 339bb81 and 75ed140.

📒 Files selected for processing (3)
  • apps/studio/components/interfaces/Database/Schemas/ColumnEditionContext.tsx
  • apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx
  • apps/studio/components/interfaces/Database/Schemas/SchemaTableNode.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/studio/components/interfaces/Database/Schemas/SchemaTableNode.tsx

@awaseem awaseem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@djhi
djhi merged commit f66eb3f into master Mar 10, 2026
24 checks passed
@djhi
djhi deleted the fe-2422-add-inline-column-edit-button-in-schema-visualiser branch March 10, 2026 18:28
@github-actions

github-actions Bot commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1773167430)

Score Average Improvements Regressions
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 93.3% (0pp) - 1 🔴
Tool Usage 96.9% (-3pp) - 1 🔴
Completeness 91.2% (-9pp) - 3 🔴
Conciseness 0% (+0pp) - -
Goal Completion 91.2% (-5pp) 1 🟢 3 🔴
Docs Faithfulness 55.3% (-9pp) - 2 🔴
Correctness 91.7% (-8pp) - 1 🔴
URL Validity 100% (+0pp) - -
Time_to_first_token 0.23tok (+0tok) 8 🟢 4 🔴
Llm_calls 8.42 (+0.06) 4 🟢 2 🔴
Tool_calls 3.25 (+0.22) 5 🟢 2 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 58106.61tok (+3576.03tok) 6 🟢 6 🔴
Prompt_cached_tokens 26005.33tok (-1361.78tok) 3 🟢 7 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Completion_tokens 2948.03tok (+168.61tok) 5 🟢 7 🔴
Completion_reasoning_tokens 2142.22tok (+97.78tok) 6 🟢 6 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 61054.64tok (+3744.64tok) 5 🟢 7 🔴
Estimated_cost 0.01$ (+0$) 4 🟢 8 🔴
Duration 48.77s (-1.82s) 6 🟢 6 🔴
Llm_duration 94.46s (-5.28s) 7 🟢 5 🔴

mandarini pushed a commit that referenced this pull request Mar 11, 2026
## Problem

Editing a column from the schema visualiser requires many clicks

## Solution

When hovering over a column in the schema visualiser, an edit button
should appear on the right side. Clicking this button should open the
column edit pane on the right side of the screen. This would reduce the
number of clicks required and allow users to make edits directly from
the visualiser instead of using it only as a visual aid.
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