Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ async function submit(formData?: FormData, skip?: boolean) {

const userInput = skip
? `{"action": "skip"}`
: (formData?.get('input') as string);
: ((formData?.get('related_query') as string) ||
(formData?.get('input') as string))
Comment on lines +57 to +58
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Logical inconsistency between input sourcing and type assignment.

Prioritizing related_query over input creates a mismatch with the type assignment logic on lines 182-185:

  • If both input and related_query are present in formData, these lines will use related_query as the content
  • But lines 182-183 will assign type 'input' (because formData?.has('input') is checked first)
  • This creates a mismatch where the content comes from related_query but the type is 'input' instead of 'input_related'

Additionally, according to the PR comments, the root cause of the recommended prompts issue is that clicking a prompt sets the input value but doesn't trigger form submission. This change only affects which field is read for content—it doesn't address the auto-submission problem. Consider:

  1. Updating the type assignment logic to check has('related_query') before has('input') to match the input sourcing priority
  2. Implementing one of the solutions proposed in the PR comments (exposing a submit method via ref or using a state flag with useEffect) to address the auto-submission issue

Apply this diff to align the type assignment with input sourcing:

   const type = skip
     ? undefined
-    : formData?.has('input') || formData?.has('file')
-    ? 'input'
-    : formData?.has('related_query')
+    : formData?.has('related_query')
     ? 'input_related'
+    : formData?.has('input') || formData?.has('file')
+    ? 'input'
     : 'inquiry'

Run this script to verify if both fields can be set simultaneously:


🏁 Script executed:

#!/bin/bash
# Description: Search for code that sets both 'input' and 'related_query' in FormData

# Search for FormData append/set operations with 'input'
echo "=== Searching for FormData operations with 'input' field ==="
rg -n -B3 -A3 "FormData.*input|append.*input|set.*input" --type=tsx --type=ts

# Search for FormData append/set operations with 'related_query'
echo "=== Searching for FormData operations with 'related_query' field ==="
rg -n -B3 -A3 "FormData.*related_query|append.*related_query|set.*related_query" --type=tsx --type=ts

# Search for form submissions that might set these fields
echo "=== Searching for form elements with name='input' or name='related_query' ==="
rg -n -B2 -A2 "name=['\"]input['\"]|name=['\"]related_query['\"]" --type=tsx --type=ts

Length of output: 291


🏁 Script executed:

#!/bin/bash
echo "=== Searching for 'related_query' references ==="
rg -n 'related_query' -C3

echo "=== Searching for JSX form elements with name='input' or 'related_query' ==="
rg -n 'name\s*=\s*["\'"](input|related_query)["\'"]' -C3 -g '*.tsx' -g '*.jsx'

Length of output: 1989


Align type assignment with input sourcing priority.

Swap the ternary checks so that related_query is evaluated before input:

 const type = skip
   ? undefined
-  : formData?.has('input') || formData?.has('file')
-    ? 'input'
-    : formData?.has('related_query')
-    ? 'input_related'
+  : formData?.has('related_query')
+    ? 'input_related'
+    : formData?.has('input') || formData?.has('file')
+    ? 'input'
   : 'inquiry'
🤖 Prompt for AI Agents
In app/actions.tsx around lines 57 to 58, the current ternary evaluates input
before related_query; swap the checks so related_query is evaluated first (use
related_query || input) and ensure the type assertions remain the same
((formData?.get('related_query') as string) || (formData?.get('input') as
string)) to preserve the original typings and sourcing priority.


if (userInput.toLowerCase().trim() === 'what is a planet computer?' || userInput.toLowerCase().trim() === 'what is qcx-terra?') {
const definition = userInput.toLowerCase().trim() === 'what is a planet computer?'
Expand Down
1 change: 1 addition & 0 deletions components/chat-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export const ChatPanel = forwardRef<ChatPanelRef, ChatPanelProps>(({ messages, i
isMobile ? 'right-1' : 'right-2'
)}
disabled={input.length === 0 && !selectedFile}
aria-label="Send message"
>
<ArrowRight size={isMobile ? 18 : 20} />
</Button>
Expand Down
2 changes: 1 addition & 1 deletion components/message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function BotMessage({ content }: { content: StreamableValue<string> }) {
<MemoizedReactMarkdown
rehypePlugins={[[rehypeExternalLinks, { target: '_blank' }], rehypeKatex]}
remarkPlugins={[remarkGfm, remarkMath]}
className="prose-sm prose-neutral prose-a:text-accent-foreground/50"
className="prose-sm prose-neutral prose-a:text-accent-foreground/50 break-words"
>
{processedData}
</MemoizedReactMarkdown>
Expand Down