11import { useState } from "react" ;
2+ import prettyMilliseconds from "pretty-ms" ;
23import { toast } from "sonner" ;
34
45import { trpc } from "~/api/trpc" ;
@@ -19,6 +20,14 @@ import {
1920 FieldLabel ,
2021} from "~/components/ui/field" ;
2122import { Input } from "~/components/ui/input" ;
23+ import {
24+ Table ,
25+ TableBody ,
26+ TableCell ,
27+ TableHead ,
28+ TableHeader ,
29+ TableRow ,
30+ } from "~/components/ui/table" ;
2231import { useWorkspace } from "~/components/WorkspaceProvider" ;
2332
2433export default function GeneralSettingsPage ( ) {
@@ -30,10 +39,19 @@ export default function GeneralSettingsPage() {
3039 slug ?: string ;
3140 } > ( { } ) ;
3241
42+ const utils = trpc . useUtils ( ) ;
43+ const saveHistoryQuery = trpc . workspace . saveHistory . useQuery ( {
44+ workspaceId : workspace . id ,
45+ } ) ;
46+
3347 const saveWorkspace = trpc . workspace . save . useMutation ( {
3448 onSuccess : ( ) => {
3549 toast . success ( "Workspace saved sucessfully" ) ;
50+ void utils . workspace . saveHistory . invalidate ( {
51+ workspaceId : workspace . id ,
52+ } ) ;
3653 } ,
54+
3755 onError : ( error : unknown ) => {
3856 const message =
3957 error instanceof Error ? error . message : "Failed to update workspace" ;
@@ -178,7 +196,7 @@ export default function GeneralSettingsPage() {
178196
179197 < Card >
180198 < CardHeader >
181- < CardTitle > Workspace Information </ CardTitle >
199+ < CardTitle > State </ CardTitle >
182200 < CardDescription >
183201 Update your workspace name and URL slug
184202 </ CardDescription >
@@ -189,6 +207,35 @@ export default function GeneralSettingsPage() {
189207 >
190208 Force Save Workspace
191209 </ Button >
210+
211+ < div className = "mt-5 max-h-[500px] overflow-y-auto rounded-md border bg-muted/50" >
212+ < Table >
213+ < TableHeader >
214+ < TableRow >
215+ < TableHead > Timestamp</ TableHead >
216+ < TableHead > Partition</ TableHead >
217+ < TableHead > Offset</ TableHead >
218+ < TableHead > Num Partitions</ TableHead >
219+ < TableHead > Path</ TableHead >
220+ </ TableRow >
221+ </ TableHeader >
222+ < TableBody className = "font-mono text-xs" >
223+ { saveHistoryQuery . data ?. map ( ( { workspace_snapshot } ) => (
224+ < TableRow key = { workspace_snapshot . id } >
225+ < TableCell >
226+ { prettyMilliseconds (
227+ Date . now ( ) - workspace_snapshot . timestamp . getTime ( ) ,
228+ ) }
229+ </ TableCell >
230+ < TableCell > { workspace_snapshot . partition } </ TableCell >
231+ < TableCell > { workspace_snapshot . offset } </ TableCell >
232+ < TableCell > { workspace_snapshot . numPartitions } </ TableCell >
233+ < TableCell > { workspace_snapshot . path } </ TableCell >
234+ </ TableRow >
235+ ) ) }
236+ </ TableBody >
237+ </ Table >
238+ </ div >
192239 </ CardContent >
193240 </ Card >
194241 </ div >
0 commit comments