refactor: untangle usage and model-provider boundaries

Draft
SI
14d ago
+240-1058

Summary

  • Share AI SDK usage accumulation through a pure package subpath.
  • Move model-provider parsing, naming and ordering out of SVG components.
  • Share the existing USD display policy; remove a redundant precision branch.
  • Remove proven unreachable usage UI, badge and an identity wrapper.

Part of the user-requested monorepo untangle-codebase pass. Lifecycle, authorization, provider race handling and active UI behavior are preserved. Independent review found no actionable issues.

Verification

  • Repository lint/format and all four package typechecks pass.
  • 558 tests pass, including 12 added behavioral regressions.
  • Eight failures in five files reproduce exactly in pristine origin/main 2546810: sandbox mock missing refreshBaseSnapshot (4), sandbox lifecycle update, post-finish usage timing, chat auto-commit, and archive snapshot refresh.
  • Root CI also references absent apps/web db:check on both branches.

This PR is draft because full CI is not green. It adds no failures, and does not weaken or remove the existing failing tests. No main merge, production deployment, live sandbox or provider call was performed.


Summary by cubic

Refactors model-provider and usage handling into shared modules so UI components and workflows no longer carry their own copies of the policy. No user-facing behavior changes.

Model provider policy

  • Moves provider parsing, display naming, prefix stripping, and ordering into apps/web/lib/model-providers/, with tests.
  • The combobox and model-options list share one ordering function; the session chat options builder was an alias and is gone.

Usage handling

  • addLanguageModelUsage is importable as the pure @open-harness/agent/add-language-model-usage package subpath.
  • Consolidates three duplicated USD formatters into lib/usage/format-usd.ts and drops a redundant precision branch.
  • Removes the unreachable settings usage section and an unused sandbox header badge.

Draft because CI isn't fully green; all four package typechecks and 558 tests pass, including 12 new behavioral regressions. The remaining eight failures reproduce on pristine main and are unrelated.