@@ -17,15 +17,17 @@ import {
17
17
DialogTitle ,
18
18
} from "@/components/ui/dialog" ;
19
19
import { toast } from "@/components/ui/use-toast" ;
20
+ import { cplxApiQueries } from "@/services/cplx-api/query-keys" ;
20
21
import { PluginsStatesService } from "@/services/plugins-states/plugins-states" ;
21
22
import { PplxApiService } from "@/services/pplx-api/pplx-api" ;
22
- import { fetchResource } from "@/utils/utils" ;
23
+ import { unixTimestampToDate } from "@/utils/dayjs" ;
24
+ import { fetchResource , setCookie } from "@/utils/utils" ;
23
25
24
26
function CanvasPrePromptInstallationDialog ( ) {
25
27
const navigate = useNavigate ( ) ;
26
28
27
29
const {
28
- data : canvasInstructionClaudeMd ,
30
+ data : canvasInstruction ,
29
31
isError,
30
32
isFetching,
31
33
} = useQuery ( {
@@ -46,6 +48,12 @@ function CanvasPrePromptInstallationDialog() {
46
48
description : "The Canvas Pre-Prompt has been installed as a Space." ,
47
49
} ) ;
48
50
51
+ setCookie (
52
+ `pplx.source-selection-v3-space-${ data . uuid } ` ,
53
+ JSON . stringify ( [ ] ) ,
54
+ 365 ,
55
+ ) ;
56
+
49
57
sendMessage (
50
58
"spa-router:push" ,
51
59
{
@@ -64,6 +72,8 @@ function CanvasPrePromptInstallationDialog() {
64
72
} ,
65
73
} ) ;
66
74
75
+ const { data : versions } = useQuery ( cplxApiQueries . versions ) ;
76
+
67
77
return (
68
78
< Dialog
69
79
defaultOpen = { true }
@@ -85,53 +95,63 @@ function CanvasPrePromptInstallationDialog() {
85
95
< div className = "tw-text-sm tw-text-muted-foreground" >
86
96
For reference, here is the prompt:
87
97
</ div >
88
- { canvasInstructionClaudeMd && (
89
- < div className = "tw-max-h-[500px] tw-overflow-y-auto tw-whitespace-pre-line tw-rounded-md tw-border tw-border-border/50 tw-bg-secondary tw-p-4 tw-text-sm tw-text-secondary-foreground" >
90
- < CopyButton
91
- className = "tw-float-right"
92
- content = { canvasInstructionClaudeMd }
93
- />
94
- { canvasInstructionClaudeMd }
95
- </ div >
96
- ) }
97
- { isFetching && ! canvasInstructionClaudeMd && (
98
- < div className = "tw-flex tw-flex-col tw-gap-2" >
99
- < p className = "tw-text-sm tw-text-muted-foreground" >
100
- Fetching the Canvas Pre-Prompt, please wait...
101
- </ p >
102
- </ div >
103
- ) }
104
- { isError && (
105
- < div className = "tw-flex tw-flex-col tw-gap-2" >
106
- < p className = "tw-text-sm tw-text-muted-foreground" >
107
- Failed to fetch the Canvas Pre-Prompt.
108
- </ p >
109
- </ div >
110
- ) }
98
+ < div className = "tw-h-[500px] tw-max-h-[500px] tw-overflow-y-auto tw-whitespace-pre-line tw-rounded-md tw-border tw-border-border/50 tw-bg-secondary tw-p-4 tw-text-sm tw-text-secondary-foreground" >
99
+ { isFetching && ! canvasInstruction && (
100
+ < div className = "tw-flex tw-flex-col tw-gap-2" >
101
+ < p className = "tw-text-sm tw-text-muted-foreground" >
102
+ Fetching the Canvas Pre-Prompt, please wait...
103
+ </ p >
104
+ </ div >
105
+ ) }
106
+ { isError && (
107
+ < div className = "tw-flex tw-flex-col tw-gap-2" >
108
+ < p className = "tw-text-sm tw-text-muted-foreground" >
109
+ Failed to fetch the Canvas Pre-Prompt.
110
+ </ p >
111
+ </ div >
112
+ ) }
113
+ { canvasInstruction && (
114
+ < >
115
+ < CopyButton
116
+ className = "tw-float-right"
117
+ content = { canvasInstruction }
118
+ />
119
+ { canvasInstruction }
120
+ </ >
121
+ ) }
122
+ </ div >
111
123
</ div >
124
+ { versions ?. canvasInstructionLastUpdated != null && (
125
+ < div className = "tw-text-sm tw-text-muted-foreground" >
126
+ Last updated:{ " " }
127
+ { unixTimestampToDate ( {
128
+ unixTimestamp : versions . canvasInstructionLastUpdated ,
129
+ } ) }
130
+ </ div >
131
+ ) }
112
132
< DialogFooter >
113
- < DialogClose asChild >
133
+ < DialogClose asChild tabIndex = { - 1 } >
114
134
< Button variant = "outline" > Cancel</ Button >
115
135
</ DialogClose >
116
136
< AsyncButton
117
- disabled = { isFetching || ! canvasInstructionClaudeMd }
137
+ disabled = { isFetching || ! canvasInstruction }
118
138
loadingText = {
119
139
< div className = "tw-flex tw-items-center tw-gap-2" >
120
140
< LuLoaderCircle className = "tw-animate-spin" />
121
141
< span > Installing...</ span >
122
142
</ div >
123
143
}
124
144
onClick = { async ( ) => {
125
- if ( ! canvasInstructionClaudeMd ) {
145
+ if ( ! canvasInstruction ) {
126
146
return ;
127
147
}
128
148
129
149
await createSpace ( {
130
150
title : "CPLX Canvas" ,
131
151
description : "" ,
132
152
emoji : "1f5bc-fe0f" ,
133
- instructions : canvasInstructionClaudeMd ,
134
- model_selection : null ,
153
+ instructions : canvasInstruction ,
154
+ model_selection : "claude2" ,
135
155
} ) ;
136
156
} }
137
157
>
0 commit comments