11<template >
2- <div class =" tool" >
3- <div >{{ displayName }}</div >
4- <markdown
5- v-if =" toolCall.toolName === 'run_query'"
6- :content =" '```sql\n' + toolCall.args.query + '\n```'"
7- />
2+ <div class =" tool" :data-tool-name =" toolCall.toolName" :data-tool-state =" toolCall.state"
3+ :data-tool-empty-result =" isEmptyResult" >
4+ <div class =" tool-name" >{{ displayName }}</div >
5+ <markdown v-if =" toolCall.toolName === 'run_query'" :content =" '```sql\n' + toolCall.args.query + '\n```'" />
86 <div v-if =" askingPermission" >
97 {{
108 toolCall.toolName === "run_query"
2220 </button >
2321 </div >
2422 </div >
25- <div :class =" { error }" >
23+ <div :class =" { 'error tool-error': error }" >
2624 <template v-if =" error " >{{ error }}</template >
2725 <template v-else-if =" data " >
2826 <template v-if =" toolCall .toolName === ' get_connection_info' " >
3634 <template v-if =" toolCall .toolName === ' get_columns' " >
3735 {{ data.length }}
3836 {{ $pluralize("column", data.length) }}
39- (<code
40- v-if =" data.length < 5"
41- v-text =" data.map((c) => c.name).join(', ')"
42- />)
37+ (<code v-if =" data.length < 5" v-text =" data.map((c) => c.name).join(', ')" />)
4338 </template >
44- <run-query-result
45- v-else-if =" toolCall.toolName === 'run_query' && data"
46- :data =" data"
47- />
39+ <run-query-result v-else-if =" toolCall.toolName === 'run_query' && data" :data =" data" />
4840 </template >
4941 </div >
5042 </div >
5143</template >
5244
5345<script lang="ts">
5446import Markdown from " @/components/messages/Markdown.vue" ;
55- import { ToolCall } from " ai" ;
47+ import { ToolInvocation } from " ai" ;
5648import { PropType } from " vue" ;
5749import { safeJSONStringify } from " @/utils" ;
5850import RunQueryResult from " @/components/messages/tool/RunQueryResult.vue" ;
@@ -64,12 +56,22 @@ export default {
6456 props: {
6557 askingPermission: Boolean ,
6658 toolCall: {
67- type: Object as PropType <ToolCall < string , any > >,
59+ type: Object as PropType <ToolInvocation >,
6860 required: true ,
6961 },
7062 },
7163 emits: [" accept" , " reject" ],
7264 computed: {
65+ isEmptyResult() {
66+ if (this .toolCall .state === " result" ) {
67+ return _ .isEmpty (
68+ this .toolCall .toolName === " run_query"
69+ ? this .data .results ?.[0 ]?.rows
70+ : this .data ,
71+ );
72+ }
73+ return true ;
74+ },
7375 content() {
7476 if (this .data ) {
7577 let str = " " ;
0 commit comments