@@ -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,34 @@ 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
+ className = "cursor pointer w-fit border py-2 px-3 rounded-xl flex flex-row items-start justify-between gap-3"
90
+ onClick = { ( event ) => {
91
+ const rect = event . currentTarget . getBoundingClientRect ( ) ;
92
+
93
+ const boundingBox = {
94
+ top : rect . top ,
95
+ left : rect . left ,
96
+ width : rect . width ,
97
+ height : rect . height ,
98
+ } ;
99
+
100
+ setBlock ( ( currentBlock ) => ( {
101
+ ...currentBlock ,
102
+ isVisible : true ,
103
+ boundingBox,
104
+ } ) ) ;
105
+ } }
106
+ >
80
107
< div className = "flex flex-row gap-3 items-start" >
81
108
< div className = "text-zinc-500 mt-1" >
82
109
{ type === 'create' ? (
@@ -88,12 +115,12 @@ export function DocumentToolCall({ type, args }: DocumentToolCallProps) {
88
115
) : null }
89
116
</ div >
90
117
91
- < div className = "" >
92
- { getActionText ( type ) } { args . title }
118
+ < div className = "text-left " >
119
+ { ` ${ getActionText ( type , 'present' ) } " $ {args . title } "` }
93
120
</ div >
94
121
</ div >
95
122
96
123
< div className = "animate-spin mt-1" > { < LoaderIcon /> } </ div >
97
- </ div >
124
+ </ button >
98
125
) ;
99
126
}
0 commit comments