Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
my-code | aae1407 | Commit Preview URL Branch Preview URL |
Mar 20 2026, 10:26 AM |
Contributor
There was a problem hiding this comment.
Pull request overview
Next.js のキャッシュ再検証(revalidateTag)が Route Handler 内では期待通り動かない問題に対応するため、チャット関連のキャッシュ再検証呼び出しを Server Action 経由に寄せ、あわせてチャット作成時のページ遷移完了まで待機するようにして体感の遅さを改善するPRです。
Changes:
app/lib/chatHistory.ts内からrevalidateChat呼び出しを外し、Server Action 側から呼ぶ設計へ移行revalidateChatAction(Server Action)を新設し、クライアントからキャッシュ再検証を実行可能に- チャット作成時の
router.pushを「遷移完了まで await」できるようにして、後続処理を待機
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| app/lib/chatHistory.ts | lib内部の revalidate 呼び出しを廃止し、再検証関数を外部から呼べるように調整 |
| app/actions/revalidateChat.ts | chat のキャッシュ再検証を行う Server Action を追加 |
| app/actions/deleteChat.ts | delete 後の再検証を Server Action 側に移動 |
| app/(docs)/@docs/[lang]/[pageId]/chatForm.tsx | ストリーミング中に Server Action で再検証し、push完了まで待機するよう変更 |
Comments suppressed due to low confidence (1)
app/lib/chatHistory.ts:43
revalidateChatacceptspagePathasstring | PagePath, but when given a string it blindly splits on/without validating the result. Since callers can pass unexpected values (e.g. empty string), this can silently generate invalid cache keys (e.g. containingundefined). Consider validating the string form (or requiringPagePathonly) and throwing on invalid input to avoid revalidating the wrong tags.
export async function revalidateChat(
chatId: string,
userId: string,
pagePath: string | PagePath
) {
if (typeof pagePath === "string") {
const [lang, page] = pagePath.split("/") as [LangId, PageSlug];
pagePath = { lang, page };
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1d16cee to
aae1407
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
revalidateTag()inside dynamic route handler is unstable vercel/next.js#69064そのためlib/以下の関数では直接revalidateChatを呼ばず、ServerActionの関数から呼ぶようにする。