Skip to content

feat: add streaming output, model selection with dropdown, and fallback - #35

Closed
Dhairya0707 wants to merge 2 commits into
HoussemEddineChaouch:mainfrom
Dhairya0707:feat/streaming-model-selection
Closed

feat: add streaming output, model selection with dropdown, and fallback#35
Dhairya0707 wants to merge 2 commits into
HoussemEddineChaouch:mainfrom
Dhairya0707:feat/streaming-model-selection

Conversation

@Dhairya0707

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR introduces streaming output and an interactive, real-time dropdown selection menu for choosing models within the CLI.

Streaming output:

  • Responses are printed token-by-token as they're generated from Gemini, instead of waiting for the full response.
  • Tool-calling responses are intelligently detected mid-stream and suppressed, then the final answer streams live.

Interactive model selection:

  • Intercepts keystrokes in real-time. As soon as the user types /model, the CLI clears the prompt and transitions into an interactive select mode.
  • Allows navigating available models using the standard Up (↑) and Down (↓) arrow keys.
  • Confirms the model change instantly upon pressing Enter, and restores the regular prompt.
  • Gracefully cancels selection and returns to the prompt upon pressing Escape or Ctrl+C.
  • Retains backward compatibility (you can still hit enter on /model to trigger the dropdown, or type /model <model-name> directly).
  • Falls back to the default model automatically if the selected model fails.

Type of change

  • Bug fix
  • New feature / tool
  • Documentation update
  • Refactor

How to test it

  1. Start the CLI application:
    node src/index.js
  2. Type hello and observe the response stream in token-by-token.
  3. Type /model into the prompt and observe the select menu:
    Agent > Select a model:
      ➔  gemini-3.1-flash-lite
         gemini-2.5-pro
         ...
    
  4. Use the Up/Down Arrow Keys to navigate through the models.
  5. Press Enter to select the highlighted model. The CLI will confirm the switch and return you to the main prompt.
  6. Trigger the menu again and press Escape to verify it cancels gracefully without switching models.
  7. Type list files and observe the tool execute with the final answer streaming.

Related issues

Closes #21

@HoussemEddineChaouch

Copy link
Copy Markdown
Owner

Hi @Dhairya0707! Thanks for the contribution.

The merge conflicts appeared after PR #34 was merged into main. Could you please resolve the conflicts, and push the updated branch?

Thanks!

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@Dhairya0707 is attempting to deploy a commit to the houssemeddinechaouch's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Dhairya0707

Copy link
Copy Markdown
Contributor Author

Done it checkout it

Comment thread src/agent.js
return { toolName, args, reason };
}

async function runAgent(userInput, messages = []) {

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.

Why remove messages = []?

Comment thread src/agent.js
@@ -72,11 +72,27 @@ async function runAgent(userInput, messages = []) {
messages.push({ role: "user", content: userInput });

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.

But still use it? Did you test this after fixing the conflicts?

@abusnitsky

Copy link
Copy Markdown
Contributor

Wouldn't it be better to break this down into three separate, simpler issues? Right now, it's a bit hard to understand and review all at once.

@Dhairya0707

Copy link
Copy Markdown
Contributor Author

Sure Just 10 min

@Dhairya0707

Copy link
Copy Markdown
Contributor Author

I've split this into 2 cleaner PRs for easier review:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Streaming responses + model selection with fallback

3 participants