Skip to content

feat(chatgpt): add model/mode selection and fix response polling#438

Merged
jackwener merged 2 commits intojackwener:mainfrom
MatrixA:feat/chatgpt-model-selection
Mar 25, 2026
Merged

feat(chatgpt): add model/mode selection and fix response polling#438
jackwener merged 2 commits intojackwener:mainfrom
MatrixA:feat/chatgpt-model-selection

Conversation

@MatrixA
Copy link
Copy Markdown
Contributor

@MatrixA MatrixA commented Mar 25, 2026

Summary

  • Add --model option to ask and send commands for selecting ChatGPT model/mode before sending
  • Add new opencli chatgpt model <model> standalone command for switching models
  • Fix ask command returning partial/thinking intermediate text instead of waiting for the full response

Supported models

auto, instant, thinking, 5.2-instant, 5.2-thinking

Usage

# Switch model standalone
opencli chatgpt model thinking

# Ask with model selection
opencli chatgpt ask "hello" --model thinking --timeout 60

# Send with model selection
opencli chatgpt send "hello" --model instant

Implementation details

Model selection (ax.ts)

  • Clicks the "Options" button (stable desc="Options") to open the model popover
  • Searches only within the AXPopover element to avoid matching sidebar items (e.g. "Auto" prefix previously matched "Automatic Trading on Chain")
  • For legacy models (5.2-instant, 5.2-thinking): clicks "Legacy models" first to expand the submenu, then selects the model
  • Uses desc prefix matching within the popover for robustness

Response polling fix (ask.ts)

  • Before: Broke out of the poll loop as soon as any new text appeared — captured thinking intermediate text in thinking mode
  • After: Polls isGenerating() which checks if the "Stop generating" button exists in the AX tree. Only reads the final response after generation completes

Files changed

File Change
src/clis/chatgpt/ax.ts Add AX_MODEL_SCRIPT, AX_GENERATING_SCRIPT, selectModel(), isGenerating(), MODEL_CHOICES
src/clis/chatgpt/ask.ts Add --model arg, fix polling to wait for generation completion
src/clis/chatgpt/send.ts Add --model arg
src/clis/chatgpt/model.ts New — standalone model switching command

Test plan

  • opencli chatgpt model auto — switches to Auto
  • opencli chatgpt model thinking — switches to Thinking
  • opencli chatgpt model 5.2-thinking — opens Legacy submenu, selects GPT-5.2 Thinking
  • opencli chatgpt model auto after legacy model — correctly selects Auto (not sidebar items)
  • opencli chatgpt ask "what is 2+2?" --model thinking — waits for full response, not thinking text
  • opencli chatgpt ask "explain quantum computing in 3 sentences" --model thinking --timeout 60 — returns complete response

MatrixA and others added 2 commits March 25, 2026 23:30
Add --model option to ask and send commands, and a new standalone
model command for switching ChatGPT Desktop models via Accessibility API.

Supported models: auto, instant, thinking, 5.2-instant, 5.2-thinking.

Changes:
- ax.ts: add AX_MODEL_SCRIPT (opens Options popover, searches within
  AXPopover to avoid matching sidebar items, supports legacy models
  submenu) and AX_GENERATING_SCRIPT (detects "Stop generating" button)
- ask.ts: add --model flag; fix polling to wait for generation to
  complete instead of returning partial/thinking intermediate text
- send.ts: add --model flag
- model.ts: new standalone command to switch model/mode
@jackwener jackwener merged commit a5f9088 into jackwener:main Mar 25, 2026
22 checks passed
@jackwener jackwener mentioned this pull request Mar 26, 2026
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.

2 participants