@@ -3,14 +3,19 @@ import type { SetStateAction } from 'react';
3
3
import type { UIBlock } from './block' ;
4
4
import { FileIcon , LoaderIcon , MessageIcon , PencilEditIcon } from './icons' ;
5
5
6
- const getActionText = ( type : 'create' | 'update' | 'request-suggestions' ) => {
6
+ const getActionText = (
7
+ type : 'create' | 'update' | 'request-suggestions' ,
8
+ tense : 'present' | 'past' ,
9
+ ) => {
7
10
switch ( type ) {
8
11
case 'create' :
9
- return ' Creating';
12
+ return tense === 'present' ? ' Creating' : 'Created ';
10
13
case 'update' :
11
- return ' Updating';
14
+ return tense === 'present' ? ' Updating' : 'Updated ';
12
15
case 'request-suggestions' :
13
- return 'Adding suggestions' ;
16
+ return tense === 'present'
17
+ ? 'Adding suggestions'
18
+ : 'Added suggestions to' ;
14
19
default :
15
20
return null ;
16
21
}
@@ -26,7 +31,6 @@ interface DocumentToolResultProps {
26
31
export function DocumentToolResult ( {
27
32
type,
28
33
result,
29
- block,
30
34
setBlock,
31
35
} : DocumentToolResultProps ) {
32
36
return (
@@ -62,8 +66,8 @@ export function DocumentToolResult({
62
66
< MessageIcon />
63
67
) : null }
64
68
</ div >
65
- < div className = "" >
66
- { getActionText ( type ) } { result . title }
69
+ < div className = "text-left " >
70
+ { ` ${ getActionText ( type , 'past' ) } " $ {result . title } "` }
67
71
</ div >
68
72
</ button >
69
73
) ;
@@ -72,11 +76,35 @@ export function DocumentToolResult({
72
76
interface DocumentToolCallProps {
73
77
type : 'create' | 'update' | 'request-suggestions' ;
74
78
args : { title : string } ;
79
+ setBlock : ( value : SetStateAction < UIBlock > ) => void ;
75
80
}
76
81
77
- export function DocumentToolCall ( { type, args } : DocumentToolCallProps ) {
82
+ export function DocumentToolCall ( {
83
+ type,
84
+ args,
85
+ setBlock,
86
+ } : DocumentToolCallProps ) {
78
87
return (
79
- < div className = "w-fit border py-2 px-3 rounded-xl flex flex-row items-start justify-between gap-3" >
88
+ < button
89
+ type = "button"
90
+ className = "cursor pointer w-fit border py-2 px-3 rounded-xl flex flex-row items-start justify-between gap-3"
91
+ onClick = { ( event ) => {
92
+ const rect = event . currentTarget . getBoundingClientRect ( ) ;
93
+
94
+ const boundingBox = {
95
+ top : rect . top ,
96
+ left : rect . left ,
97
+ width : rect . width ,
98
+ height : rect . height ,
99
+ } ;
100
+
101
+ setBlock ( ( currentBlock ) => ( {
102
+ ...currentBlock ,
103
+ isVisible : true ,
104
+ boundingBox,
105
+ } ) ) ;
106
+ } }
107
+ >
80
108
< div className = "flex flex-row gap-3 items-start" >
81
109
< div className = "text-zinc-500 mt-1" >
82
110
{ type === 'create' ? (
@@ -88,12 +116,12 @@ export function DocumentToolCall({ type, args }: DocumentToolCallProps) {
88
116
) : null }
89
117
</ div >
90
118
91
- < div className = "" >
92
- { getActionText ( type ) } { args . title }
119
+ < div className = "text-left " >
120
+ { ` ${ getActionText ( type , 'present' ) } $ {args . title ? `" ${ args . title } "` : '' } ` }
93
121
</ div >
94
122
</ div >
95
123
96
124
< div className = "animate-spin mt-1" > { < LoaderIcon /> } </ div >
97
- </ div >
125
+ </ button >
98
126
) ;
99
127
}
0 commit comments