Skip to content

fix(cli): keep models.dev refresh errors off the TUI - #13107

Merged
johnnyeric merged 1 commit into
mainfrom
johnnyeric/fix-models-dev-tui-logging
Aug 13, 2026
Merged

fix(cli): keep models.dev refresh errors off the TUI#13107
johnnyeric merged 1 commit into
mainfrom
johnnyeric/fix-models-dev-tui-logging

Conversation

@johnnyeric

@johnnyeric johnnyeric commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Issue

No existing gh issue. A live TUI session when models.dev was unreachable: Effect's default logger dumped [HH:MM:SS.mmm] ERROR (#N): Failed to fetch models.dev { cause: { _id: "Cause", ... } } onto the tty and overwrote the prompt footer (Claude Opus 5 Kilo Gateway · high became _id: "Cause",de Opus 5 Kilo Gateway · high).

Context

The TUI listener builds a fresh ModelsDev graph and only Layer.provides AppLayer. That does not install Observability into the ModelsDev construction fiber, so a failed catalog refresh uses Effect's default pretty logger and writes to the tty. AppLayer / createRoutes already provideMerge(Observability.layer) last and do not leak.

Implementation

ModelsDev.node now depends on Observability.node. Construction captures Logger.CurrentLoggers once and refresh() reuses that set. Failed fetches still log at Error to the file/OTLP loggers; they no longer rebuild Observability or dump to the TUI.

Screenshots / Video

N/A — the leaked line is the Effect defaultLogger dump above. No layout or styling change.

How to Test

Manual/local verification

  • Agent: bun test ./test/kilocode/models-dev-logger.test.ts in packages/core — 1 pass.
  • Agent A/B: same test on HEAD fails with Received: "... ERROR (#2):\nFailed to fetch models.dev\n[object Object]"; with the fix it passes.
  • Agent: bun test ./test/models.test.ts ./test/plugin/models-dev.test.ts ./test/kilocode/models-dev-logger.test.ts in packages/core — 12/12.
  • Agent: bun test ./test/provider/provider-model-refresh.test.ts ./test/provider/provider.test.ts in packages/opencode — 100/100 (from the independent review).
  • Agent: bun run script/check-opencode-annotations.ts --worktree passed.

Reviewer test steps

Reproduce the leak on main / this branch's parent (8013e5f504):

  1. From packages/core, force a failed ModelsDev.refresh(true) against a 500 https://models.dev/api.json response without Layer.provideMerge(Observability.layer) — the TUI listener shape is Layer.fresh(listener).pipe(Layer.provide(AppLayer)).
  2. Confirm Effect prints [HH:MM:SS.mmm] ERROR (#N): Failed to fetch models.dev { cause: { _id: "Cause", failures: [[Object ...]] } } to the console.
  3. On this branch, repeat the same failed refresh. The dump must not appear; the error still lands in the file logger (opencode.log).
  4. Optional live TUI: start kilo with outbound models.dev blocked (sandbox / offline). The prompt footer must stay intact instead of being overwritten by _id: "Cause",.

Minimal unit check:

cd packages/core
bun test ./test/kilocode/models-dev-logger.test.ts

That test fails on HEAD and passes here.

Checklist

  • Issue linked above, or exception explained
  • Tests/verification described
  • Screenshots/video included for visual changes, or marked N/A
  • Changeset considered for user-facing changes
  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.

@johnnyeric
johnnyeric marked this pull request as ready for review August 13, 2026 15:39
Comment thread packages/core/test/kilocode/models-dev-logger.test.ts
@kilo-code-bot

kilo-code-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Incremental review of e5c9ef17 (changes since 8aa53f9a): the previous SUGGESTION on packages/core/test/kilocode/models-dev-logger.test.ts is resolved — the test now polls the isolated opencode.log and positively asserts Failed to fetch models.dev is file-logged, pinning both sides of the behavior. No new issues on changed lines.

Files Reviewed (3 files)
  • .changeset/models-dev-tui-logging.md
  • packages/core/src/models-dev.ts
  • packages/core/test/kilocode/models-dev-logger.test.ts

lgtm

Previous Review Summary (commit 8aa53f9)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 8aa53f9)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/core/test/kilocode/models-dev-logger.test.ts 51 Test only asserts the console stays clean; add a positive assertion that the error still lands in the file logger so a regression that swallows errors entirely can't keep the test green
Files Reviewed (3 files)
  • .changeset/models-dev-tui-logging.md - 0 issues
  • packages/core/src/models-dev.ts - 0 issues
  • packages/core/test/kilocode/models-dev-logger.test.ts - 1 issue

The core fix looks correct: capturing Logger.CurrentLoggers at layer construction (with Observability.node now provided as a dependency, so the file/OTLP loggers are installed) and re-providing that set inside refresh() keeps failed catalog refreshes off the TUI while preserving file logging. No cycles, no resource leaks, changeset present and user-facing.

Fix these issues in Kilo Cloud


Reviewed by kimi-k3 · Input: 40.6K · Output: 2.9K · Cached: 153.6K

Review guidance: REVIEW.md from base branch main

Capture CurrentLoggers at ModelsDev construction so a failed catalog
refresh cannot dump Effect's default logger onto the TUI tty.
@johnnyeric
johnnyeric force-pushed the johnnyeric/fix-models-dev-tui-logging branch from 8aa53f9 to e5c9ef1 Compare August 13, 2026 15:51
@johnnyeric
johnnyeric merged commit 746fa97 into main Aug 13, 2026
31 checks passed
@johnnyeric
johnnyeric deleted the johnnyeric/fix-models-dev-tui-logging branch August 13, 2026 16:16
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
Capture CurrentLoggers at ModelsDev construction so a failed catalog
refresh cannot dump Effect's default logger onto the TUI tty.
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