-
-
Notifications
You must be signed in to change notification settings - Fork 8
Revert PR #732 #733
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
Revert PR #732 #733
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ export async function generateMetadata({ params }: SearchPageProps) { | |
| // TODO: Metadata generation might need authenticated user if chats are private | ||
| // For now, assuming getChat can be called or it handles anon access for metadata appropriately | ||
| const userId = await getCurrentUserIdOnServer(); // Attempt to get user for metadata | ||
| const chat = await getChat(id, userId || undefined); // Pass userId or undefined if none (allows public fallback) | ||
| const chat = await getChat(id, userId || 'anonymous'); // Pass userId or 'anonymous' if none | ||
| return { | ||
| title: chat?.title?.toString().slice(0, 50) || 'Search', | ||
| }; | ||
|
|
@@ -48,11 +48,14 @@ export default async function SearchPage({ params }: SearchPageProps) { | |
| const initialMessages: AIMessage[] = dbMessages.map((dbMsg): AIMessage => { | ||
| return { | ||
| id: dbMsg.id, | ||
| role: dbMsg.role as AIMessage['role'], | ||
| role: dbMsg.role as AIMessage['role'], // Cast role, ensure AIMessage['role'] includes all dbMsg.role possibilities | ||
| content: dbMsg.content, | ||
| createdAt: dbMsg.createdAt ? new Date(dbMsg.createdAt) : undefined, | ||
| type: dbMsg.type ? (dbMsg.type as AIMessage['type']) : undefined, | ||
| name: dbMsg.name || undefined, | ||
| // 'type' and 'name' are not in the basic Drizzle 'messages' schema. | ||
| // These would be undefined unless specific logic is added to derive them. | ||
| // For instance, if a message with role 'tool' should have a 'name', | ||
| // or if some messages have a specific 'type' based on content or other flags. | ||
| // This mapping assumes standard user/assistant messages primarily. | ||
|
Comment on lines
+51
to
+58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify whether the Chat component or any other mechanism reconstructs UI state
# from AI state on page load, which could bypass getUIStateFromAIState.
# Check how the Chat component consumes AI/UI state
ast-grep outline components/chat.tsx --items all --type function,component
# Search for getUIState or onGetUIState usage to understand when it's called
rg -nC3 'getUIState|onGetUIState' --type=ts --glob '!**/node_modules/**'
# Check if initialUIState is set to anything other than empty array
rg -nC3 'initialUIState' app/actions.tsxRepository: QueueLab/QCX Length of output: 197 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== Files ==\n'
git ls-files 'app/search/[id]/page.tsx' 'app/actions.tsx' 'components/chat.tsx'
printf '\n== Outline: app/search/[id]/page.tsx ==\n'
ast-grep outline 'app/search/[id]/page.tsx' || true
printf '\n== Outline: app/actions.tsx ==\n'
ast-grep outline 'app/actions.tsx' || true
printf '\n== Outline: components/chat.tsx ==\n'
ast-grep outline 'components/chat.tsx' || true
printf '\n== Search for getUIState / onGetUIState / initialUIState ==\n'
rg -nC3 'getUIState|onGetUIState|initialUIState' --glob '!**/node_modules/**' app components || true
printf '\n== Relevant slices: app/actions.tsx ==\n'
sed -n '640,720p' app/actions.tsx || true
printf '\n== Relevant slices: components/chat.tsx ==\n'
sed -n '1,260p' components/chat.tsx || true
printf '\n== Relevant slice: app/search/[id]/page.tsx ==\n'
sed -n '1,180p' 'app/search/[id]/page.tsx' || trueRepository: QueueLab/QCX Length of output: 17459 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the specific message/UI types to understand whether `type` is required
# and how the page reconstructs state.
rg -nC3 'type:|UIMessage|AIMessage|Message' app components --glob '!**/node_modules/**' || true
# Look for any conversion from DB messages to UI messages besides app/search/[id]/page.tsx
rg -nC3 'messages.map|createdAt:|role: dbMsg.role|content: dbMsg.content' app components --glob '!**/node_modules/**' || trueRepository: QueueLab/QCX Length of output: 50368 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== Match files ==\n'
git ls-files | rg '^(app/actions\.tsx|app/search/\[id\]/page\.tsx|components/chat\.tsx)$'
printf '\n== app/actions.tsx around getUIStateFromAIState ==\n'
python3 - <<'PY'
from pathlib import Path
p = Path('app/actions.tsx')
text = p.read_text()
for needle in ['getUIStateFromAIState', 'initialUIState', 'onGetUIState', 'type ===', '!type']:
idx = text.find(needle)
print(f'needle={needle!r} idx={idx}')
if idx != -1:
start = max(0, text.rfind('\n', 0, idx-200))
end = text.find('\n', idx+400)
print(text[start:end])
print('---')
PY
printf '\n== components/chat.tsx around state wiring ==\n'
python3 - <<'PY'
from pathlib import Path
p = Path('components/chat.tsx')
text = p.read_text()
for needle in ['initialUIState', 'onGetUIState', 'getUIState', 'useUIState', 'useChat']:
idx = text.find(needle)
print(f'needle={needle!r} idx={idx}')
if idx != -1:
start = max(0, text.rfind('\n', 0, idx-250))
end = text.find('\n', idx+500)
print(text[start:end])
print('---')
PY
printf '\n== app/search/[id]/page.tsx around DB message mapping ==\n'
python3 - <<'PY'
from pathlib import Path
p = Path('app/search/[id]/page.tsx')
text = p.read_text()
for needle in ['createdAt: dbMsg.createdAt', 'role: dbMsg.role', 'type:', 'messages.map', 'getUIStateFromAIState']:
idx = text.find(needle)
print(f'needle={needle!r} idx={idx}')
if idx != -1:
start = max(0, text.rfind('\n', 0, idx-250))
end = text.find('\n', idx+500)
print(text[start:end])
print('---')
PYRepository: QueueLab/QCX Length of output: 6472 Restore 🤖 Prompt for AI Agents |
||
| }; | ||
| }); | ||
|
|
||
|
|
||
This file was deleted.
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.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
endmessages are now persisted to the DB and accumulate across saves.updatedMessagesincludes the appended{ content: 'end', type: 'end' }message (lines 641–649). Since the mapping insaveChat(lib/actions/chat.ts, lines 213–219) dropstype, this message is stored asrole: 'assistant', content: 'end'. Each subsequent save appends a newendmessage with a freshnanoid(), so multipleendrows accumulate per chat over time. While these are filtered from the UI on rehydration (notype→null), they waste storage and could confuse message-count or ordering logic.🤖 Prompt for AI Agents