Skip to content

チャットの表示をparallel routesで実装#192

Merged
na-trium-144 merged 20 commits intomainfrom
new-chat-ui
Mar 17, 2026
Merged

チャットの表示をparallel routesで実装#192
na-trium-144 merged 20 commits intomainfrom
new-chat-ui

Conversation

@na-trium-144
Copy link
Contributor

@na-trium-144 na-trium-144 commented Mar 16, 2026

close #65
close #179

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 16, 2026

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 9c25d19 Commit Preview URL

Branch Preview URL
Mar 17 2026, 02:07 PM

@na-trium-144 na-trium-144 marked this pull request as ready for review March 17, 2026 13:29
@na-trium-144 na-trium-144 requested a review from Copilot March 17, 2026 13:29
Copy link
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

Next.js の Parallel Routes を使って「ドキュメント表示」と「チャット表示」を独立に切り替えられる構成にし、チャットをサイドバー的に表示できるようにするPRです。あわせて、ページ幅/コンテナ幅の見直しで #179(ページタイトル幅)のレイアウト問題にも対応しています。

Changes:

  • チャットに title カラムを追加し、既存データをメッセージから移行
  • (docs) 配下に @docs / @chat の Parallel Routes を追加し、チャット領域・チャット一覧UIを実装
  • コンテナ幅・ブレークポイントのカスタマイズ、Markdownのハイライト/リンク挙動を更新

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
drizzle/meta/_journal.json Drizzleのマイグレーション履歴を更新
drizzle/meta/0005_snapshot.json スキーマスナップショット更新(chat.title追加など)
drizzle/0005_giant_kylun.sql chat.title追加+既存チャットのtitle埋め戻し
app/schema/chat.ts chatテーブルに title を追加
app/lib/chatHistory.ts チャット追加/取得/削除、キャッシュキーとrevalidate方針を拡張
app/actions/chatActions.ts AI応答からセクションID+タイトル+本文をパースし保存
app/actions/getRedirectFromChat.ts /chat/:id 直アクセス時に対応ドキュメントへ解決するaction追加
app/(docs)/layout.tsx docs/chatを並べるレイアウト(Parallel Routes)追加
app/(docs)/@docs/[lang]/[pageId]/page.tsx ドキュメント側ページを新構成に対応、チャット取得をキャッシュ化
app/(docs)/@docs/[lang]/[pageId]/pageContent.tsx セクションごとのチャット一覧UI、レイアウト調整
app/(docs)/@chat/chat/[chatId]/page.tsx チャット領域(サイドバー表示)を新規実装
app/(docs)/@docs/default.tsx /chat/:id 直アクセス時のdocsスロット側リダイレクト
app/globals.css breakpoints/containersのテーマ変数追加
app/sidebar.tsx / app/navbar.tsx / app/layout.tsx / app/terminal/page.tsx 幅や表示条件(has-sidebar等)に合わせたUI調整
app/markdown/* hr無効化、ハイライトからチャットへ遷移できるように更新
Comments suppressed due to low confidence (3)

app/(docs)/@docs/[lang]/[pageId]/pageContent.tsx:291

  • チャット表示中(chatId !== null)かつ has-chat-2 以上の幅では、上の <ul> も表示される一方で、この <details> も常に block になってしまい、リストとボタンが同時表示されます。chatId !== null の分岐側は has-chat-2:hidden などにして、意図したブレークポイントで片方だけ表示されるようにしてください。
    app/(docs)/@docs/[lang]/[pageId]/page.tsx:100
  • Cloudflare Cacheの cachedResponse.json() 経由で返す ChatWithMessages[] では、createdAt(chat/message/diff)が JSON 化により文字列になります。下流のクライアント側(PageContent)では createdAt.getTime() を呼んでいるため例外になります。ここで createdAtnew Date(...) に復元する(入れ子も含めて)か、クライアント側が文字列でも動くように統一してください。
    app/(docs)/@docs/[lang]/[pageId]/pageContent.tsx:50
  • chatHistories をサーバー側キャッシュ(Cloudflare Cacheの cachedResponse.json())経由で渡す場合、createdAtDate ではなく文字列になり得ます。このファイル内で createdAt.getTime() を使っている箇所があるため、受け取った時点で Date へ復元するか、ソート/比較側を new Date(createdAt) で扱える形にして例外を防いでください。

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +36 to +45
if (typeof pagePath === "string") {
const [lang, page] = pagePath.split("/") as [LangId, PageSlug];
pagePath = { lang, page };
}
revalidateTag(cacheKeyForChat(chatId));
revalidateTag(cacheKeyForPage(pagePath, userId));
if (isCloudflare()) {
const cache = await caches.open("chatHistory");
await cache.delete(cacheKeyForChat(chatId));
await cache.delete(cacheKeyForPage(pagePath, userId));
@na-trium-144 na-trium-144 merged commit 876b81d into main Mar 17, 2026
7 of 8 checks passed
@na-trium-144 na-trium-144 deleted the new-chat-ui branch March 17, 2026 14:06
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.

ページタイトルの幅がおかしい チャットの表示をparallel routesにする

2 participants