Skip to content

feat(computers): share projects and worktree policy across computers - #168

Merged
nixuuu merged 1 commit into
feat/linked-shared-config-2from
feat/linked-shared-config-3
Nov 5, 2026
Merged

nixuuu merged 1 commit into
feat/linked-shared-config-2from
feat/linked-shared-config-3

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 5, 2026

Copy link
Copy Markdown
Member

Stage 3 of 7 of shared configuration across linked computers. The design is in docs/linked-computers.md.

What changes

  • Shared: projects (name, kind, archived, origin as identity), project settings without the workspace, and worktree settings for the account and each project, without location.
  • Stays local: workspaces, worktrees, worktree location, and worker-scope worktree settings. Worker records come in stage 6.
  • Identity: projects merge by known git origin, the same rule the picker uses since feat(computers): merge linked projects by git origin #149, and get aliases. Routed calls translate aliased project_id. Projects without an origin merge only by global id.
  • Old mechanism removed: the remaining 0050 opt-in project data is migrated. Its tables (computer_shared_*), its sync loop and its UI (ShareSetting, ShareScope, SharedConfigOverview) are removed, and so is a broken query in moves-preview.ts.
  • UI: shared project fields have no label. Workspaces show their computer and worker. Project fields have conflict notices with Restore.

Migration: 0075_config_projects. Proto (additive): Project.global_id = 801.

Tests: gateway↔gateway integration covers:

  • project rename and settings sync;
  • worktree policy syncs while location stays local;
  • origin merge with aliases, and routed calls with an aliased project id;
  • concurrent edits with Restore;
  • delete with Restore;
  • sharing off;
  • the migration from 0050;
  • owner scoping.

Full suite: 1195 passed, 0 failed.

Copy audit (docs/copy.md §8):

  • "Workers" became "Workspaces".
  • The description is shortened to one sentence.
  • Scope tags are removed.

@nixuuu
nixuuu added this pull request to stack #165 November 5, 2026 11:11
@nixuuu
nixuuu force-pushed the feat/linked-shared-config-3 branch from 08c6c74 to 9191a00 Compare November 5, 2026 12:22
@nixuuu
nixuuu force-pushed the feat/linked-shared-config-3 branch from 9191a00 to 73db7aa Compare November 5, 2026 14:43
@nixuuu
nixuuu marked this pull request as ready for review November 5, 2026 14:43
@nixuuu
nixuuu merged commit 776c085 into dev Nov 5, 2026
10 checks passed
@nixuuu
nixuuu deleted the feat/linked-shared-config-3 branch November 5, 2026 14:51
nixuuu added a commit that referenced this pull request Nov 6, 2026
## Root cause

A shared project (#168) is one overview row with every linked computer's
workspaces. The routed overview merged them only in `GetOverview` and in
updates **from the partner**. When this computer republished its **own**
row of a shared project, the overview stream sent it with local
workspaces only. Triggers include `coreBroadcastWorkers` on any worker
change, renames, `projectsChanged` after a config sync and origin
refreshes. Web and mobile upsert by id, so the merged row lost the
partner's workspaces. A project that lives only on a linked computer
then had `workspaces: []`, and the new-thread picker showed "No worker"
and "… is not on any worker yet".

I reproduced it with two linked gateways. A's `WatchOverview` emitted
the shared project with `workspaces: []` right after A republished it.

## Fix

- `apps/gateway/src/api/routed-overview.ts`: every update of a shared
project goes out with all computers' workspaces, whether it came from
this computer or a partner. A burst (for example, a worker change
republishing every project) reads the overview once, 50 ms coalescing.
If that read fails, the local row still goes out. Mobile is fixed by the
same change.
- `WorkerPicker.svelte`:
- linked workers stay listed until the gateway capabilities load
(before, they were briefly hidden);
- workers on an unreachable computer are greyed out and disabled, with
the presence reason, as on mobile;
- the empty state says "<project>'s workers are not connected." when the
project has workspaces. "not on any worker yet" now appears only when it
is true.
- `docs/linked-computers.md`: notes the merged stream updates.

## Verification

- New `tests/integration/linked-new-thread.test.ts` (two linked
gateways, separate databases):
- A's overview stream keeps B's workspace after A republishes the shared
project. This test fails without the fix.
  - B's worker is in A's overview and online.
  - A thread created from A on B's worker lives on B, in B's project.
- Passed, each file run on its own: `linked-projects`,
`config-sync-projects`, `worktrees`, `worktree-automation` and the db
schema test.
- Clean: `bun install`, `gen:check`, `typecheck`, `lint`, `format:check`
and the web build.
- `check:tmp`: 1517 pass, 3 fail. All 3 failures are in files `dev`
(#294) changed while the run was in progress; all 3 pass when rerun on
the rebased branch.
- Browser, against three linked test gateways and a vite dev BFF:
- wrk-ai only on "Mac-Studio-of-the-team": the picker shows that worker
and the composer is ready (light, desktop);
- pinpoint on two computers: grouped "This computer" /
"Mac-Studio-of-the-team";
- an offline "Mac mini": its worker is greyed out and disabled with
"Offline since …" (dark, iPhone 12 Pro width).

## Not in scope

New worktrees on a linked computer's checkout stay refused on purpose
(docs/worktrees.md, "Połączone komputery", stage 1). Supporting them
needs gateway capability negotiation and is a separate feature.

## Copy audit (docs/copy.md §8)

- New: "{project}'s workers are not connected." It is short and factual,
and it replaces a false claim. No other text changed.

Fixes: #168
nixuuu added a commit that referenced this pull request Nov 12, 2026
Clone outbound stream messages before mapping shared project IDs so local Hub subscribers retain their home project and worktree metadata.

Fixes: #168
nixuuu added a commit that referenced this pull request Nov 12, 2026
Clone outbound stream messages before mapping shared project IDs so local Hub subscribers retain their home project and worktree metadata.

Related: #168
nixuuu added a commit that referenced this pull request Nov 12, 2026
When a linked computer watches a home gateway, its project ID
translation can change the same live thread row that the home's web and
mobile clients receive. A working worktree thread can then show “Unknown
project” even though its stored placement is correct. Clone each
outbound stream message before translating IDs so local clients keep the
home project ID and the peer receives its global ID.

The source of the problem is `remoteServe`: `create(descriptor,
message)` returns an already typed protobuf message unchanged. Hub
subscriptions share those instances, and `ConfigIds.map` mutates project
references in place. Project alias mapping was introduced in #168; #526
and #539/#541/#543 did not introduce this boundary. Both clients resolve
projects by exact `projectId`, so both are affected. The database
placement and `threadSelect` retain the parent project and joined
worktree; this is an ID rewrite, rather than evidence of a partial
status row. No client merge fallback or cwd-based guess is needed.

The gateway integration regression uses two linked databases with merged
project aliases and a side thread inheriting its parent's worktree. A
real worker holds a turn open while overview updates and a resumed
thread delta arrive. It checks the local/global project IDs and branch
before, during and after work, including an unread update while working.
The branch-over-directory presentation change remains in #545, which
uses the same domain helper on mobile and web.

Validation: scoped `nice -n 19` oxlint and oxfmt checks passed; `git
diff --check` passed. Local installation, typecheck, tests, builds,
fingerprints, browser and render measurements remain deferred at the
maintainer's request while host diagnostics run. GitHub CI will run the
required suite. The local commit hook was skipped using its supported
`SKIP_SIMPLE_GIT_HOOKS` switch because commitlint is not installed in
this worktree and local install is deferred; CI validates the Angular
title.

Copy audit (`docs/copy.md` §8): no UI strings, labels, errors, empty
states or actions changed. The existing “Unknown project” fallback
remains; this fix supplies its correct project reference. Documentation
change is in Polish. No mobile/native dependencies, client subscriptions
or timers changed.

Related: #168
Related: #545
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.

1 participant