|
15 | 15 | * See the License for the specific language governing permissions and |
16 | 16 | * limitations under the License. |
17 | 17 | */ |
18 | | -import { Collapse, Tag } from 'antd'; |
| 18 | +import { Button, Collapse, Space, Tag } from 'antd'; |
| 19 | +import { Link } from 'react-router-dom'; |
19 | 20 | import { |
20 | 21 | CodeOutlined, |
21 | 22 | DatabaseOutlined, |
22 | 23 | BarChartOutlined, |
23 | 24 | DashboardOutlined, |
24 | 25 | SaveOutlined, |
25 | 26 | FunctionOutlined, |
| 27 | + EyeOutlined, |
26 | 28 | } from '@ant-design/icons'; |
27 | 29 | import type { ToolCall } from '../../types/ai'; |
28 | 30 | import type { ChatMessage } from '../../types/ai'; |
@@ -86,14 +88,29 @@ export default function ToolCallDisplay({ toolCalls, toolResults }: ToolCallDisp |
86 | 88 | <strong>Arguments:</strong> |
87 | 89 | <pre className="prospector-tool-json">{formatJson(tc.arguments)}</pre> |
88 | 90 | </div> |
89 | | - {result && ( |
90 | | - <div> |
91 | | - <strong>Result:</strong> |
92 | | - <pre className="prospector-tool-json"> |
93 | | - {formatJson(result.content || '')} |
94 | | - </pre> |
95 | | - </div> |
96 | | - )} |
| 91 | + {result && (() => { |
| 92 | + let parsed: Record<string, unknown> | null = null; |
| 93 | + try { parsed = JSON.parse(result.content || ''); } catch { /* ignore */ } |
| 94 | + const viewPath = parsed?.viewPath as string | undefined; |
| 95 | + const hasError = !!parsed?.error; |
| 96 | + return ( |
| 97 | + <div> |
| 98 | + <strong>Result:</strong> |
| 99 | + <pre className="prospector-tool-json"> |
| 100 | + {formatJson(result.content || '')} |
| 101 | + </pre> |
| 102 | + {viewPath && !hasError && ( |
| 103 | + <Space style={{ marginTop: 8 }}> |
| 104 | + <Link to={viewPath}> |
| 105 | + <Button size="small" type="primary" icon={<EyeOutlined />}> |
| 106 | + View {tc.name === 'create_dashboard' ? 'Dashboards' : 'Visualizations'} |
| 107 | + </Button> |
| 108 | + </Link> |
| 109 | + </Space> |
| 110 | + )} |
| 111 | + </div> |
| 112 | + ); |
| 113 | + })()} |
97 | 114 | </div> |
98 | 115 | ), |
99 | 116 | }; |
|
0 commit comments