Skip to content

Go: CLI chat with text, image, video - #14573

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
JinHai-CN:fix412
May 5, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
JinHai-CN:fix412

Conversation

@JinHai-CN

Copy link
Copy Markdown
Member

What problem does this PR solve?

RAGFlow(user)> chat with 'glm-4.6v-flash@test@zhipu-ai' message 'What are the pics talk about?' image 'https://cdn.bigmodel.cn/static/logo/register.png' 'https://cdn.bigmodel.cn/static/logo/api-key.png'
Answer: The first picture shows a login/register modal with options for phone number login, account login, and WeChat QR code login, along with a prompt for new users to get a 20 million tokens experience package. The second picture displays the API keys management page of a platform, including a warning about API key security and a table listing existing API keys with details like creation time and usage history.
Time: 31.600545
RAGFlow(user)> chat with 'glm-4.6v-flash@test@zhipu-ai' message 'What are the video talk about?' video 'https://cdn.bigmodel.cn/agent-demos/lark/113123.mov'
Answer: Based on the sequence of frames provided, the video is a demonstration of a web search and navigation process.

1.  The video starts with a blank Google search page.
2.  The user types "智谱" (which is the Chinese name for the company Zhipu AI) into the search box.
3.  The search is initiated and the page shows "About 0 results".
4.  The search results load, showing information about Zhipu AI, including its website.
5.  The user clicks on the main website link (www.zhipuai.cn).
6.  The video ends by showing the homepage of Zhipu AI's website, titled "Z.ai GLM Large Model Open Platform".

In summary, the video is about searching for the company "智谱" (Zhipu AI) on Google and then navigating to its official website.
Time: 76.582520

Type of change

  • New Feature (non-breaking change which adds functionality)

@coderabbitai

coderabbitai Bot commented May 5, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds multimodal input support to the chat command parser. The lexer recognizes new keywords (MESSAGE, IMAGE, VIDEO, AUDIO), four token types are added and one removed, the parser is rewritten from positional to option-based parsing, and the command builder now constructs multimodal request payloads with text, images, videos, audio, and files.

Changes

Multimodal Chat Support

Layer / File(s) Summary
Token Definitions
internal/cli/types.go
Added token constants TokenMessage, TokenImage, TokenVideo, TokenAudio; removed TokenPool.
Lexer Recognition
internal/cli/lexer.go
lookupIdent now recognizes MESSAGE, IMAGE, VIDEO, AUDIO keywords and returns their dedicated token types instead of generic identifier tokens.
Parser Restructuring
internal/cli/user_parser.go
parseChatCommand rewrites from positional parsing to structured option parsing using WITH, MESSAGE, IMAGE, VIDEO, AUDIO, and FILE options; collects values as slices instead of single fields; enforces uniqueness and maps EFFORT/VERBOSITY tokens.
Request Construction
internal/cli/user_command.go
ChatToModel builds multimodal request payloads from messages, images, videos, audios, and files parameters; adds isValidURL helper for validation; handles base64 encoding of local files and URL vs. local file differentiation for each media type.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • infiniflow/ragflow#14453: Modifies ChatToModel in internal/cli/user_command.go alongside this PR, changing request target and fields while this PR restructures the message payload format.

Suggested labels

size:L

Poem

🐰 Four new tokens hop into play,
MESSAGE, IMAGE, VIDEO, AUDIO say,
The parser now dances in structured delight,
Building multimodal payloads—oh what a sight!
Files encoded in base64 rise,
While URLs skip beneath parsing skies. ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description provides concrete examples demonstrating the new multimodal chat feature with images and videos, but lacks explicit explanation of the problem solved and the Type of change checkbox is not fully addressed in standard format. Clarify the problem statement (e.g., why multimodal support was needed) and ensure the Type of change section explicitly shows the checkbox selection in the description.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main feature: adding CLI chat support for text, image, and video, which aligns with the core changes across the lexer, types, parser, and command handler.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JinHai-CN JinHai-CN added the ci Continue Integration label May 5, 2026
@JinHai-CN
JinHai-CN marked this pull request as ready for review May 5, 2026 09:12
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 5, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 5

🧹 Nitpick comments (2)
internal/cli/user_parser.go (1)

2415-2416: 💤 Low value

Outdated docstring example.

The first line shows the legacy positional form CHAT 'model@instance@provider' 'hello world', but the rewritten parser only accepts the option-based syntax (WITH ... MESSAGE ...). Drop the stale example to avoid misleading users.

📝 Proposed cleanup
-// CHAT 'model@instance@provider' 'hello world'
-// CHAT WITH 'model@instance@provider' MESSAGE 'hello world' 'who are you' IMAGE 'url1' 'file0' VIDEO "url2.mov" "file1" FILE "url" "path file2" AUDIO "file.wav"
+// CHAT WITH 'model@instance@provider' MESSAGE 'hello world' 'who are you' IMAGE 'url1' 'file0' VIDEO "url2.mov" "file1" FILE "url" "path file2" AUDIO "file.wav"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/user_parser.go` around lines 2415 - 2416, Remove the stale
positional example "CHAT 'model@instance@provider' 'hello world'" from the
docstring so only the current option-based syntax remains (e.g., the "CHAT WITH
... MESSAGE ... IMAGE ... VIDEO ... FILE ... AUDIO ..." example). Update the
docstring in internal/cli/user_parser.go where those example lines appear,
deleting the legacy positional line and ensuring examples reflect the rewritten
parser that requires the WITH/MESSAGE option-based form.
internal/cli/user_command.go (1)

1655-1668: 💤 Low value

Remove dead commented-out legacy code.

The block of commented-out lines reflects the prior single-message parsing/JSON-array-content path that no longer applies to the new formattedMessages flow. Leaving it in obscures the new logic; safer to delete and rely on git history.

🧹 Proposed cleanup
-	//message = strings.TrimSpace(message)
-	//var content interface{} = message
-	//if strings.HasPrefix(message, "[") && strings.HasSuffix(message, "]") {
-	//	var parts []map[string]interface{}
-	//	if err := json.Unmarshal([]byte(message), &parts); err == nil {
-	//		content = parts
-	//	}
-	//}
-	//formattedMessage := []map[string]interface{}{
-	//	{
-	//		"role":    "user",
-	//		"content": content,
-	//	},
-	//}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/user_command.go` around lines 1655 - 1668, Remove the dead
commented-out legacy parsing block that handles single `message` JSON/unmarshal
and builds a `formattedMessage` (the commented lines referencing `message`,
`content`, `parts`, `json.Unmarshal`, and the `formattedMessage` slice) since
the code now uses the `formattedMessages` flow; delete those commented lines
from user_command.go so only the current `formattedMessages` logic remains (rely
on VCS history if you need the old code).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/cli/user_command.go`:
- Around line 1598-1625: The error messages for the type assertions on videos
and files (and the commented audios block) are incorrect and reference "images";
update the returned fmt.Errorf messages to the correct parameter names so
callers can locate the missing param—change the error in the videos check to
"videos not provided", the files check to "files not provided", and if you
re-enable the audios check change that error to "audios not provided" (search
for the variables videos, files, audios and the type assertion checks in
user_command.go to apply the fixes).
- Around line 1617-1620: The AUDIO inputs are currently ignored because the
audio handling block in internal/cli/user_command.go is commented out; restore
and implement audio support by extracting cmd.Params["audios"] into a []string
(check ok), validate entries, and add content parts named "audio_url" or
"audio_file" following the same pattern used for "image", "video", and "file"
branches so audio assets are included in the request payload; alternatively if
audio is out-of-scope for this change, modify the parser to reject AUDIO tokens
or return an error when cmd.Params["audios"] is present so users are not misled.

In `@internal/cli/user_parser.go`:
- Around line 2557-2566: In the switch over p.curToken.Type that sets verbosity
(the block using TokenLow, TokenMedium, TokenHigh), change the TokenMedium case
to set verbosity = "medium" (not "median") so the variable verbosity matches the
expected downstream value; locate the switch in user_parser.go where
p.curToken.Type is inspected and update the TokenMedium branch accordingly.
- Around line 2499-2534: The duplicate-option checks in the TokenAudio and
TokenFile branches incorrectly return "video is already set"; change the error
strings so TokenAudio returns an error like "audio is already set" and TokenFile
returns "file is already set" (update the fmt.Errorf(...) calls in the
TokenAudio and TokenFile branches in the parser loop where audios/files are
checked) so the messages match the option being duplicated.
- Around line 2535-2568: The TokenEffort and TokenVerbosity case blocks in the
parser (see TokenEffort, TokenVerbosity, and surrounding optionsLoop handling in
internal/cli/user_parser.go) prematurely terminate the optionsLoop by calling
"break optionsLoop" after setting effort/verbosity, which prevents parsing
subsequent options; remove the "break optionsLoop" statements from both the
TokenEffort and TokenVerbosity branches so the loop continues calling
p.nextToken() and processes further options until the normal terminator
(semicolon/default) is reached.

---

Nitpick comments:
In `@internal/cli/user_command.go`:
- Around line 1655-1668: Remove the dead commented-out legacy parsing block that
handles single `message` JSON/unmarshal and builds a `formattedMessage` (the
commented lines referencing `message`, `content`, `parts`, `json.Unmarshal`, and
the `formattedMessage` slice) since the code now uses the `formattedMessages`
flow; delete those commented lines from user_command.go so only the current
`formattedMessages` logic remains (rely on VCS history if you need the old
code).

In `@internal/cli/user_parser.go`:
- Around line 2415-2416: Remove the stale positional example "CHAT
'model@instance@provider' 'hello world'" from the docstring so only the current
option-based syntax remains (e.g., the "CHAT WITH ... MESSAGE ... IMAGE ...
VIDEO ... FILE ... AUDIO ..." example). Update the docstring in
internal/cli/user_parser.go where those example lines appear, deleting the
legacy positional line and ensuring examples reflect the rewritten parser that
requires the WITH/MESSAGE option-based form.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c8af47b0-ef5d-4151-b336-c3713f17d710

📥 Commits

Reviewing files that changed from the base of the PR and between 24af087 and f23315d.

📒 Files selected for processing (4)
  • internal/cli/lexer.go
  • internal/cli/types.go
  • internal/cli/user_command.go
  • internal/cli/user_parser.go

Comment on lines +1598 to +1625
videos, ok := cmd.Params["videos"].([]string)
if !ok {
return nil, fmt.Errorf("images not provided")
}
if len(videos) > 0 {
for _, video := range videos {
if isValidURL(video) {
contents = append(contents, map[string]interface{}{
"type": "video_url",
"video_url": map[string]interface{}{
"url": video,
},
})
} else {
return nil, fmt.Errorf("invalid video URL: %s", video)
}
}
}

//audios, ok := cmd.Params["audios"].([]string)
//if !ok {
// return nil, fmt.Errorf("images not provided")
//}

files, ok := cmd.Params["files"].([]string)
if !ok {
return nil, fmt.Errorf("images not provided")
}

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 | 🟡 Minor | ⚡ Quick win

Misleading error messages for videos/files (and commented audios).

When the type assertion fails for the videos and files slices (and the commented-out audios block), the returned errors say "images not provided". Use the correct field name so callers can locate the missing param.

🐛 Proposed fix
 	videos, ok := cmd.Params["videos"].([]string)
 	if !ok {
-		return nil, fmt.Errorf("images not provided")
+		return nil, fmt.Errorf("videos not provided")
 	}
 ...
 	files, ok := cmd.Params["files"].([]string)
 	if !ok {
-		return nil, fmt.Errorf("images not provided")
+		return nil, fmt.Errorf("files not provided")
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
videos, ok := cmd.Params["videos"].([]string)
if !ok {
return nil, fmt.Errorf("images not provided")
}
if len(videos) > 0 {
for _, video := range videos {
if isValidURL(video) {
contents = append(contents, map[string]interface{}{
"type": "video_url",
"video_url": map[string]interface{}{
"url": video,
},
})
} else {
return nil, fmt.Errorf("invalid video URL: %s", video)
}
}
}
//audios, ok := cmd.Params["audios"].([]string)
//if !ok {
// return nil, fmt.Errorf("images not provided")
//}
files, ok := cmd.Params["files"].([]string)
if !ok {
return nil, fmt.Errorf("images not provided")
}
videos, ok := cmd.Params["videos"].([]string)
if !ok {
return nil, fmt.Errorf("videos not provided")
}
if len(videos) > 0 {
for _, video := range videos {
if isValidURL(video) {
contents = append(contents, map[string]interface{}{
"type": "video_url",
"video_url": map[string]interface{}{
"url": video,
},
})
} else {
return nil, fmt.Errorf("invalid video URL: %s", video)
}
}
}
//audios, ok := cmd.Params["audios"].([]string)
//if !ok {
// return nil, fmt.Errorf("images not provided")
//}
files, ok := cmd.Params["files"].([]string)
if !ok {
return nil, fmt.Errorf("files not provided")
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/user_command.go` around lines 1598 - 1625, The error messages
for the type assertions on videos and files (and the commented audios block) are
incorrect and reference "images"; update the returned fmt.Errorf messages to the
correct parameter names so callers can locate the missing param—change the error
in the videos check to "videos not provided", the files check to "files not
provided", and if you re-enable the audios check change that error to "audios
not provided" (search for the variables videos, files, audios and the type
assertion checks in user_command.go to apply the fixes).

Comment on lines +1617 to +1620
//audios, ok := cmd.Params["audios"].([]string)
//if !ok {
// return nil, fmt.Errorf("images not provided")
//}

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 | 🟠 Major | ⚡ Quick win

Audio inputs are silently dropped.

The lexer, token set, and parser all handle AUDIO ... and populate cmd.Params["audios"], but the audio-handling block here is commented out, so audio assets never reach the request payload. Either implement the audio_url/audio_file content parts (matching the image/video/file pattern) or, if audio is intentionally out-of-scope for this PR, reject AUDIO at parse time so users aren't misled into thinking audio works.

🐛 Suggested implementation (mirrors video/file branches)
-	//audios, ok := cmd.Params["audios"].([]string)
-	//if !ok {
-	//	return nil, fmt.Errorf("images not provided")
-	//}
+	audios, ok := cmd.Params["audios"].([]string)
+	if !ok {
+		return nil, fmt.Errorf("audios not provided")
+	}
+	if len(audios) > 0 {
+		for _, audio := range audios {
+			if isValidURL(audio) {
+				contents = append(contents, map[string]interface{}{
+					"type": "audio_url",
+					"audio_url": map[string]interface{}{
+						"url": audio,
+					},
+				})
+			} else {
+				return nil, fmt.Errorf("invalid audio URL: %s", audio)
+			}
+		}
+	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/user_command.go` around lines 1617 - 1620, The AUDIO inputs are
currently ignored because the audio handling block in
internal/cli/user_command.go is commented out; restore and implement audio
support by extracting cmd.Params["audios"] into a []string (check ok), validate
entries, and add content parts named "audio_url" or "audio_file" following the
same pattern used for "image", "video", and "file" branches so audio assets are
included in the request payload; alternatively if audio is out-of-scope for this
change, modify the parser to reject AUDIO tokens or return an error when
cmd.Params["audios"] is present so users are not misled.

Comment on lines +2499 to +2534
case TokenAudio:
p.nextToken()
if len(audios) != 0 {
return nil, fmt.Errorf("video is already set")
}
audioLoop:
for {
if p.curToken.Type != TokenQuotedString {
break audioLoop
}
var audio string
audio, err = p.parseQuotedString()
if err != nil {
return nil, err
}
audios = append(audios, audio)
p.nextToken()
}
case TokenFile:
p.nextToken()
if len(files) != 0 {
return nil, fmt.Errorf("video is already set")
}
fileLoop:
for {
if p.curToken.Type != TokenQuotedString {
break fileLoop
}
var file string
file, err = p.parseQuotedString()
if err != nil {
return nil, err
}
files = append(files, file)
p.nextToken()
}

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 | 🟡 Minor | ⚡ Quick win

Wrong error messages in AUDIO and FILE branches.

Both TokenAudio (line 2502) and TokenFile (line 2520) report "video is already set" on duplicate option detection. This will confuse users who pass duplicate AUDIO or FILE options.

🐛 Proposed fix
 		case TokenAudio:
 			p.nextToken()
 			if len(audios) != 0 {
-				return nil, fmt.Errorf("video is already set")
+				return nil, fmt.Errorf("audio is already set")
 			}
 ...
 		case TokenFile:
 			p.nextToken()
 			if len(files) != 0 {
-				return nil, fmt.Errorf("video is already set")
+				return nil, fmt.Errorf("file is already set")
 			}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case TokenAudio:
p.nextToken()
if len(audios) != 0 {
return nil, fmt.Errorf("video is already set")
}
audioLoop:
for {
if p.curToken.Type != TokenQuotedString {
break audioLoop
}
var audio string
audio, err = p.parseQuotedString()
if err != nil {
return nil, err
}
audios = append(audios, audio)
p.nextToken()
}
case TokenFile:
p.nextToken()
if len(files) != 0 {
return nil, fmt.Errorf("video is already set")
}
fileLoop:
for {
if p.curToken.Type != TokenQuotedString {
break fileLoop
}
var file string
file, err = p.parseQuotedString()
if err != nil {
return nil, err
}
files = append(files, file)
p.nextToken()
}
case TokenAudio:
p.nextToken()
if len(audios) != 0 {
return nil, fmt.Errorf("audio is already set")
}
audioLoop:
for {
if p.curToken.Type != TokenQuotedString {
break audioLoop
}
var audio string
audio, err = p.parseQuotedString()
if err != nil {
return nil, err
}
audios = append(audios, audio)
p.nextToken()
}
case TokenFile:
p.nextToken()
if len(files) != 0 {
return nil, fmt.Errorf("file is already set")
}
fileLoop:
for {
if p.curToken.Type != TokenQuotedString {
break fileLoop
}
var file string
file, err = p.parseQuotedString()
if err != nil {
return nil, err
}
files = append(files, file)
p.nextToken()
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/user_parser.go` around lines 2499 - 2534, The duplicate-option
checks in the TokenAudio and TokenFile branches incorrectly return "video is
already set"; change the error strings so TokenAudio returns an error like
"audio is already set" and TokenFile returns "file is already set" (update the
fmt.Errorf(...) calls in the TokenAudio and TokenFile branches in the parser
loop where audios/files are checked) so the messages match the option being
duplicated.

Comment on lines +2535 to +2568
case TokenEffort:
p.nextToken() // pass Effort
switch p.curToken.Type {
case TokenNone:
effort = "none"
case TokenMinimal:
effort = "minimal"
case TokenLow:
effort = "low"
case TokenMedium:
effort = "medium"
case TokenHigh:
effort = "high"
case TokenMax:
effort = "max"
default:
return nil, fmt.Errorf("invalid effort level")
}
p.nextToken()
break optionsLoop
case TokenVerbosity:
p.nextToken() // pass VERBOSITY
switch p.curToken.Type {
case TokenLow:
verbosity = "low"
case TokenMedium:
verbosity = "median"
case TokenHigh:
verbosity = "high"
default:
return nil, fmt.Errorf("invalid verbosity level")
}
p.nextToken()
break optionsLoop

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 | 🟠 Major | ⚡ Quick win

break optionsLoop after EFFORT/VERBOSITY prevents composing options.

After parsing either option the loop is unconditionally terminated, so any options that follow are silently ignored. Combinations like EFFORT high VERBOSITY low (or these options preceding MESSAGE/IMAGE/etc.) won't work, and only the first of EFFORT/VERBOSITY provided takes effect. This is asymmetric with parseAddModel, which keeps iterating until the default/semicolon case. Drop the break optionsLoop so parsing continues until ; or an unknown token.

🐛 Proposed fix
 		case TokenEffort:
 			p.nextToken() // pass Effort
 			switch p.curToken.Type {
 			...
 			default:
 				return nil, fmt.Errorf("invalid effort level")
 			}
 			p.nextToken()
-			break optionsLoop
 		case TokenVerbosity:
 			p.nextToken() // pass VERBOSITY
 			switch p.curToken.Type {
 			...
 			default:
 				return nil, fmt.Errorf("invalid verbosity level")
 			}
 			p.nextToken()
-			break optionsLoop
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case TokenEffort:
p.nextToken() // pass Effort
switch p.curToken.Type {
case TokenNone:
effort = "none"
case TokenMinimal:
effort = "minimal"
case TokenLow:
effort = "low"
case TokenMedium:
effort = "medium"
case TokenHigh:
effort = "high"
case TokenMax:
effort = "max"
default:
return nil, fmt.Errorf("invalid effort level")
}
p.nextToken()
break optionsLoop
case TokenVerbosity:
p.nextToken() // pass VERBOSITY
switch p.curToken.Type {
case TokenLow:
verbosity = "low"
case TokenMedium:
verbosity = "median"
case TokenHigh:
verbosity = "high"
default:
return nil, fmt.Errorf("invalid verbosity level")
}
p.nextToken()
break optionsLoop
case TokenEffort:
p.nextToken() // pass Effort
switch p.curToken.Type {
case TokenNone:
effort = "none"
case TokenMinimal:
effort = "minimal"
case TokenLow:
effort = "low"
case TokenMedium:
effort = "medium"
case TokenHigh:
effort = "high"
case TokenMax:
effort = "max"
default:
return nil, fmt.Errorf("invalid effort level")
}
p.nextToken()
case TokenVerbosity:
p.nextToken() // pass VERBOSITY
switch p.curToken.Type {
case TokenLow:
verbosity = "low"
case TokenMedium:
verbosity = "median"
case TokenHigh:
verbosity = "high"
default:
return nil, fmt.Errorf("invalid verbosity level")
}
p.nextToken()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/user_parser.go` around lines 2535 - 2568, The TokenEffort and
TokenVerbosity case blocks in the parser (see TokenEffort, TokenVerbosity, and
surrounding optionsLoop handling in internal/cli/user_parser.go) prematurely
terminate the optionsLoop by calling "break optionsLoop" after setting
effort/verbosity, which prevents parsing subsequent options; remove the "break
optionsLoop" statements from both the TokenEffort and TokenVerbosity branches so
the loop continues calling p.nextToken() and processes further options until the
normal terminator (semicolon/default) is reached.

Comment on lines +2557 to +2566
switch p.curToken.Type {
case TokenLow:
verbosity = "low"
case TokenMedium:
verbosity = "median"
case TokenHigh:
verbosity = "high"
default:
return nil, fmt.Errorf("invalid verbosity level")
}

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 | 🟡 Minor | ⚡ Quick win

verbosity = "median" looks like a typo for "medium".

TokenMedium for EFFORT maps to "medium" (line 2545) but for VERBOSITY it maps to "median". The downstream payload (user_command.go) forwards this string verbatim, so the backend will likely reject "median" as an unknown verbosity level.

🐛 Proposed fix
 			case TokenMedium:
-				verbosity = "median"
+				verbosity = "medium"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
switch p.curToken.Type {
case TokenLow:
verbosity = "low"
case TokenMedium:
verbosity = "median"
case TokenHigh:
verbosity = "high"
default:
return nil, fmt.Errorf("invalid verbosity level")
}
switch p.curToken.Type {
case TokenLow:
verbosity = "low"
case TokenMedium:
verbosity = "medium"
case TokenHigh:
verbosity = "high"
default:
return nil, fmt.Errorf("invalid verbosity level")
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/user_parser.go` around lines 2557 - 2566, In the switch over
p.curToken.Type that sets verbosity (the block using TokenLow, TokenMedium,
TokenHigh), change the TokenMedium case to set verbosity = "medium" (not
"median") so the variable verbosity matches the expected downstream value;
locate the switch in user_parser.go where p.curToken.Type is inspected and
update the TokenMedium branch accordingly.

@codecov

codecov Bot commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.16%. Comparing base (24af087) to head (f23315d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14573      +/-   ##
==========================================
- Coverage   95.59%   94.16%   -1.43%     
==========================================
  Files          10       10              
  Lines         703      703              
  Branches      112      112              
==========================================
- Hits          672      662      -10     
- Misses         21       25       +4     
- Partials       10       16       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit 3a51c27 into infiniflow:main May 5, 2026
1 check passed
@coderabbitai coderabbitai Bot mentioned this pull request May 12, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant