Skip to content

fix(frontend): fix multiple UI bugs and improve robustness#2664

Open
zhoufengen wants to merge 1 commit intobytedance:mainfrom
zhoufengen:fix/frontend-bug-fixes
Open

fix(frontend): fix multiple UI bugs and improve robustness#2664
zhoufengen wants to merge 1 commit intobytedance:mainfrom
zhoufengen:fix/frontend-bug-fixes

Conversation

@zhoufengen
Copy link
Copy Markdown

Summary

This PR fixes several frontend bugs and improves code robustness across the workspace components and core modules.

Changes

Bug Fixes

  1. Null guard in useRenameThread (core/threads/hooks.ts)

    • The onSuccess callback called oldData.map() without checking for null, which would crash if the query cache was empty.
    • Added the same if (oldData == null) { return oldData; } guard already used in useDeleteThread.
  2. Response check in loadArtifactContent (core/artifacts/loader.ts)

    • fetch() result was read with response.text() without checking response.ok, which could display error HTML as artifact content.
    • Added if (!response.ok) check that throws a descriptive error.
  3. Clipboard API error handling in CopyButton (components/workspace/copy-button.tsx)

    • navigator.clipboard.writeText() was fire-and-forget (void), so the "copied" indicator would show even if the write failed.
    • Now awaits the promise in a try/catch and only shows the copied state on success.

Accessibility

  1. Invalid ARIA roles in message skeleton (components/workspace/messages/skeleton.tsx)
    • role="human-message" and role="assistant-message" are not valid WAI-ARIA role values.
    • Replaced with data-role attributes to preserve the semantic intent without violating the spec.

UI

  1. Dark mode support in TodoList (components/workspace/todo-list.tsx)
    • Hardcoded bg-white broke dark mode rendering.
    • Replaced with bg-background, the theme-aware class used throughout the workspace.

Code Quality

  1. Remove console.log from production code (core/config/index.ts, core/api/api-client.ts)
    • Removed debug console.log statements that would output to the browser console in production.

Testing

  • All changes are minimal and focused on correctness.
  • Each fix follows existing patterns already established in the codebase.

- Add null guard in useRenameThread to prevent runtime crash when
  query cache is empty, matching existing pattern in useDeleteThread
- Check response.ok in loadArtifactContent before reading body to
  avoid displaying error HTML as artifact content
- Handle clipboard API failure in CopyButton to avoid showing false
  "copied" state
- Replace invalid ARIA roles with data attributes in message skeleton
- Fix TodoList dark mode by replacing hardcoded bg-white with theme
  aware class
- Remove console.log statements from production code paths

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 30, 2026

CLA assistant check
All committers have signed the CLA.

@WillemJiang WillemJiang requested a review from Copilot May 4, 2026 00:55
@WillemJiang
Copy link
Copy Markdown
Collaborator

@zhoufengen, thanks for your contribution. Please fix the lint error.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses several small but user-visible frontend issues in the DeerFlow workspace UI and core client utilities, improving robustness and accessibility while removing stray debug logging.

Changes:

  • Hardened React Query cache updates (null/undefined guards) and artifact loading (response.ok check).
  • Improved clipboard copy UX by awaiting clipboard writes before showing the “copied” state.
  • Fixed UI/accessibility issues (dark-mode background class; replaced invalid ARIA roles with data attributes) and removed production console.logs.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
frontend/src/core/threads/hooks.ts Prevents potential crash when renaming if cached thread list is missing/undefined.
frontend/src/core/config/index.ts Removes debug logging from base URL resolution.
frontend/src/core/artifacts/loader.ts Throws a descriptive error when artifact fetch fails instead of treating error HTML as content.
frontend/src/core/api/api-client.ts Removes debug logging during API client creation.
frontend/src/components/workspace/todo-list.tsx Uses theme-aware bg-background to support dark mode.
frontend/src/components/workspace/messages/skeleton.tsx Replaces invalid role values with data-role attributes to avoid ARIA violations.
frontend/src/components/workspace/copy-button.tsx Awaits clipboard write and only shows “copied” state on success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants