-
Notifications
You must be signed in to change notification settings - Fork 1
ログイン機能 #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ログイン機能 #71
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
my-code | 02c903c | Commit Preview URL Branch Preview URL |
Oct 25 2025, 06:36 PM |
There was a problem hiding this 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 implements a login functionality using better-auth with anonymous authentication and OAuth providers (GitHub/Google), replacing the previous localStorage-based chat history with a PostgreSQL database managed by Prisma.
Key changes:
- Added Prisma schema with User, Session, Account, Chat, and Message models for database-backed authentication and chat storage
- Integrated better-auth with anonymous login and OAuth providers
- Migrated chat history from localStorage to database with automatic chat migration when anonymous users link accounts
Reviewed Changes
Copilot reviewed 18 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| prisma/schema.prisma | Defines database schema for authentication (User, Session, Account, Verification) and chat functionality (Chat, Message) |
| prisma.config.ts | Configures Prisma with PostgreSQL datasource and migration settings |
| package.json | Adds prisma, @prisma/client, better-auth, and dotenv dependencies; updates scripts to run prisma generate |
| app/sidebar.tsx | Adds AccountMenu component to sidebar header |
| app/navbar.tsx | Adds AccountMenu component to navbar |
| app/lib/prisma.ts | Exports configured PrismaClient instance |
| app/lib/chatHistory.ts | Implements server-side chat CRUD operations with authentication checks and user migration |
| app/lib/auth.ts | Configures better-auth with Prisma adapter, anonymous plugin, and OAuth providers |
| app/lib/auth-client.ts | Creates client-side auth instance with anonymous plugin |
| app/layout.tsx | Adds AutoAnonymousLogin component for automatic anonymous authentication |
| app/api/auth/[...all]/route.ts | Creates Next.js API route handler for better-auth endpoints |
| app/actions/chatActions.ts | Updates askAI to save chats to database and return ChatWithMessages type |
| app/accountMenu.tsx | Implements UI components for login/logout and account menu with OAuth integration |
| app/[docs_id]/pageContent.tsx | Updates to use database-backed chat histories with new data structure |
| app/[docs_id]/page.tsx | Fetches initial chat histories from database via getChat |
| app/[docs_id]/chatHistory.tsx | Refactors chat history context to use database-backed ChatWithMessages type |
| app/[docs_id]/chatForm.tsx | Updates to work with new chat data structure and server action response |
| README.md | Documents setup instructions for Prisma development environment and production OAuth configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| response: "", | ||
| error: "予期せぬエラーが発生しました。", | ||
| targetSectionId: sectionContent.find((s) => s.inView)?.sectionId || "", | ||
| error: String(error), |
Copilot
AI
Oct 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converting the error to a string with String(error) may produce unhelpful messages like '[object Object]'. Extract the error message properly: error instanceof Error ? error.message : 'An unexpected error occurred'.
| error: String(error), | |
| error: error instanceof Error ? error.message : 'An unexpected error occurred', |
| const aiMessage: ChatMessage = { sender: "ai", text: result.response }; | ||
| const chatId = addChat(result.targetSectionId, [userMessage, aiMessage]); | ||
| addChat(result.chat); | ||
| // TODO: chatIdが指す対象の回答にフォーカス |
Copilot
AI
Oct 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The chatId variable is no longer defined after removing the assignment. If the TODO is still relevant, it should reference result.chat.chatId instead.
| // TODO: chatIdが指す対象の回答にフォーカス | |
| // TODO: result.chat.chatIdが指す対象の回答にフォーカス |
|
プレビューだとなんか動作しないが、ログも出なくて何が起きているかわからんので、一旦マージしちゃう |
This reverts commit 72fc0f6.
close #61