@@ -64,16 +64,14 @@ const Render = memo<ArtifactProps>(({ identifier, title, type, language, childre
64
64
65
65
const inThread = useContext ( InPortalThreadContext ) ;
66
66
const { message } = App . useApp ( ) ;
67
- const [ isGenerating , isArtifactTagClosed , currentArtifactMessageId , openArtifact , closeArtifact ] =
68
- useChatStore ( ( s ) => {
69
- return [
70
- chatSelectors . isMessageGenerating ( id ) ( s ) ,
71
- chatPortalSelectors . isArtifactTagClosed ( id ) ( s ) ,
72
- chatPortalSelectors . artifactMessageId ( s ) ,
73
- s . openArtifact ,
74
- s . closeArtifact ,
75
- ] ;
76
- } ) ;
67
+ const [ isGenerating , isArtifactTagClosed , openArtifact , closeArtifact ] = useChatStore ( ( s ) => {
68
+ return [
69
+ chatSelectors . isMessageGenerating ( id ) ( s ) ,
70
+ chatPortalSelectors . isArtifactTagClosed ( id ) ( s ) ,
71
+ s . openArtifact ,
72
+ s . closeArtifact ,
73
+ ] ;
74
+ } ) ;
77
75
78
76
const openArtifactUI = ( ) => {
79
77
openArtifact ( { id, identifier, language, title, type } ) ;
@@ -86,52 +84,53 @@ const Render = memo<ArtifactProps>(({ identifier, title, type, language, childre
86
84
} , [ isGenerating , hasChildren , str , identifier , title , type , id , language ] ) ;
87
85
88
86
return (
89
- < p >
90
- < Flexbox
91
- className = { styles . container }
92
- gap = { 16 }
93
- onClick = { ( ) => {
94
- if ( currentArtifactMessageId === id ) {
95
- closeArtifact ( ) ;
96
- } else {
97
- if ( inThread ) {
98
- message . info ( t ( 'artifact.inThread' ) ) ;
99
- return ;
100
- }
101
- openArtifactUI ( ) ;
87
+ < Flexbox
88
+ className = { styles . container }
89
+ gap = { 16 }
90
+ onClick = { ( ) => {
91
+ const currentArtifactMessageId = chatPortalSelectors . artifactMessageId (
92
+ useChatStore . getState ( ) ,
93
+ ) ;
94
+ if ( currentArtifactMessageId === id ) {
95
+ closeArtifact ( ) ;
96
+ } else {
97
+ if ( inThread ) {
98
+ message . info ( t ( 'artifact.inThread' ) ) ;
99
+ return ;
102
100
}
103
- } }
104
- width = { '100%' }
105
- >
106
- < Flexbox align = { 'center' } flex = { 1 } horizontal >
107
- < Center className = { styles . avatar } height = { 64 } horizontal width = { 64 } >
108
- < ArtifactIcon type = { type } />
109
- </ Center >
110
- < Flexbox gap = { 4 } paddingBlock = { 8 } paddingInline = { 12 } >
111
- { ! title && isGenerating ? (
112
- < Flexbox className = { cx ( dotLoading ) } horizontal >
113
- { t ( 'artifact.generating' ) }
101
+ openArtifactUI ( ) ;
102
+ }
103
+ } }
104
+ width = { '100%' }
105
+ >
106
+ < Flexbox align = { 'center' } flex = { 1 } horizontal >
107
+ < Center className = { styles . avatar } height = { 64 } horizontal width = { 64 } >
108
+ < ArtifactIcon type = { type } />
109
+ </ Center >
110
+ < Flexbox gap = { 4 } paddingBlock = { 8 } paddingInline = { 12 } >
111
+ { ! title && isGenerating ? (
112
+ < Flexbox className = { cx ( dotLoading ) } horizontal >
113
+ { t ( 'artifact.generating' ) }
114
+ </ Flexbox >
115
+ ) : (
116
+ < Flexbox className = { cx ( styles . title ) } > { title || t ( 'artifact.unknownTitle' ) } </ Flexbox >
117
+ ) }
118
+ { hasChildren && (
119
+ < Flexbox className = { styles . desc } horizontal >
120
+ { identifier } ·{ ' ' }
121
+ < Flexbox gap = { 2 } horizontal >
122
+ { ! isArtifactTagClosed && (
123
+ < div >
124
+ < Icon icon = { Loader2 } spin />
125
+ </ div >
126
+ ) }
127
+ { str ?. length }
114
128
</ Flexbox >
115
- ) : (
116
- < Flexbox className = { cx ( styles . title ) } > { title || t ( 'artifact.unknownTitle' ) } </ Flexbox >
117
- ) }
118
- { hasChildren && (
119
- < Flexbox className = { styles . desc } horizontal >
120
- { identifier } ·{ ' ' }
121
- < Flexbox gap = { 2 } horizontal >
122
- { ! isArtifactTagClosed && (
123
- < div >
124
- < Icon icon = { Loader2 } spin />
125
- </ div >
126
- ) }
127
- { str ?. length }
128
- </ Flexbox >
129
- </ Flexbox >
130
- ) }
131
- </ Flexbox >
129
+ </ Flexbox >
130
+ ) }
132
131
</ Flexbox >
133
132
</ Flexbox >
134
- </ p >
133
+ </ Flexbox >
135
134
) ;
136
135
} ) ;
137
136
0 commit comments