Skip to content

Commit 21bc8c5

Browse files
committed
fix(flow-chat): Clarify file edit guidance errors
Edit failures such as old_string mismatches can be handled by the agent. The action-required labels and warning icon misleadingly suggested that users needed to intervene. - Remove guidance labels and the header warning icon from file cards. - Preserve error details for manual expansion and ordinary failure UI. - Limit error details to 20rem with vertical scrolling for long output. - Remove unused translations and update guidance rendering assertions.
1 parent 9f2f576 commit 21bc8c5

7 files changed

Lines changed: 20 additions & 16 deletions

File tree

design-system/packages/ui/src/flow-chat/tool-cards/FileOperationToolCard.module.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
}
8282

8383
.errorMessage {
84+
max-block-size: 20rem;
85+
overflow-y: auto;
8486
color: var(--openbitfun-color-content-muted);
8587
white-space: pre-wrap;
8688
overflow-wrap: anywhere;

design-system/packages/ui/src/flow-chat/tool-cards/FileOperationToolCard.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface FileOperationToolCardAction {
3939
export interface FileOperationToolCardError {
4040
guidance?: boolean;
4141
message: ReactNode;
42-
title: ReactNode;
42+
title?: ReactNode;
4343
}
4444

4545
export interface FileOperationToolCardProps
@@ -146,10 +146,12 @@ export function FileOperationToolCard({
146146

147147
const errorContent = error ? (
148148
<div className={styles.error} data-guidance={error.guidance ? "true" : "false"}>
149-
<div className={styles.errorTitle}>
150-
{error.guidance ? <Info aria-hidden="true" /> : <XCircle aria-hidden="true" />}
151-
<span>{error.title}</span>
152-
</div>
149+
{error.title != null && (
150+
<div className={styles.errorTitle}>
151+
{error.guidance ? <Info aria-hidden="true" /> : <XCircle aria-hidden="true" />}
152+
<span>{error.title}</span>
153+
</div>
154+
)}
153155
<div className={styles.errorMessage}>{error.message}</div>
154156
</div>
155157
) : undefined;
@@ -211,7 +213,7 @@ export function FileOperationToolCard({
211213
/>
212214
) : undefined}
213215
icon={<Icon aria-hidden="true" />}
214-
statusIcon={failed
216+
statusIcon={failed && !error?.guidance
215217
? (
216218
<TriangleAlert
217219
aria-hidden="true"

src/web-ui/src/flow_chat/tool-cards/FileOperationToolCard.test.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,8 @@ describe('FileOperationToolCard', () => {
877877
);
878878
});
879879

880-
expect(container.textContent).toContain('toolCards.file.guidanceHint');
880+
expect(container.textContent).not.toContain('toolCards.file.guidanceHint');
881+
expect(container.querySelector('[data-openbitfun-icon="warning"]')).toBeNull();
881882
expect(container.textContent).not.toContain('toolCards.file.failed');
882883
expect(container.textContent).toContain('report.md');
883884
expect(container.textContent).not.toContain(
@@ -894,6 +895,8 @@ describe('FileOperationToolCard', () => {
894895
'Use Read to load the current contents of docs/report.md before calling Write on it.',
895896
);
896897
expect(container.querySelector('[data-openbitfun-part="error"] [data-guidance="true"]')).not.toBeNull();
898+
expect(container.textContent).not.toContain('toolCards.file.guidanceTitle');
899+
expect(container.querySelector('[data-openbitfun-icon="warning"]')).toBeNull();
897900
});
898901

899902
it('renders edit guardrail blocks as guidance instead of hard failure', async () => {
@@ -938,7 +941,8 @@ describe('FileOperationToolCard', () => {
938941
);
939942
});
940943

941-
expect(container.textContent).toContain('toolCards.file.guidanceHint');
944+
expect(container.textContent).not.toContain('toolCards.file.guidanceHint');
945+
expect(container.querySelector('[data-openbitfun-icon="warning"]')).toBeNull();
942946
expect(container.textContent).not.toContain('toolCards.file.failed');
943947
expect(container.textContent).toContain('main.rs');
944948
expect(container.textContent).not.toContain(
@@ -955,6 +959,8 @@ describe('FileOperationToolCard', () => {
955959
'Use Read to load the current contents of src/main.rs before calling Edit on it.',
956960
);
957961
expect(container.querySelector('[data-openbitfun-part="error"] [data-guidance="true"]')).not.toBeNull();
962+
expect(container.textContent).not.toContain('toolCards.file.guidanceTitle');
963+
expect(container.querySelector('[data-openbitfun-icon="warning"]')).toBeNull();
958964
});
959965

960966
it('shows receiving content label while write content streams before file_path', async () => {

src/web-ui/src/flow_chat/tool-cards/FileOperationToolCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ const GenericFileOperationToolCard: React.FC<FileOperationToolCardProps> = ({
808808
? `${t('toolCards.file.delete')}${isFailed ? t('toolCards.file.failed') : ''}`
809809
: isFailed
810810
? isFileGuidanceBlocked
811-
? `${toolDisplayName}${t('toolCards.file.guidanceHint')}`
811+
? `${toolDisplayName}:`
812812
: `${toolDisplayName}${t('toolCards.file.failed')}`
813813
: `${toolDisplayName}:`;
814814

@@ -838,7 +838,7 @@ const GenericFileOperationToolCard: React.FC<FileOperationToolCardProps> = ({
838838
guidance: isFileGuidanceBlocked,
839839
message: getDisplayMessage(),
840840
title: isFileGuidanceBlocked
841-
? t('toolCards.file.guidanceTitle')
841+
? undefined
842842
: `${toolDisplayName}${t('toolCards.file.failed')}`,
843843
} : undefined}
844844
isExpanded={isCardContentExpanded}

src/web-ui/src/locales/en-US/flow-chat.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,8 +1636,6 @@
16361636
"delete": "Delete File",
16371637
"deletedLabel": "Deleted",
16381638
"failed": "Failed",
1639-
"guidanceHint": " · Needs attention",
1640-
"guidanceTitle": "Action required before retrying",
16411639
"parsingPath": "Parsing file path...",
16421640
"receivingContent": "Receiving file content...",
16431641
"unknownFile": "Unknown file",

src/web-ui/src/locales/zh-CN/flow-chat.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,8 +1636,6 @@
16361636
"delete": "删除文件",
16371637
"deletedLabel": "删除",
16381638
"failed": "失败",
1639-
"guidanceHint": " · 需要处理",
1640-
"guidanceTitle": "重试前需要处理",
16411639
"parsingPath": "解析文件路径中...",
16421640
"receivingContent": "接收文件内容中...",
16431641
"unknownFile": "未知文件",

src/web-ui/src/locales/zh-TW/flow-chat.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,8 +1636,6 @@
16361636
"delete": "刪除檔案",
16371637
"deletedLabel": "刪除",
16381638
"failed": "失敗",
1639-
"guidanceHint": " · 需要處理",
1640-
"guidanceTitle": "重試前需要處理",
16411639
"parsingPath": "解析檔案路徑中...",
16421640
"receivingContent": "接收檔案內容中...",
16431641
"unknownFile": "未知檔案",

0 commit comments

Comments
 (0)