Skip to content

fix: Local models page copy and feedback, attachment limit, gateway-home cause (0.1.4 E2) - #237

Closed
oldwinter53 wants to merge 3 commits into
mainfrom
oldwinter/014-e2
Closed

oldwinter53 wants to merge 3 commits into
mainfrom
oldwinter/014-e2

Conversation

@oldwinter53

Copy link
Copy Markdown

Summary

0.1.4 E2 (FIXLIST P2-11, P2-18; GitHub #183): Local models page copy and action feedback, the attachment size limit, and the localmodels dev40 GATEWAY_HOME_NOT_PRIVATE cause end to end. Three commits, each with its own regenerated contracts.

1. Make room no longer blames the model when other apps hold the memory (local-model-dialogs.tsx, local-models-rules.ts)

 MakeRoomDialog
   <fieldset> loaded models to unload (unchanged)
-  nothing loaded → "doesn't fit even when the memory is empty"
+  need > pool total          → "<model> needs more than all <total> of <pool>, so it can't load there."
+  unloading all isn't enough → <ul "Also using this memory">
+                                  Other apps   <used_bytes − Σ holders>
+                                  <component>  <bytes>
+                                "Close other apps that use GPU 0, then try again."
+                                (or "Choose a smaller model." when no other app holds any)

otherAppsBytes(pool) now lives in the rules and the Details pool bar uses it too.

2. Show actions that are under way (local-model-row.tsx, local-models-page.tsx)

 row status while a request is pending or accepted but not yet in a snapshot
   load → Loading, download → Downloading            (unchanged)
+  cancel → Cancelling (Discarding for a stopped download)
+  unload → Unloading, remove → Removing
 row actions
-  off until a snapshot reflects the accepted download
+  Cancel works as soon as the Computer accepts the download

3. Attachment limit names the number (TeamHub handlers_message_attachment.go, use-composer-attachments.ts)

 413 PAYLOAD_TOO_LARGE
+  details: [{field: content, code: too_large, limit_bytes: 52428800}]   # ErrorDetail.limit_bytes, additive
 composer
-  "big.zip: message attachment exceeds the configured limit"
+  "big.zip: Attachments can be up to 50 MB, and this file is 60 MB."

4. GATEWAY_HOME_NOT_PRIVATE reaches the page

sequenceDiagram
    participant LM as localmodels dev40
    participant D as Daemon (internal/localmodels)
    participant NS as Agent Service
    participant TH as TeamHub
    participant W as Web
    LM->>D: load job error line {code GATEWAY_REGISTRATION_FAILED, cause, path}
    Note over D: keeps cause per model; library status has only code+detail
    D->>NS: snapshot, row error + cause/path (each read, while the row still fails with that code)
    NS->>TH: record (envelope schema validates cause enum)
    TH->>W: view; path only for the Computer owner, unknown cause refused
    W->>W: "…the folder <path> belongs to another account. Quit Linger, rename that folder, then open Linger and load the model again."
Loading

The owner's next accepted job for that model drops the kept cause, as does a row that has moved on. The cause lives in Daemon memory, so after a Daemon restart the row shows only the code copy. Contract changes are additive: LocalModelError.cause and path in both the Runner Gateway envelope and OpenAPI.

Docs: apps/web/AGENTS.md (labels, early Cancel, Make room) and apps/computer/local-daemon/README.md (error causes).

Not in this PR: an unload or remove refusal that carries the cause still maps to LOCAL_MODEL_ACTION_FAILED, because the cause reaches the page only through a failed load's row. "Recommended jumps rows mid-download" (precheck N1) is also not covered.

User message → provider_ready path: untouched. This PR adds no round trip or file walk there.

Evidence

Every behavior test below failed first, before its implementation:

  • Web (local-models-page.test.tsx)
    • "names the apps holding the memory instead of calling the model too big"
    • "lists other apps when unloading every model still isn't enough"
    • "says so when nothing else in the pool can be unloaded" (now says a model can't fit only when it is bigger than the whole pool)
    • "shows a download as cancelling from the click until the Computer stops it": the row read Downloading · 32% before and reads Cancelling after
    • "lets an accepted download be cancelled before its first progress": Cancel was disabled before and is enabled after
    • "spins and disables the row's button while an unload is sent": the row now reads Unloading
    • "explains a gateway folder another account owns", for the owner (with the path) and without the path
  • Web (message-composer.test.tsx): "names the file's size and the attachment limit when TeamHub refuses a large file"
  • TeamHub
    • TestMessageAttachmentTooLargeNamesTheLimit covers both the file-size path and the MaxBytesReader path
    • TestLocalModelsViewShowsTheCausePathOnlyToTheOwner
    • TestValidLocalModelsSnapshot/unknown error cause
  • Daemon: TestAFailedLoadKeepsTheGatewayCauseOnItsRow shows the cause on the failed row, keeps it across later reads, and drops it after a retry that fails without one

Checks run locally on this branch:

  • make check BASE=origin/main passed except one test, cmd/linger-computer-daemon TestManagedToolsUpdateKeepsResidentDaemonPID ("Managed tools require Node 26.5.0"). It fails the same way on a clean origin/main worktree on this host, so it is environmental and not caused by this branch. The rest of check-computer passed when run separately: internal/provider/native and the go-local-daemon-process test.
  • make check-repository-gate BASE=origin/main passed.
  • TeamHub fmt-check and tests/integration/layout passed.
  • Contracts were regenerated and verified.

Real-machine checks for the 0.1.4 RC round

  1. Windows, NVIDIA 16 GB with other GPU apps open: Load a model that fits an empty card but not the free memory. Make room lists "Other apps N GB" and asks to close them; it never says "doesn't fit even when empty".
  2. Any platform: Download a model, then press Cancel right away, before the first progress tick. Cancel is enabled, the row reads Cancelling until the model is back to Not downloaded, and Unload and Remove show Unloading and Removing.
  3. Any platform: Attach a file larger than 50 MB in a Room. The composer shows ": Attachments can be up to 50 MB, and this file is N MB."
  4. Windows: Make a gateway-home owned by another account that localmodels cannot reclaim (for example SYSTEM, not Administrators), then Load. The owner's row details show the folder path and the rename instruction. Another Tenant member sees the copy without the path.

Merge Danger

Door: two-way

The contract fields are optional and additive, and there is no migration or stored-data change. A revert drops the fields again, and snapshots already stored keep decoding.

Blast Radius: small

The changes are limited to the Local models page copy and row labels, one TeamHub 413 body (one new detail added), and Daemon snapshots, which can now carry cause/path on a failed row. Older TeamHub or Agent Service builds that receive a dev40 Daemon snapshot with a cause would reject it under the old envelope schema, so ship the Daemon with this TeamHub and Agent Service, as the desktop bundle already does.

🤖 Generated with Claude Code

oldwinter90 and others added 3 commits November 19, 2026 03:19
Make room said a model "doesn't fit even when the memory is empty" whenever
no other model was loaded in its pool, though on a shared card other apps or
Linger's components held the memory. It now says a model can't fit only when
it needs more than the pool's total; otherwise, when unloading every loaded
model is not enough, it lists what else holds the pool (components, and other
apps from the used bytes no holder accounts for) and asks to close other apps.

A cancel, unload or remove under way now labels its row Cancelling,
Unloading or Removing (Discarding for a stopped download) until a snapshot
moves the model on, and a download the Computer accepted can be cancelled
before its first progress reaches a snapshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An oversized Message attachment showed "message attachment exceeds the
configured limit" with no number. TeamHub now adds an ErrorDetail with code
too_large and the new limit_bytes field to its PAYLOAD_TOO_LARGE answer, and
the composer reads that structured limit to say how large attachments may be
and how large the file is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
localmodels 0.1.0.dev40 adds cause GATEWAY_HOME_NOT_PRIVATE and the folder's
path to a GATEWAY_REGISTRATION_FAILED error line, while its status row keeps
only the code. LocalModelError gains optional cause and path in the Runner
Gateway and TeamHub contracts. The Daemon keeps the cause of a job's error
line per model and puts it back on that row in every read while it still
fails with that code; the model's next accepted job drops it. TeamHub
refuses an unknown cause and shows the path only to the Computer's owner,
and the Local models page tells the owner to quit Linger and rename that
folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve with nits (1 P2)

Scope: base main at merge-base 080cbcf9 (equal to current origin/main, so no rebase needed); 3 commits, 31 files reviewed at 9c195ef8. Helper skills loaded: coderbook; ponytail-review and karpathy-guidelines were not loaded, but their checklists were applied from the review instructions. Ran in a separate session.

Findings

P2

apps/computer/local-daemon/internal/localmodels/library.go:207 (restoreCauses): a status read that was already running can drop a cause that was just saved.
superviseJob saves the cause under l.mu (line ~557) and then calls Refresh, which waits on refreshMu. While the load job is adopted, reconcile keeps polling (hasAdoptedJobLocked), and phaseStarted and owner-triggered Refresh also read status. If one of those reads started its localmodels status process before the tool wrote the failed row, it still sees the model as loading. It then reaches restoreCauses after the cause was saved, finds Error == nil (or a different code), and deletes the cause. The Refresh that follows reads the failed row with no cause, so the owner sees only the generic GATEWAY_REGISTRATION_FAILED copy and never the folder or the rename instruction. The race window is one status read overlapping the end of the job. Process spawn on Windows makes it wider, and Windows is the platform where this cause occurs. The new test does not exercise a concurrent read.
Fix: let only reads that began after the cause was saved decide whether to forget it. For example, store a sequence or now() with the cause, take the same stamp before runOnce in read, and skip the delete when the read is older. An accepted job already clears the cause, so the snapshot-based delete only needs to handle reads that are newer than the cause.

Verified as fine

  • Daemon: libraryEvent.cause() accepts only a known code, a known cause and a non-empty path, and clips the path to the schema's 4096 limit. The next accepted job clears the cause, and a retry that fails without a cause leaves nothing stale behind (covered by TestAFailedLoadKeepsTheGatewayCauseOnItsRow). read runs under refreshMu and never under mu, so taking mu in restoreCauses cannot deadlock.
  • TeamHub: localModelsView is the only public reader of the stored snapshot (handlers_local_models.go:90/99), and it sets Error.Path to nil for non-owners. validLocalModelsSnapshot refuses an unknown cause. Both have tests.
  • The 413 detail goes through the existing writeErrorWithDetails. limit_bytes is an additive optional field on ErrorDetail. The test covers both the ErrTooLarge path and the MaxBytesReader path. formatBytes uses base 1024, so 52428800 bytes shows as "50 MB", as the PR says.
  • Contracts: the OpenAPI and Runner Gateway envelope changes are additive and optional, and the generated files match (check (contracts) passed).
  • Web: otherAppsBytes is moved into the rules module rather than copied, and the pool bar reuses it. In Make room, the "too big" message is now based on needBytes > total_bytes, and holders that Make room cannot unload are listed. The new row labels for cancel, unload and remove, and early Cancel for an accepted download (busy), match the apps/web/AGENTS.md update. Copy logic keys on structured cause and code, never on prose.
  • Docs: apps/web/AGENTS.md and apps/computer/local-daemon/README.md are updated in the same PR. The PR body's claims (tests listed, additive contracts, path visible only to the owner, cause lost after a Daemon restart) match the diff.
  • No new dependencies, migrations or env vars.

Process notes

  • No merge commits and no fixup commits. Each commit has a descriptive body.

CI

All checks pass, including check (teamhub), check (computer-go), check (contracts), web tests 1–3 and repository-gate. I ran no tests myself; the finding comes from reading the code. CI's check (computer-go) runs without -race.

Automated review by Claude Code


Automated review of 9c195ef by Claude Code.

@oldwinter53

Copy link
Copy Markdown
Author

Consolidated into #249 with #230 and #237 (same commits, replayed on the newest main and merged with #242's Make room changes; the body carries this PR's description, tests and real-machine checks). Please review there.

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