Skip to content

Commit 945f93b

Browse files
wip
1 parent 7255033 commit 945f93b

File tree

12 files changed

+163
-209
lines changed

12 files changed

+163
-209
lines changed

packages/web/src/features/chat/agent.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,7 @@ const createAgentStream = async ({
231231
});
232232
} else if (toolName === grepDefinition.name) {
233233
output.metadata.files.forEach((file) => {
234-
onWriteSource({
235-
type: 'file',
236-
language: file.language,
237-
repo: file.repo,
238-
path: file.fileName,
239-
revision: file.revision,
240-
name: file.fileName.split('/').pop() ?? file.fileName,
241-
});
234+
onWriteSource(file);
242235
});
243236
} else if (toolName === findSymbolDefinitionsDefinition.name || toolName === findSymbolReferencesDefinition.name) {
244237
output.metadata.files.forEach((file) => {
@@ -308,7 +301,7 @@ const createPrompt = ({
308301
The user has explicitly selected the following repositories for analysis:
309302
${repos.map(repo => `- ${repo}`).join('\n')}
310303
311-
When calling tools that accept a \`repo\` parameter (e.g. \`read_file\`, \`list_commits\`, \`list_tree\`, \`grep\`), use these repository names directly.
304+
When calling tools that accept a \`repo\` parameter (e.g. \`read_file\`, \`list_commits\`, \`list_tree\`, \`grep\`), use these repository names exactly as listed above, including the full host prefix (e.g. \`github.com/org/repo\`).
312305
</selected_repositories>
313306
` : ''}
314307

packages/web/src/features/chat/components/chatThread/tools/findSymbolDefinitionsToolComponent.tsx

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

33
import { FindSymbolDefinitionsToolUIPart } from "@/features/chat/tools";
4-
import { isServiceError } from "@/lib/utils";
54
import { useMemo, useState } from "react";
65
import { FileListItem, ToolHeader, TreeList } from "./shared";
76
import { CodeSnippet } from "@/app/components/codeSnippet";
@@ -29,38 +28,30 @@ export const FindSymbolDefinitionsToolComponent = ({ part }: { part: FindSymbolD
2928
<div className="my-4">
3029
<ToolHeader
3130
isLoading={part.state !== 'output-available' && part.state !== 'output-error'}
32-
isError={part.state === 'output-error' || (part.state === 'output-available' && isServiceError(part.output))}
31+
isError={part.state === 'output-error'}
3332
isExpanded={isExpanded}
3433
label={label}
3534
Icon={BookOpenIcon}
3635
onExpand={setIsExpanded}
3736
input={part.state !== 'input-streaming' ? JSON.stringify(part.input) : undefined}
38-
output={part.state === 'output-available' && !isServiceError(part.output) ? part.output.output : undefined}
37+
output={part.state === 'output-available' ? part.output.output : undefined}
3938
/>
4039
{part.state === 'output-available' && isExpanded && (
4140
<>
42-
{isServiceError(part.output) ? (
41+
{part.output.metadata.files.length === 0 ? (
42+
<span className="text-sm text-muted-foreground ml-[25px]">No matches found</span>
43+
) : (
4344
<TreeList>
44-
<span>Failed with the following error: <CodeSnippet className="text-sm text-destructive">{part.output.message}</CodeSnippet></span>
45+
{part.output.metadata.files.map((file) => {
46+
return (
47+
<FileListItem
48+
key={file.fileName}
49+
path={file.fileName}
50+
repoName={file.repo}
51+
/>
52+
)
53+
})}
4554
</TreeList>
46-
) : (
47-
<>
48-
{part.output.metadata.files.length === 0 ? (
49-
<span className="text-sm text-muted-foreground ml-[25px]">No matches found</span>
50-
) : (
51-
<TreeList>
52-
{part.output.metadata.files.map((file) => {
53-
return (
54-
<FileListItem
55-
key={file.fileName}
56-
path={file.fileName}
57-
repoName={file.repo}
58-
/>
59-
)
60-
})}
61-
</TreeList>
62-
)}
63-
</>
6455
)}
6556
<Separator className='ml-[7px] my-2' />
6657
</>

packages/web/src/features/chat/components/chatThread/tools/findSymbolReferencesToolComponent.tsx

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

33
import { FindSymbolReferencesToolUIPart } from "@/features/chat/tools";
4-
import { isServiceError } from "@/lib/utils";
54
import { useMemo, useState } from "react";
65
import { FileListItem, ToolHeader, TreeList } from "./shared";
76
import { CodeSnippet } from "@/app/components/codeSnippet";
@@ -29,38 +28,30 @@ export const FindSymbolReferencesToolComponent = ({ part }: { part: FindSymbolRe
2928
<div className="my-4">
3029
<ToolHeader
3130
isLoading={part.state !== 'output-available' && part.state !== 'output-error'}
32-
isError={part.state === 'output-error' || (part.state === 'output-available' && isServiceError(part.output))}
31+
isError={part.state === 'output-error'}
3332
isExpanded={isExpanded}
3433
label={label}
3534
Icon={BookOpenIcon}
3635
onExpand={setIsExpanded}
3736
input={part.state !== 'input-streaming' ? JSON.stringify(part.input) : undefined}
38-
output={part.state === 'output-available' && !isServiceError(part.output) ? part.output.output : undefined}
37+
output={part.state === 'output-available' ? part.output.output : undefined}
3938
/>
4039
{part.state === 'output-available' && isExpanded && (
4140
<>
42-
{isServiceError(part.output) ? (
41+
{part.output.metadata.files.length === 0 ? (
42+
<span className="text-sm text-muted-foreground ml-[25px]">No matches found</span>
43+
) : (
4344
<TreeList>
44-
<span>Failed with the following error: <CodeSnippet className="text-sm text-destructive">{part.output.message}</CodeSnippet></span>
45+
{part.output.metadata.files.map((file) => {
46+
return (
47+
<FileListItem
48+
key={file.fileName}
49+
path={file.fileName}
50+
repoName={file.repo}
51+
/>
52+
)
53+
})}
4554
</TreeList>
46-
) : (
47-
<>
48-
{part.output.metadata.files.length === 0 ? (
49-
<span className="text-sm text-muted-foreground ml-[25px]">No matches found</span>
50-
) : (
51-
<TreeList>
52-
{part.output.metadata.files.map((file) => {
53-
return (
54-
<FileListItem
55-
key={file.fileName}
56-
path={file.fileName}
57-
repoName={file.repo}
58-
/>
59-
)
60-
})}
61-
</TreeList>
62-
)}
63-
</>
6455
)}
6556
<Separator className='ml-[7px] my-2' />
6657
</>

packages/web/src/features/chat/components/chatThread/tools/grepToolComponent.tsx

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

33
import { GrepToolUIPart } from "@/features/chat/tools";
4-
import { isServiceError } from "@/lib/utils";
54
import { useMemo, useState } from "react";
65
import { FileListItem, ToolHeader, TreeList } from "./shared";
76
import { CodeSnippet } from "@/app/components/codeSnippet";
@@ -35,38 +34,30 @@ export const GrepToolComponent = ({ part }: { part: GrepToolUIPart }) => {
3534
<div className="my-4">
3635
<ToolHeader
3736
isLoading={part.state !== 'output-available' && part.state !== 'output-error'}
38-
isError={part.state === 'output-error' || (part.state === 'output-available' && isServiceError(part.output))}
37+
isError={part.state === 'output-error'}
3938
isExpanded={isExpanded}
4039
label={label}
4140
Icon={SearchIcon}
4241
onExpand={setIsExpanded}
43-
input={part.state !== 'input-streaming' ? JSON.stringify(part.input) : undefined}
44-
output={part.state === 'output-available' && !isServiceError(part.output) ? part.output.output : undefined}
42+
input={part.state !== 'input-streaming' ? `${JSON.stringify(part.input, null, 2)}\n\nQuery: ${part.output?.metadata.query ?? ''}` : undefined}
43+
output={part.state === 'output-available' ? part.output.output : undefined}
4544
/>
4645
{part.state === 'output-available' && isExpanded && (
4746
<>
48-
{isServiceError(part.output) ? (
47+
{part.output.metadata.files.length === 0 ? (
48+
<span className="text-sm text-muted-foreground ml-[25px]">No matches found</span>
49+
) : (
4950
<TreeList>
50-
<span>Failed with the following error: <CodeSnippet className="text-sm text-destructive">{part.output.message}</CodeSnippet></span>
51+
{part.output.metadata.files.map((file) => {
52+
return (
53+
<FileListItem
54+
key={file.path}
55+
path={file.name}
56+
repoName={file.repo}
57+
/>
58+
)
59+
})}
5160
</TreeList>
52-
) : (
53-
<>
54-
{part.output.metadata.files.length === 0 ? (
55-
<span className="text-sm text-muted-foreground ml-[25px]">No matches found</span>
56-
) : (
57-
<TreeList>
58-
{part.output.metadata.files.map((file) => {
59-
return (
60-
<FileListItem
61-
key={file.fileName}
62-
path={file.fileName}
63-
repoName={file.repo}
64-
/>
65-
)
66-
})}
67-
</TreeList>
68-
)}
69-
</>
7061
)}
7162
<Separator className='ml-[7px] my-2' />
7263
</>

packages/web/src/features/chat/components/chatThread/tools/listCommitsToolComponent.tsx

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

33
import { ListCommitsToolUIPart } from "@/features/chat/tools";
4-
import { isServiceError } from "@/lib/utils";
54
import { useMemo, useState } from "react";
65
import { ToolHeader, TreeList } from "./shared";
76
import { CodeSnippet } from "@/app/components/codeSnippet";
@@ -27,59 +26,51 @@ export const ListCommitsToolComponent = ({ part }: { part: ListCommitsToolUIPart
2726
<div className="my-4">
2827
<ToolHeader
2928
isLoading={part.state !== 'output-available' && part.state !== 'output-error'}
30-
isError={part.state === 'output-error' || (part.state === 'output-available' && isServiceError(part.output))}
29+
isError={part.state === 'output-error'}
3130
isExpanded={isExpanded}
3231
label={label}
3332
Icon={GitCommitVerticalIcon}
3433
onExpand={setIsExpanded}
3534
input={part.state !== 'input-streaming' ? JSON.stringify(part.input) : undefined}
36-
output={part.state === 'output-available' && !isServiceError(part.output) ? part.output.output : undefined}
35+
output={part.state === 'output-available' ? part.output.output : undefined}
3736
/>
3837
{part.state === 'output-available' && isExpanded && (
3938
<>
40-
{isServiceError(part.output) ? (
41-
<TreeList>
42-
<span>Failed with the following error: <CodeSnippet className="text-sm text-destructive">{part.output.message}</CodeSnippet></span>
43-
</TreeList>
39+
{part.output.metadata.commits.length === 0 ? (
40+
<span className="text-sm text-muted-foreground ml-[25px]">No commits found</span>
4441
) : (
45-
<>
46-
{part.output.metadata.commits.length === 0 ? (
47-
<span className="text-sm text-muted-foreground ml-[25px]">No commits found</span>
48-
) : (
49-
<TreeList>
50-
<div className="text-sm text-muted-foreground mb-2">
51-
Found {part.output.metadata.commits.length} of {part.output.metadata.totalCount} total commits:
52-
</div>
53-
{part.output.metadata.commits.map((commit) => (
54-
<div key={commit.hash} className="mb-3 last:mb-0">
55-
<div className="flex items-start gap-2 text-sm">
56-
<GitCommitVerticalIcon className="h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0" />
57-
<div className="flex-1 min-w-0">
58-
<div className="flex items-center gap-2 flex-wrap">
59-
<CodeSnippet className="text-xs font-mono">
60-
{commit.hash.substring(0, 7)}
61-
</CodeSnippet>
62-
{commit.refs && (
63-
<span className="text-xs text-muted-foreground">
64-
{commit.refs}
65-
</span>
66-
)}
67-
</div>
68-
<div className="mt-1 font-medium">
69-
{commit.message}
70-
</div>
71-
<div className="flex items-center gap-2 mt-1 text-xs text-muted-foreground">
72-
<span>{commit.author_name}</span>
73-
<span></span>
74-
<span>{new Date(commit.date).toLocaleString()}</span>
75-
</div>
76-
</div>
42+
<TreeList>
43+
<div className="text-sm text-muted-foreground mb-2">
44+
Found {part.output.metadata.commits.length} of {part.output.metadata.totalCount} total commits:
45+
</div>
46+
{part.output.metadata.commits.map((commit) => (
47+
<div key={commit.hash} className="mb-3 last:mb-0">
48+
<div className="flex items-start gap-2 text-sm">
49+
<GitCommitVerticalIcon className="h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0" />
50+
<div className="flex-1 min-w-0">
51+
<div className="flex items-center gap-2 flex-wrap">
52+
<CodeSnippet className="text-xs font-mono">
53+
{commit.hash.substring(0, 7)}
54+
</CodeSnippet>
55+
{commit.refs && (
56+
<span className="text-xs text-muted-foreground">
57+
{commit.refs}
58+
</span>
59+
)}
60+
</div>
61+
<div className="mt-1 font-medium">
62+
{commit.message}
63+
</div>
64+
<div className="flex items-center gap-2 mt-1 text-xs text-muted-foreground">
65+
<span>{commit.author_name}</span>
66+
<span></span>
67+
<span>{new Date(commit.date).toLocaleString()}</span>
7768
</div>
7869
</div>
79-
))}
80-
</TreeList>
81-
)}
82-
</>
70+
</div>
71+
</div>
72+
))}
73+
</TreeList>
8374
)}
8475
<Separator className='ml-[7px] my-2' />
8576
</>

0 commit comments

Comments
 (0)