Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Overview

This PR implements user-facing error message display for the chat functionality, addressing the TODO comment in the chat form that previously only logged errors to the console.

Changes

Previously, when the AI chat action encountered an error, it was only logged to the console and users received no feedback. This PR adds a visible error message display area in the chat form UI.

Implementation Details

  1. Error State Management: Added errorMessage state to the ChatForm component to track error messages returned from askAI()

  2. Error Display UI: Added a new error message display area positioned between the close button (閉じる) and send button (➤). The error message:

    • Appears conditionally only when an error exists
    • Uses red text for visibility
    • Centers in the available space using flexbox
    • Automatically clears when a new question is submitted
  3. Error Handling Flow: Updated the handleSubmit function to properly set and clear error messages instead of creating unused error message objects

Visual Layout

[ 閉じる ]  [ Error message appears here in red ]  [ ➤ ]

Testing

  • ✅ ESLint passes with no warnings or errors
  • ✅ TypeScript type checking passes
  • ✅ Production build completes successfully
  • ✅ CodeQL security scan shows no vulnerabilities

Fixes #59 (related discussion: #59 (comment))

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • sparrow.cloudflare.com
    • Triggering command: /usr/local/bin/node --no-warnings --experimental-vm-modules /home/REDACTED/work/my-code/my-code/node_modules/wrangler/wrangler-dist/cli.js types --env-interface CloudflareEnv cloudflare-env.d.ts (dns block)
  • workers.cloudflare.com
    • Triggering command: /usr/local/bin/node --no-warnings --experimental-vm-modules /home/REDACTED/work/my-code/my-code/node_modules/wrangler/wrangler-dist/cli.js types --env-interface CloudflareEnv cloudflare-env.d.ts (dns block)
    • Triggering command: node /home/REDACTED/work/my-code/my-code/node_modules/.bin/next lint (dns block)
    • Triggering command: node /home/REDACTED/work/my-code/my-code/node_modules/.bin/next build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>chatエラーメッセージをユーザーに表示</issue_title>
<issue_description>(たぶん正常時のaddChat()と別で、チャット入力欄のところに表示したほうがいいと思う)

Originally posted by @na-trium-144 in #59 (comment)
</issue_description>

<agent_instructions>chatFormの閉じるボタンと送信ボタンの間にエラーメッセージを表示する場所を追加し、chatAction内で発生したエラーメッセージはそこに表示するようにしてください</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 24, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
my-code 69221ae Commit Preview URL

Branch Preview URL
Oct 24 2025, 05:34 PM

Copilot AI changed the title [WIP] Add error message display in chat input Display chat error messages to users in the chat form Oct 24, 2025
Copilot AI requested a review from na-trium-144 October 24, 2025 15:22
Copilot finished work on behalf of na-trium-144 October 24, 2025 15:22
@na-trium-144 na-trium-144 marked this pull request as ready for review October 24, 2025 17:31
@na-trium-144 na-trium-144 merged commit b60d945 into main Oct 24, 2025
2 of 3 checks passed
@na-trium-144 na-trium-144 deleted the copilot/add-error-message-to-chat branch October 24, 2025 17:36
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.

chatエラーメッセージをユーザーに表示

2 participants