File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,13 +103,13 @@ export default function CodeViewer({
103103 < SyntaxHighlighter code = { code } language = { language } />
104104 </ div >
105105 ) : (
106- < div >
106+ < >
107107 { language && (
108- < div className = "mt-8 flex items-center justify-center" >
108+ < div className = "flex h-full items-center justify-center" >
109109 < CodeRunner language = { language } code = { code } key = { refresh } />
110110 </ div >
111111 ) }
112- </ div >
112+ </ >
113113 ) }
114114 </ div >
115115 ) : (
@@ -156,7 +156,9 @@ export default function CodeViewer({
156156 < p className = "text-sm" >
157157 Version < span className = "tabular-nums" > { currentVersion + 1 } </ span > { " " }
158158 < span className = "text-gray-400" > of</ span > { " " }
159- < span className = "tabular-nums" > { assistantMessages . length } </ span >
159+ < span className = "tabular-nums" >
160+ { Math . max ( currentVersion + 1 , assistantMessages . length ) }
161+ </ span >
160162 </ p >
161163
162164 { nextMessage ? (
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import assert from "assert";
1111import Image from "next/image" ;
1212import Link from "next/link" ;
1313import { useRouter } from "next/navigation" ;
14- import { use , useState } from "react" ;
14+ import { startTransition , use , useState } from "react" ;
1515import TextareaAutosize from "react-textarea-autosize" ;
1616import { createChat , getNextCompletionStreamPromise } from "./actions" ;
1717import { Context } from "./providers" ;
@@ -77,9 +77,11 @@ export default function Home() {
7777 lastMessageId ,
7878 model ,
7979 ) ;
80- setStreamPromise ( streamPromise ) ;
8180
82- router . push ( `/chats/${ chatId } ` ) ;
81+ startTransition ( ( ) => {
82+ setStreamPromise ( streamPromise ) ;
83+ router . push ( `/chats/${ chatId } ` ) ;
84+ } ) ;
8385 } }
8486 >
8587 < Fieldset >
@@ -89,7 +91,7 @@ export default function Home() {
8991 required
9092 name = "prompt"
9193 rows = { 1 }
92- className = "peer relative w-full resize-none bg-transparent p-2 placeholder-gray-500 focus:outline-none"
94+ className = "peer relative w-full resize-none bg-transparent p-2 placeholder-gray-500 focus:outline-none disabled:opacity-50 "
9395 value = { prompt }
9496 onChange = { ( e ) => setPrompt ( e . target . value ) }
9597 onKeyDown = { ( event ) => {
Original file line number Diff line number Diff line change 11export default function Layout ( { children } : { children : React . ReactNode } ) {
22 return (
3- < body className = "flex min-h-full flex-col items-center justify-center" >
3+ < body className = "flex h-full min-h-full flex-col items-center justify-center" >
44 { children }
55 </ body >
66 ) ;
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export default async function SharePage({
4444 }
4545
4646 return (
47- < div className = "flex h-full items-center justify-center" >
47+ < div className = "flex h-full w-full grow items-center justify-center" >
4848 < CodeRunner language = { app . language } code = { app . code } />
4949 </ div >
5050 ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export default function ReactCodeRunner({ code }: { code: string }) {
1212 < SandpackProvider
1313 key = { code }
1414 template = "react-ts"
15+ className = "h-full w-full [&_.sp-preview-container]:flex [&_.sp-preview-container]:h-full [&_.sp-preview-container]:w-full [&_.sp-preview-container]:grow [&_.sp-preview-container]:flex-col [&_.sp-preview-container]:justify-center [&_.sp-preview-iframe]:grow"
1516 files = { {
1617 "App.tsx" : code ,
1718 ...shadcnFiles ,
@@ -31,7 +32,7 @@ export default function ReactCodeRunner({ code }: { code: string }) {
3132 showRefreshButton = { false }
3233 showRestartButton = { false }
3334 showOpenNewtab = { false }
34- className = "w-full"
35+ className = "h-full w-full"
3536 />
3637 </ SandpackProvider >
3738 ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ export default function CodeRunner({
1212 language : string ;
1313 code : string ;
1414} ) {
15+ return < CodeRunnerReact code = { code } /> ;
16+
1517 return (
1618 < >
1719 { language === "python" ? (
You can’t perform that action at this time.
0 commit comments