@@ -12,17 +12,19 @@ import { tabsSchema, TabValue } from '~/lib/schema'
12
12
import { assertDefined , isMigrationStatement } from '~/lib/sql-util'
13
13
import { ToolInvocation } from '~/lib/tools'
14
14
import { useBreakpoint } from '~/lib/use-breakpoint'
15
+ import { cn } from '~/lib/utils'
15
16
import { useApp } from './app-provider'
16
17
import SchemaGraph from './schema/graph'
17
18
import { useWorkspace } from './workspace'
18
19
19
20
const initialMigrationSql = '-- Migrations will appear here as you chat with AI\n'
20
21
const initialSeedSql = '-- Seeds will appear here as you chat with AI\n'
21
22
22
- export type IDEProps = PropsWithChildren
23
+ export type IDEProps = PropsWithChildren < {
24
+ className ?: string
25
+ } >
23
26
24
- export default function IDE ( { children } : IDEProps ) {
25
- const { pgliteVersion, pgVersion } = useApp ( )
27
+ export default function IDE ( { children, className } : IDEProps ) {
26
28
const { databaseId } = useWorkspace ( )
27
29
const [ tab , setTab ] = useState < TabValue > ( 'diagram' )
28
30
@@ -94,9 +96,9 @@ export default function IDE({ children }: IDEProps) {
94
96
const migrationsSql = ( initialMigrationSql + '\n' + migrationStatements ?. join ( '\n\n' ) ) . trim ( )
95
97
96
98
return (
97
- < div className = " flex-1 h-full flex flex -col items-stretch gap-3" >
99
+ < div className = { cn ( ' flex flex-col items-stretch gap-3' , className ) } >
98
100
< Tabs
99
- className = "flex-1 flex flex-col items-stretch"
101
+ className = "h-full flex-1 flex flex-col items-stretch"
100
102
value = { tab }
101
103
onValueChange = { ( tab ) => setTab ( tabsSchema . parse ( tab ) ) }
102
104
>
@@ -125,53 +127,60 @@ export default function IDE({ children }: IDEProps) {
125
127
</ TabsList >
126
128
127
129
{ isSmallBreakpoint && (
128
- < TabsContent value = "chat" className = "flex-1 h-full min-h-0" >
130
+ < TabsContent value = "chat" className = "flex-1 h-full min-h-0 overflow-y-auto " >
129
131
{ children }
130
132
</ TabsContent >
131
133
) }
132
134
< TabsContent value = "diagram" className = "h-full" >
133
- < SchemaGraph databaseId = { databaseId } schemas = { [ 'public' , 'meta' ] } />
135
+ < div className = "h-full flex flex-col gap-3" >
136
+ < SchemaGraph databaseId = { databaseId } schemas = { [ 'public' , 'meta' ] } />
137
+ < Footer />
138
+ </ div >
134
139
</ TabsContent >
135
- < TabsContent value = "migrations" className = "h-full py-4 rounded-md bg-[#1e1e1e]" >
136
- < Editor
137
- language = "pgsql"
138
- value = { migrationsSql }
139
- theme = "vs-dark"
140
- options = { {
141
- tabSize : 2 ,
142
- minimap : {
143
- enabled : false ,
144
- } ,
145
- fontSize : 13 ,
146
- readOnly : true ,
147
- } }
148
- onMount = { async ( editor , monaco ) => {
149
- // Register pgsql formatter
150
- monaco . languages . registerDocumentFormattingEditProvider ( 'pgsql' , {
151
- async provideDocumentFormattingEdits ( model ) {
152
- const currentCode = editor . getValue ( )
153
- const formattedCode = format ( currentCode , {
154
- language : 'postgresql' ,
155
- keywordCase : 'lower' ,
156
- } )
157
- return [
158
- {
159
- range : model . getFullModelRange ( ) ,
160
- text : formattedCode ,
161
- } ,
162
- ]
140
+ < TabsContent value = "migrations" className = "h-full" >
141
+ < div className = "h-full flex flex-col gap-3" >
142
+ < Editor
143
+ className = " py-4 rounded-md bg-[#1e1e1e]"
144
+ language = "pgsql"
145
+ value = { migrationsSql }
146
+ theme = "vs-dark"
147
+ options = { {
148
+ tabSize : 2 ,
149
+ minimap : {
150
+ enabled : false ,
163
151
} ,
164
- } )
152
+ fontSize : 13 ,
153
+ readOnly : true ,
154
+ } }
155
+ onMount = { async ( editor , monaco ) => {
156
+ // Register pgsql formatter
157
+ monaco . languages . registerDocumentFormattingEditProvider ( 'pgsql' , {
158
+ async provideDocumentFormattingEdits ( model ) {
159
+ const currentCode = editor . getValue ( )
160
+ const formattedCode = format ( currentCode , {
161
+ language : 'postgresql' ,
162
+ keywordCase : 'lower' ,
163
+ } )
164
+ return [
165
+ {
166
+ range : model . getFullModelRange ( ) ,
167
+ text : formattedCode ,
168
+ } ,
169
+ ]
170
+ } ,
171
+ } )
165
172
166
- // Format on cmd+s
167
- editor . addCommand ( monaco . KeyMod . CtrlCmd | monaco . KeyCode . KeyS , async ( ) => {
168
- await editor . getAction ( 'editor.action.formatDocument' ) ?. run ( )
169
- } )
173
+ // Format on cmd+s
174
+ editor . addCommand ( monaco . KeyMod . CtrlCmd | monaco . KeyCode . KeyS , async ( ) => {
175
+ await editor . getAction ( 'editor.action.formatDocument' ) ?. run ( )
176
+ } )
170
177
171
- // Run format on the initial value
172
- await editor . getAction ( 'editor.action.formatDocument' ) ?. run ( )
173
- } }
174
- />
178
+ // Run format on the initial value
179
+ await editor . getAction ( 'editor.action.formatDocument' ) ?. run ( )
180
+ } }
181
+ />
182
+ < Footer />
183
+ </ div >
175
184
</ TabsContent >
176
185
{ /* Temporarily hide seeds until we get pg_dump working */ }
177
186
{ false && (
@@ -217,22 +226,27 @@ export default function IDE({ children }: IDEProps) {
217
226
</ TabsContent >
218
227
) }
219
228
</ Tabs >
229
+ </ div >
230
+ )
231
+ }
220
232
221
- < div className = "flex flex-col pb-1 text-xs text-neutral-500 text-center justify-center" >
222
- { pgliteVersion && (
223
- < span >
224
- < a
225
- className = "underline"
226
- href = "https://github.com/electric-sql/pglite"
227
- target = "_blank"
228
- rel = "noopener noreferrer"
229
- >
230
- PGlite
231
- </ a > { ' ' }
232
- { pgliteVersion } { pgVersion && < > (PG { pgVersion } )</ > }
233
- </ span >
234
- ) }
235
- </ div >
233
+ function Footer ( ) {
234
+ const { pgliteVersion, pgVersion } = useApp ( )
235
+ return (
236
+ < div className = "flex flex-col pb-1 text-xs text-neutral-500 text-center justify-center" >
237
+ { pgliteVersion && (
238
+ < span >
239
+ < a
240
+ className = "underline"
241
+ href = "https://github.com/electric-sql/pglite"
242
+ target = "_blank"
243
+ rel = "noopener noreferrer"
244
+ >
245
+ PGlite
246
+ </ a > { ' ' }
247
+ { pgliteVersion } { pgVersion && < > (PG { pgVersion } )</ > }
248
+ </ span >
249
+ ) }
236
250
</ div >
237
251
)
238
252
}
0 commit comments