[PR #14609] [MERGED] cmd: refactor tui and launch #20019

Closed
opened 2026-04-16 07:23:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14609
Author: @ParthSareen
Created: 3/4/2026
Status: Merged
Merged: 3/13/2026
Merged by: @ParthSareen

Base: mainHead: parth-refactor-launch-tui


📝 Commits (10+)

  • 54f4d68 Refactor launch flow into shared launcher package
  • b55f2b6 Keep selected model visible in More
  • 2b625d6 Fix launcher and cloud model regressions
  • 8d1d3b0 Route launch --model through root TUI
  • 9e60921 Apply headless-safe missing model launch policy
  • 090000c Move integration ownership into cmd/launch
  • 78e3eda Require integration names for launch flags
  • 7c19513 Remove unused launch helper wrappers
  • 5591463 Fix launcher regression handling
  • d297629 Isolate backup temp directories in config tests

📊 Changes

42 files changed (+5182 additions, -3265 deletions)

View changed files

📝 cmd/cmd.go (+92 -167)
cmd/cmd_launcher_test.go (+233 -0)
📝 cmd/cmd_test.go (+41 -20)
cmd/config/claude.go (+0 -187)
📝 cmd/config/config.go (+13 -33)
📝 cmd/config/config_cloud_test.go (+41 -77)
📝 cmd/config/config_test.go (+13 -78)
cmd/config/integrations.go (+0 -1441)
cmd/config/selector.go (+0 -59)
cmd/config/selector_test.go (+0 -19)
📝 cmd/internal/fileutil/files.go (+10 -6)
📝 cmd/internal/fileutil/files_test.go (+63 -43)
cmd/launch/claude.go (+77 -0)
📝 cmd/launch/claude_test.go (+12 -59)
📝 cmd/launch/cline.go (+4 -23)
📝 cmd/launch/cline_test.go (+1 -1)
📝 cmd/launch/codex.go (+1 -1)
📝 cmd/launch/codex_test.go (+1 -1)
cmd/launch/command_test.go (+494 -0)
📝 cmd/launch/droid.go (+13 -28)

...and 22 more files

📄 Description

ollama launch was created as an isolated package to support integrations. Since its inception, we have added a tui to make it easier to launch and connect to integrations.

Currently, there are many diverging paths which follow effectively the same behavior, making it difficult to wire up new integrations or do testing. This PR is in aim to make adding new integrations, tui updates, and testing significantly easier.

Main structural change

User-visible behavior changes

  • ollama launch still opens the launcher.
  • ollama launch <integration> still launches/configures that integration.
  • ollama launch --model ..., ollama launch --config, and ollama launch -- ... now error unless an integration name is present.
  • The intended pattern is now:
    • ollama launch claude --model qwen3.5
    • ollama launch droid --config

This is the clearest explicit behavior change in the branch. It removes the confusing “root launcher + pending flags” path instead of preserving it.

Launch safety / model readiness

  • Launch readiness now distinguishes interactive vs headless sessions in cmd/launch/models.go:
    • interactive missing local model: may prompt/pull
    • headless missing local model: fails immediately
    • cloud models keep auth/connectivity behavior and do not attempt local pull

This changes failure behavior in CI/headless cases and is intentionally stricter.

Regression fixes preserved in the branch

  • OpenClaw remains on the editor-style multi-model launch path.
  • Normal editor launches no longer reconfigure on every Enter press.
  • Configure-only flows still work before the integration binary is installed.
  • Cloud sign-in cancellation remains a soft cancel.
  • Selected model visibility in the launcher UI was improved.

These fixes are mixed in with the refactor, so testing should confirm they were preserved after the move.

Cloud config details

  • Cloud model limits are centralized in cmd/launch/models.go.
  • OpenCode and Pi now use the shared cloud limit lookup instead of per-integration copies.
  • Pi now prefers shared cloud limits for known cloud models when /api/show fails or omits usable context metadata, while still letting positive server-provided context length win when present.

OpenCode/Pi cloud config generation is a good area to spot-check because it was part of the rebase conflict resolution.

Risk areas to review closely

  1. Package boundary changes between cmd/config, cmd/launch, and cmd/tui.
  2. Direct-launch flows using --model and --config.
  3. Headless missing-model behavior.
  4. OpenCode/Pi cloud config writes after the rebase.
  5. Root launcher Run a model behavior, since that path still exists even though bare launch --model was removed.

Validation

  • go test ./cmd/... passes on the rebased branch.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/14609 **Author:** [@ParthSareen](https://github.com/ParthSareen) **Created:** 3/4/2026 **Status:** ✅ Merged **Merged:** 3/13/2026 **Merged by:** [@ParthSareen](https://github.com/ParthSareen) **Base:** `main` ← **Head:** `parth-refactor-launch-tui` --- ### 📝 Commits (10+) - [`54f4d68`](https://github.com/ollama/ollama/commit/54f4d6812464dec57ded1221c582c973d2686d10) Refactor launch flow into shared launcher package - [`b55f2b6`](https://github.com/ollama/ollama/commit/b55f2b6b08f22212e57fc736ae3cec4129d90933) Keep selected model visible in More - [`2b625d6`](https://github.com/ollama/ollama/commit/2b625d6b774075ec4dba347b0dd955e96959101f) Fix launcher and cloud model regressions - [`8d1d3b0`](https://github.com/ollama/ollama/commit/8d1d3b0a5df5f79bab623a5158edb357ef5d0d64) Route launch --model through root TUI - [`9e60921`](https://github.com/ollama/ollama/commit/9e6092144e180ef486e25a12c3aec2dbaf1d4b5a) Apply headless-safe missing model launch policy - [`090000c`](https://github.com/ollama/ollama/commit/090000c4021b6b618f4e5fc167054046bb94a38e) Move integration ownership into cmd/launch - [`78e3eda`](https://github.com/ollama/ollama/commit/78e3edad08856ec67b0411e53344096d427634d3) Require integration names for launch flags - [`7c19513`](https://github.com/ollama/ollama/commit/7c19513c5fd1ab65c7c084c7ba901b2953a547bf) Remove unused launch helper wrappers - [`5591463`](https://github.com/ollama/ollama/commit/5591463aeb2c521533b2dda825025f489ee4a22b) Fix launcher regression handling - [`d297629`](https://github.com/ollama/ollama/commit/d29762981f4571fab6d8ec121c4213f657e1b748) Isolate backup temp directories in config tests ### 📊 Changes **42 files changed** (+5182 additions, -3265 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+92 -167) ➕ `cmd/cmd_launcher_test.go` (+233 -0) 📝 `cmd/cmd_test.go` (+41 -20) ➖ `cmd/config/claude.go` (+0 -187) 📝 `cmd/config/config.go` (+13 -33) 📝 `cmd/config/config_cloud_test.go` (+41 -77) 📝 `cmd/config/config_test.go` (+13 -78) ➖ `cmd/config/integrations.go` (+0 -1441) ➖ `cmd/config/selector.go` (+0 -59) ➖ `cmd/config/selector_test.go` (+0 -19) 📝 `cmd/internal/fileutil/files.go` (+10 -6) 📝 `cmd/internal/fileutil/files_test.go` (+63 -43) ➕ `cmd/launch/claude.go` (+77 -0) 📝 `cmd/launch/claude_test.go` (+12 -59) 📝 `cmd/launch/cline.go` (+4 -23) 📝 `cmd/launch/cline_test.go` (+1 -1) 📝 `cmd/launch/codex.go` (+1 -1) 📝 `cmd/launch/codex_test.go` (+1 -1) ➕ `cmd/launch/command_test.go` (+494 -0) 📝 `cmd/launch/droid.go` (+13 -28) _...and 22 more files_ </details> ### 📄 Description ollama launch was created as an isolated package to support integrations. Since its inception, we have added a tui to make it easier to launch and connect to integrations. Currently, there are many diverging paths which follow effectively the same behavior, making it difficult to wire up new integrations or do testing. This PR is in aim to make adding new integrations, tui updates, and testing significantly easier. ### Main structural change - Integration/runtime ownership moved from `cmd/config` into [`cmd/launch/launch.go`](/Users/parth/Documents/repos/ollama-refactor-launch-tui/cmd/launch/launch.go), [`cmd/launch/models.go`](/Users/parth/Documents/repos/ollama-refactor-launch-tui/cmd/launch/models.go), and [`cmd/launch/registry.go`](/Users/parth/Documents/repos/ollama-refactor-launch-tui/cmd/launch/registry.go). - `cmd/config` is now much narrower and mostly persists Ollama’s own config state. - Concrete integrations like Claude, OpenCode, Pi, OpenClaw, etc. now live under [`cmd/launch`](/Users/parth/Documents/repos/ollama-refactor-launch-tui/cmd/launch). ### User-visible behavior changes - `ollama launch` still opens the launcher. - `ollama launch <integration>` still launches/configures that integration. - `ollama launch --model ...`, `ollama launch --config`, and `ollama launch -- ...` now error unless an integration name is present. - The intended pattern is now: - `ollama launch claude --model qwen3.5` - `ollama launch droid --config` This is the clearest explicit behavior change in the branch. It removes the confusing “root launcher + pending flags” path instead of preserving it. ### Launch safety / model readiness - Launch readiness now distinguishes interactive vs headless sessions in [`cmd/launch/models.go`](cmd/launch/models.go): - interactive missing local model: may prompt/pull - headless missing local model: fails immediately - cloud models keep auth/connectivity behavior and do not attempt local pull This changes failure behavior in CI/headless cases and is intentionally stricter. ### Regression fixes preserved in the branch - OpenClaw remains on the editor-style multi-model launch path. - Normal editor launches no longer reconfigure on every Enter press. - Configure-only flows still work before the integration binary is installed. - Cloud sign-in cancellation remains a soft cancel. - Selected model visibility in the launcher UI was improved. These fixes are mixed in with the refactor, so testing should confirm they were preserved after the move. ### Cloud config details - Cloud model limits are centralized in [`cmd/launch/models.go`](cmd/launch/models.go). - OpenCode and Pi now use the shared cloud limit lookup instead of per-integration copies. - Pi now prefers shared cloud limits for known cloud models when /api/show fails or omits usable context metadata, while still letting positive server-provided context length win when present. OpenCode/Pi cloud config generation is a good area to spot-check because it was part of the rebase conflict resolution. ### Risk areas to review closely 1. Package boundary changes between `cmd/config`, `cmd/launch`, and `cmd/tui`. 2. Direct-launch flows using `--model` and `--config`. 3. Headless missing-model behavior. 4. OpenCode/Pi cloud config writes after the rebase. 5. Root launcher `Run a model` behavior, since that path still exists even though bare `launch --model` was removed. ### Validation - `go test ./cmd/...` passes on the rebased branch. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 07:23:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#20019