Skip to content

Commit ed4d026

Browse files
Move local workspace ownership into OpenWork server (anomalyco#1107)
* feat(server): move local workspace ownership off Tauri * docs: clarify architecture authority for agents * fix: harden workspace reconnect and sidebar navigation * feat(app): soften get-started copy in workspace onboarding * fix(app): stabilize starter workspace onboarding * fix(app): normalize local workspace paths
1 parent 3709ea3 commit ed4d026

23 files changed

Lines changed: 1325 additions & 185 deletions

‎AGENTS.md‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ User mental model:
3838
* A worker is a remote runtime destination.
3939
* Connecting to a worker happens through `Add worker` -> `Connect remote` using URL + token (or deep link).
4040

41-
Read INFRASTRUCTURE.md
41+
Read `ARCHITECTURE.md` for runtime flow, server-vs-shell ownership, and architecture behavior. Read `INFRASTRUCTURE.md` for deployment and control-plane details.
4242

4343
## Why OpenWork Exists
4444

@@ -126,12 +126,13 @@ Design principles for hot reload:
126126
## Repository Guidance
127127

128128
* Use `VISION.md`, `PRINCIPLES.md`, `PRODUCT.md`, `ARCHITECTURE.md`, and `INFRASTRUCTURE.md` to understand the "why" and requirements so you can guide your decisions.
129+
* Treat `ARCHITECTURE.md` as the authoritative system design source for runtime flow, server ownership, filesystem mutation policy, and agent/runtime boundaries. If those behaviors change, update `ARCHITECTURE.md` in the same task.
129130
* Use `DESIGN-LANGUAGE.md` as the default visual reference for OpenWork app and landing work.
130131
* For OpenWork session-surface details, also reference `packages/docs/orbita-layout-style.mdx`.
131132

132133
## Dev Debugging
133134

134-
* If you change `packages/server/src`, rebuild the OpenWork server binary (`pnpm --filter openwork-server build:bin`) because `openwork` (openwork-orchestrator) runs the compiled server, not the TS sources.
135+
* If you change `apps/server/src`, rebuild the OpenWork server binary (`pnpm --filter openwork-server build:bin`) because `openwork` (openwork-orchestrator) runs the compiled server, not the TS sources.
135136

136137
## Local Structure
137138

@@ -144,7 +145,7 @@ openwork/
144145
ARCHITECTURE.md # Runtime modes and OpenCode integration
145146
.gitignore # Ignores vendor/opencode, node_modules, etc.
146147
.opencode/
147-
packages/
148+
apps/
148149
app/
149150
src/
150151
public/
@@ -154,6 +155,9 @@ openwork/
154155
desktop/
155156
src-tauri/
156157
package.json
158+
server/
159+
src/
160+
package.json
157161
```
158162

159163
## OpenCode SDK Usage
@@ -190,7 +194,7 @@ Key primitives to expose:
190194

191195
## Skill: SolidJS Patterns
192196

193-
When editing SolidJS UI (`packages/app/src/**/*.tsx`), consult:
197+
When editing SolidJS UI (`apps/app/src/**/*.tsx`), consult:
194198

195199
* `.opencode/skills/solidjs-patterns/SKILL.md`
196200

@@ -206,11 +210,11 @@ OpenWork releases are built by GitHub Actions (`Release App`). A release is trig
206210
1. Ensure `main` is green and up to date.
207211
2. Bump versions (keep these in sync):
208212

209-
* `packages/app/package.json` (`version`)
210-
* `packages/desktop/package.json` (`version`)
211-
* `packages/orchestrator/package.json` (`version`, publishes as `openwork-orchestrator`)
212-
* `packages/desktop/src-tauri/tauri.conf.json` (`version`)
213-
* `packages/desktop/src-tauri/Cargo.toml` (`version`)
213+
* `apps/app/package.json` (`version`)
214+
* `apps/desktop/package.json` (`version`)
215+
* `apps/orchestrator/package.json` (`version`, publishes as `openwork-orchestrator`)
216+
* `apps/desktop/src-tauri/tauri.conf.json` (`version`)
217+
* `apps/desktop/src-tauri/Cargo.toml` (`version`)
214218

215219
You can bump all three non-interactively with:
216220

@@ -244,11 +248,11 @@ Confirm the DMG assets are attached and versioned correctly.
244248
This is usually covered by `Release App` when `publish_sidecars` + `publish_npm` are enabled. Use `.opencode/skills/openwork-orchestrator-npm-publish/SKILL.md` for manual recovery or one-off publishing.
245249

246250
1. Ensure the default branch is up to date and clean.
247-
2. Bump `packages/orchestrator/package.json` (`version`).
251+
2. Bump `apps/orchestrator/package.json` (`version`).
248252
3. Commit the bump.
249253
4. Build and upload sidecar assets for the same version tag:
250254
* `pnpm --filter openwork-orchestrator build:sidecars`
251-
* `gh release create openwork-orchestrator-vX.Y.Z packages/orchestrator/dist/sidecars/* --repo different-ai/openwork`
255+
* `gh release create openwork-orchestrator-vX.Y.Z apps/orchestrator/dist/sidecars/* --repo different-ai/openwork`
252256
5. Publish:
253257
* `pnpm --filter openwork-orchestrator publish --access public`
254258
6. Verify:

‎ARCHITECTURE.md‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ Auto-detection can exist as a convenience, but should be tiered and explainable:
3030

3131
The readiness check should be a clear, single command (e.g. `docker info`) and the UI should show the exact error output when it fails.
3232

33+
## Minimal use of Tauri
34+
We move most of the functionality to the openwork server which interfaces mostly with FS and proxies to opencode.
35+
36+
37+
3338
## Filesystem mutation policy
3439

3540
OpenWork should route filesystem mutations through the OpenWork server whenever possible.
@@ -47,6 +52,36 @@ Guidelines:
4752
- If a feature cannot yet write through the OpenWork server, treat that as an architecture gap and close it before depending on direct local writes.
4853
- Reads can fall back locally when necessary, but writes should be designed around the OpenWork server path.
4954

55+
## Agent authority map
56+
57+
When OpenWork is edited from `openwork-enterprise`, architecture and runtime behavior should be sourced from this document.
58+
59+
| Entry point | Role | Architecture authority |
60+
| --- | --- | --- |
61+
| `openwork-enterprise/AGENTS.md` | OpenWork Factory multi-repo orchestration | Defers OpenWork runtime flow, server-vs-shell ownership, and filesystem mutation behavior to `_repos/openwork/ARCHITECTURE.md`. |
62+
| `openwork-enterprise/.opencode/agents/openwork-surgeon.md` | Surgical fix agent for `_repos/openwork` | Uses `_repos/openwork/ARCHITECTURE.md` as the runtime and architecture source of truth before changing product behavior. |
63+
| `_repos/openwork/AGENTS.md` | Product vocabulary, audience, and repo-local development guidance | Refers to `ARCHITECTURE.md` for runtime flow, server ownership, and architectural boundaries. |
64+
| Skills / commands / agents that mutate workspace state | Capability layer on top of the product runtime | Should assume the OpenWork server path is canonical for workspace creation, config writes, `.opencode/` mutation, and reload signaling. |
65+
66+
### Agent access to server-owned behavior
67+
68+
Agents, skills, and commands should model the following as OpenWork server behavior first:
69+
70+
- workspace creation and initialization
71+
- writes to `.opencode/`, `opencode.json`, and `opencode.jsonc`
72+
- OpenWork workspace config writes (`.opencode/openwork.json`)
73+
- reload event generation after config or capability changes
74+
- other filesystem-backed capability changes that must work across desktop host mode and remote clients
75+
76+
Tauri or other native shell behavior remains the fallback or shell boundary for:
77+
78+
- file and folder picking
79+
- reveal/open-in-OS affordances
80+
- updater and window management
81+
- host-side process supervision and native runtime bootstrapping
82+
83+
If an agent needs one of the server-owned behaviors above and only a Tauri path exists, treat that as an architecture gap to close rather than a parallel capability surface to preserve.
84+
5085
## opencode primitives
5186
how to pick the right extension abstraction for
5287
@opencode

‎apps/app/src/app/app.tsx‎

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3023,6 +3023,8 @@ export default function App() {
30233023
openworkServerSettings,
30243024
updateOpenworkServerSettings,
30253025
openworkServerClient,
3026+
openworkServerStatus,
3027+
openworkServerWorkspaceId,
30263028
onEngineStable: () => {},
30273029
engineRuntime,
30283030
developerMode,
@@ -3324,6 +3326,26 @@ export default function App() {
33243326
? allSessions.filter((session) => normalizeDirectoryPath(session.directory) === activeWorkspaceRoot)
33253327
: allSessions;
33263328
const sorted = sortSessionsByActivity(scopedSessions);
3329+
if (developerMode()) {
3330+
console.log("[sidebar-sync] workspace session scope", {
3331+
wsId,
3332+
status,
3333+
activeWorkspace,
3334+
activeWorkspaceRoot,
3335+
allSessions: allSessions.map((session) => ({
3336+
id: session.id,
3337+
title: session.title,
3338+
directory: session.directory,
3339+
parentID: session.parentID,
3340+
})),
3341+
scopedSessions: scopedSessions.map((session) => ({
3342+
id: session.id,
3343+
title: session.title,
3344+
directory: session.directory,
3345+
parentID: session.parentID,
3346+
})),
3347+
});
3348+
}
33273349
const rootItems: SidebarSessionItem[] = sorted.map((s) => ({
33283350
id: s.id,
33293351
title: s.title,
@@ -3421,6 +3443,22 @@ export default function App() {
34213443
}
34223444
return dedupedWorkspaces.map((workspace) => {
34233445
const groupSessions = sessionsById[workspace.id] ?? [];
3446+
if (developerMode()) {
3447+
console.log("[sidebar-groups] workspace group", {
3448+
workspaceId: workspace.id,
3449+
workspaceName: workspace.name,
3450+
workspaceType: workspace.workspaceType,
3451+
workspacePath: workspace.path,
3452+
workspaceDirectory: workspace.directory,
3453+
sessionCount: groupSessions.length,
3454+
sessions: groupSessions.map((session) => ({
3455+
id: session.id,
3456+
title: session.title,
3457+
directory: session.directory,
3458+
parentID: session.parentID,
3459+
})),
3460+
});
3461+
}
34243462
return {
34253463
workspace,
34263464
sessions: groupSessions,
@@ -3518,7 +3556,7 @@ export default function App() {
35183556
if (cancelled) return;
35193557
const items = Array.isArray(response.items) ? response.items : [];
35203558
const match = items.find((entry) => normalizeDirectoryPath(entry.path) === root);
3521-
setOpenworkServerWorkspaceId(match?.id ?? response.activeId ?? null);
3559+
setOpenworkServerWorkspaceId(match?.id ?? null);
35223560
} catch {
35233561
if (!cancelled) setOpenworkServerWorkspaceId(null);
35243562
}
@@ -3608,7 +3646,7 @@ export default function App() {
36083646
};
36093647

36103648
const findSharedBundleImportWorkspaceId = (
3611-
items: Array<{ id: string; path?: string; directory?: string; opencode?: { directory?: string } }>,
3649+
items: Array<{ id: string; path?: string | null; directory?: string | null; opencode?: { directory?: string | null } }>,
36123650
target?: SharedBundleImportTarget,
36133651
) => {
36143652
const explicitId = target?.workspaceId?.trim() ?? "";
@@ -4903,16 +4941,14 @@ export default function App() {
49034941

49044942
// Scheduler helpers - must be defined after workspaceStore
49054943
const resolveOpenworkScheduler = () => {
4906-
const isRemoteWorkspace = workspaceStore.activeWorkspaceDisplay().workspaceType === "remote";
4907-
if (!isRemoteWorkspace) return null;
49084944
const client = openworkServerClient();
49094945
const workspaceId = openworkServerWorkspaceId();
49104946
if (openworkServerStatus() !== "connected" || !client || !workspaceId) return null;
49114947
return { client, workspaceId };
49124948
};
49134949

49144950
const scheduledJobsSource = createMemo<"local" | "remote">(() => {
4915-
return workspaceStore.activeWorkspaceDisplay().workspaceType === "remote" ? "remote" : "local";
4951+
return resolveOpenworkScheduler() ? "remote" : "local";
49164952
});
49174953

49184954
const scheduledJobsSourceReady = createMemo(() => {
@@ -5620,6 +5656,25 @@ export default function App() {
56205656
}
56215657
}
56225658

5659+
const readMcpConfigFile = async (scope: "project" | "global") => {
5660+
const projectDir = workspaceProjectDir().trim();
5661+
const openworkClient = openworkServerClient();
5662+
const openworkWorkspaceId = openworkServerWorkspaceId();
5663+
const canUseOpenworkServer =
5664+
openworkServerStatus() === "connected" &&
5665+
openworkClient &&
5666+
openworkWorkspaceId &&
5667+
resolvedOpenworkCapabilities()?.config?.read;
5668+
5669+
if (canUseOpenworkServer && openworkClient && openworkWorkspaceId) {
5670+
return openworkClient.readOpencodeConfigFile(openworkWorkspaceId, scope);
5671+
}
5672+
if (!isTauriRuntime()) {
5673+
return null;
5674+
}
5675+
return readOpencodeConfig(scope, projectDir);
5676+
};
5677+
56235678
async function connectMcp(entry: (typeof MCP_QUICK_CONNECT)[number]) {
56245679
const startedAt = perfNow();
56255680
const isRemoteWorkspace =
@@ -7109,6 +7164,10 @@ export default function App() {
71097164
setTab("settings");
71107165
setView("dashboard");
71117166
},
7167+
onOpenAdvancedSettings: () => {
7168+
setTab("config");
7169+
setView("dashboard");
7170+
},
71127171
themeMode: themeMode(),
71137172
setThemeMode,
71147173
});
@@ -7217,6 +7276,8 @@ export default function App() {
72177276
testWorkspaceConnection: workspaceStore.testWorkspaceConnection,
72187277
recoverWorkspace: workspaceStore.recoverWorkspace,
72197278
openCreateWorkspace: () => workspaceStore.setCreateWorkspaceOpen(true),
7279+
getStartedWorkspace: workspaceStore.quickStartWorkspaceFlow,
7280+
pickFolderWorkspace: workspaceStore.createWorkspaceFromPickedFolder,
72207281
openCreateRemoteWorkspace: () => workspaceStore.setCreateRemoteWorkspaceOpen(true),
72217282
connectRemoteWorkspace: workspaceStore.createRemoteWorkspaceFlow,
72227283
importWorkspaceConfig: workspaceStore.importWorkspaceConfig,
@@ -7391,6 +7452,7 @@ export default function App() {
73917452
mcpConnectingName: mcpConnectingName(),
73927453
selectedMcp: selectedMcp(),
73937454
setSelectedMcp,
7455+
readConfigFile: readMcpConfigFile,
73947456
quickConnect: MCP_QUICK_CONNECT,
73957457
connectMcp,
73967458
authorizeMcp,
@@ -7449,6 +7511,8 @@ export default function App() {
74497511
editWorkspaceConnection: openWorkspaceConnectionSettings,
74507512
forgetWorkspace: workspaceStore.forgetWorkspace,
74517513
openCreateWorkspace: () => workspaceStore.setCreateWorkspaceOpen(true),
7514+
getStartedWorkspace: workspaceStore.quickStartWorkspaceFlow,
7515+
pickFolderWorkspace: workspaceStore.createWorkspaceFromPickedFolder,
74527516
openCreateRemoteWorkspace: () => workspaceStore.setCreateRemoteWorkspaceOpen(true),
74537517
importWorkspaceConfig: workspaceStore.importWorkspaceConfig,
74547518
importingWorkspaceConfig: workspaceStore.importingWorkspaceConfig(),

‎apps/app/src/app/components/workspace-right-sidebar.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
ChevronLeft,
55
ChevronRight,
66
History,
7+
MessageCircle,
78
Settings,
89
SlidersHorizontal,
910
X,
@@ -30,6 +31,7 @@ type Props = {
3031
onOpenAutomations: () => void;
3132
onOpenSkills: () => void;
3233
onOpenExtensions: () => void;
34+
onOpenMessaging: () => void;
3335
onOpenAdvanced: () => void;
3436
onOpenSettings: () => void;
3537
onInboxToast?: (message: string) => void;
@@ -117,6 +119,12 @@ export default function WorkspaceRightSidebar(props: Props) {
117119
showSelection() && (props.tab === "mcp" || props.tab === "plugins"),
118120
props.onOpenExtensions,
119121
)}
122+
{sidebarButton(
123+
"Messaging",
124+
<MessageCircle size={18} />,
125+
showSelection() && props.tab === "identities",
126+
props.onOpenMessaging,
127+
)}
120128
<Show when={props.developerMode}>
121129
{sidebarButton(
122130
"Advanced",

‎apps/app/src/app/context/session.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,24 @@ export function createSessionStore(options: {
686686
// string equality against the stored session.directory.
687687
const queryDirectory = normalizeDirectoryQueryPath(scopeRoot) || undefined;
688688

689+
sessionDebug("sessions:load:request", {
690+
scopeRoot: scopeRoot ?? null,
691+
queryDirectory: queryDirectory ?? null,
692+
activeWorkspaceRoot: options.activeWorkspaceRoot?.() ?? null,
693+
});
694+
689695
const start = Date.now();
690696
sessionDebug("sessions:load:start", { scopeRoot: scopeRoot ?? null, queryDirectory: queryDirectory ?? null });
691697
const list = unwrap(await c.session.list({ directory: queryDirectory, roots: true }));
698+
sessionDebug("sessions:load:response", {
699+
count: list.length,
700+
sessions: list.map((session) => ({
701+
id: session.id,
702+
title: session.title,
703+
directory: session.directory,
704+
parentID: session.parentID,
705+
})),
706+
});
692707
sessionDebug("sessions:load:raw", { count: list.length, ms: Date.now() - start });
693708

694709
// Defensive client-side filter in case the server returns sessions spanning
@@ -697,6 +712,16 @@ export function createSessionStore(options: {
697712
const filtered = root
698713
? list.filter((session) => normalizeDirectoryPath(session.directory) === root)
699714
: list;
715+
sessionDebug("sessions:load:filtered-list", {
716+
root: root || null,
717+
count: filtered.length,
718+
sessions: filtered.map((session) => ({
719+
id: session.id,
720+
title: session.title,
721+
directory: session.directory,
722+
parentID: session.parentID,
723+
})),
724+
});
700725
sessionDebug("sessions:load:filtered", { root: root || null, count: filtered.length });
701726
rememberSessions(filtered);
702727
setStore("sessions", reconcile(sortSessionsByActivity(filtered), { key: "id" }));

0 commit comments

Comments
 (0)