Skip to content

Commit d8c864e

Browse files
author
ben
authored
chore: remove explanatory comments across the repo (#7653)
Delete about 30,700 comments from 2,840 TypeScript files in apps, packages and ee. Kept: directives (@ts-*, eslint, biome, prettier, webpack, coverage), build annotations (#__PURE__, #region), license headers, issue and RFC links, and doc comments on exported package APIs. Tests, declarations and generated files are untouched. No new parse errors; every package typechecks.
1 parent 8e2480e commit d8c864e

2,840 files changed

Lines changed: 169 additions & 51862 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/app/dev-den-proxy.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ interface DevDenProxyOptions {
55
}
66

77
export function devDenProxy(env: NodeJS.ProcessEnv): Record<string, DevDenProxyOptions> {
8-
// A local Den API is a separate service from its web UI. Proxy to it
9-
// directly so a cross-origin redirect cannot strip the member's bearer.
108
const apiTarget = env.OPENWORK_DEV_HEADLESS_DEN_API_TARGET?.trim();
119
const target = apiTarget || env.OPENWORK_DEV_HEADLESS_DEN_TARGET?.trim();
1210
if (!target) return {};

‎apps/app/src/app/cloud/desktop-app-restrictions.ts‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ export function checkDesktopAppRestriction(input: {
2020
config: DenDesktopConfig | null | undefined;
2121
restriction: DesktopAppRestrictionKey;
2222
}) {
23-
// OpenCode Zen is retired, including signed-out and offline use. Reuse the
24-
// restriction every surface already honors (model list, Connect, Automations
25-
// and the engine's disabled providers), regardless of organization policy.
2623
if (input.restriction === "allowZenModel") {
2724
return true;
2825
}
@@ -34,28 +31,16 @@ export function checkDesktopAppRestriction(input: {
3431

3532
const RETIRED_OPENCODE_ZEN_TERMS = "opencode zen big pickle free";
3633

37-
/**
38-
* Whether Connect a provider shows OpenCode Zen as retired where it used to be
39-
* listed: only while Zen itself is missing from the list, and for an empty
40-
* search or one a person looking for Zen would type.
41-
*/
4234
export function showsRetiredOpencodeZen(input: { providerIds: readonly string[]; query: string }) {
4335
if (input.providerIds.some((id) => id.trim().toLowerCase() === DESKTOP_RESTRICTION_OPENCODE_PROVIDER_ID)) return false;
4436
const query = input.query.trim().toLowerCase();
4537
return !query || RETIRED_OPENCODE_ZEN_TERMS.includes(query);
4638
}
4739

48-
/** Catalog copy explaining why the organization blocked a capability. */
4940
export function desktopRestrictionNotice(restriction: DesktopAppRestrictionKey) {
5041
return desktopPolicyUserNotices[restriction];
5142
}
5243

53-
/**
54-
* Settings tabs that stay reachable when `allowControlSettings` is blocked.
55-
* Members can still see their Cloud account, switch organizations, and use
56-
* Cloud features that are not desktop settings; every other tab is hidden and
57-
* redirected.
58-
*/
5944
const SETTINGS_TABS_WITHOUT_CONTROL = new Set<SettingsTab>(["cloud-account", "usage", "devices"]);
6045

6146
export const SETTINGS_TAB_WITHOUT_CONTROL: SettingsTab = "cloud-account";
@@ -78,7 +63,6 @@ export function isDesktopProviderBlocked(input: {
7863
if (providerId === DESKTOP_RESTRICTION_OPENCODE_PROVIDER_ID) {
7964
return input.checkRestriction({ restriction: "allowZenModel" });
8065
}
81-
// Ollama and LM Studio follow the organization's local models switch.
8266
if (isLocalModelProviderId(providerId)) {
8367
return input.checkRestriction({ restriction: "allowLocalModels" });
8468
}

‎apps/app/src/app/cloud/desktop-cloud-sync.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ function readSyncChange(value: unknown): OpenworkDesktopCloudSyncChange | null {
4343
};
4444
}
4545

46-
/** Read all pending changes from a persisted desktop-cloud-sync state (GET response). */
4746
export function readPendingCloudSyncChanges(state: OpenworkDesktopCloudSyncState): OpenworkDesktopCloudSyncChange[] {
4847
return Object.values(state.entries).flatMap((entry) => {
4948
if (!isRecord(entry) || !Array.isArray(entry.pendingChanges)) return [];
@@ -54,12 +53,6 @@ export function readPendingCloudSyncChanges(state: OpenworkDesktopCloudSyncState
5453
});
5554
}
5655

57-
/**
58-
* Derive a map of installed cloud plugin id -> pending change.
59-
* "modified" means an update is available; "removed" means the plugin was
60-
* removed upstream. Stale changes (already applied locally or for plugins
61-
* no longer installed) are filtered out.
62-
*/
6356
export function derivePendingCloudPluginChanges(input: {
6457
changes: OpenworkDesktopCloudSyncChange[];
6558
installedPlugins: Record<string, InstalledCloudPluginLike>;

‎apps/app/src/app/constants.ts‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,27 @@ export type ExtensionKind = "mcp" | "plugin" | "skill" | "ui-control" | "extensi
2828

2929
export type McpDirectoryInfo = {
3030
id?: string;
31-
/** Display name shown in the UI. */
3231
name: string;
33-
/** Safe server name for opencode.jsonc (alphanumeric, - and _ only). Auto-derived from name if omitted. */
3432
serverName?: string;
3533
description: string;
3634
url?: string;
3735
type?: "remote" | "local";
3836
command?: string[];
3937
oauth: boolean;
40-
/** Route OAuth through the local OpenWork gateway instead of delegating it to OpenCode. */
4138
managedOAuth?: boolean;
42-
/** Identifies MCP entries owned by OpenWork Connect instead of workspace configuration. */
4339
managedBy?: "openwork-connect";
4440
oauthConfig?: {
4541
clientId?: string;
4642
clientSecret?: string;
4743
scope?: string;
4844
};
49-
/** Extension category for UI grouping. Defaults to "mcp". */
5045
kind?: ExtensionKind;
51-
/** Simple Icons slug for brand icon (e.g. "notion", "stripe", "figma"). */
5246
iconSlug?: string;
53-
/** Direct icon URL (e.g. local SVG). Takes priority over iconSlug. */
5447
iconSrc?: string;
55-
/** Prompt inserted from the composer extension picker. */
5648
composerPrompt?: string;
57-
/** Whether OpenWork should show this extension as enabled before user setup. */
5849
defaultEnabled?: boolean;
59-
/** Whether OpenWork should hide this extension from the default catalog view. */
6050
defaultHidden?: boolean;
61-
/** Whether this extension is still in preview. */
6251
preview?: boolean;
63-
/** Normalized extension manifest backing this catalog entry. */
6452
extensionManifest?: OpenWorkExtensionManifest;
6553
};
6654

@@ -89,7 +77,6 @@ export function isBuiltInOpenWorkExtension(entry: Pick<McpDirectoryInfo, "kind"
8977
return entry.kind === "extension" && isTrustedBuiltInExtension(entry.extensionManifest);
9078
}
9179

92-
/** Derive a safe MCP server name from a display name or explicit serverName. */
9380
export function getMcpServerName(entry: McpDirectoryInfo): string {
9481
if (entry.serverName) return entry.serverName;
9582
return canonicalMcpServerName(entry.name);
@@ -156,11 +143,6 @@ export const MCP_QUICK_CONNECT: McpDirectoryInfo[] = [
156143
serverName: "openwork-cloud",
157144
get description() { return t("mcp.quick_connect_openwork_cloud_desc"); },
158145
get url() {
159-
// The desktop app connects to the minimal, harness-facing surface
160-
// (/mcp/agent: search_capabilities + execute_capability only), not the
161-
// full catalog at bare /mcp. getDenMcpUrl heals stale web-app origins;
162-
// never at the web app's root (see
163-
// packages/docs/cloud/run-in-the-cloud/cloud-mcp.mdx).
164146
try {
165147
return `${getDenMcpUrl()}/agent`;
166148
} catch {
@@ -172,23 +154,17 @@ export const MCP_QUICK_CONNECT: McpDirectoryInfo[] = [
172154
managedBy: "openwork-connect",
173155
kind: "mcp",
174156
iconSrc: "/openwork-mark.svg",
175-
// Auto-managed by the signed-in cloud reconciler (syncCloudControlMcp):
176-
// configured + enabled while signed in to OpenWork Cloud. Hidden from the
177-
// default catalog; "Show hidden" reveals it.
178157
defaultHidden: true,
179158
},
180159
{
181160
get name() { return t("mcp.quick_connect_openwork_ui_title"); },
182161
serverName: "openwork-ui",
183162
get description() { return t("mcp.quick_connect_openwork_ui_desc"); },
184163
type: "local",
185-
// Dev builds replace this with the local checkout path before writing config.
186164
command: ["npx", "-y", "openwork-ui-mcp"],
187165
oauth: false,
188166
kind: "ui-control",
189167
iconSrc: "/openwork-mark.svg",
190-
// Internal UI-control surface for agents driving the desktop app. Hidden
191-
// from the default catalog; "Show hidden" reveals it.
192168
defaultHidden: true,
193169
},
194170
...BUILT_IN_OPENWORK_EXTENSION_MANIFESTS.map(extensionManifestToDirectoryInfo),

‎apps/app/src/app/enablement.ts‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
import type { EnablementCondition, EnablementResult } from "./extensions";
22
import type { McpStatusMap } from "./types";
33

4-
/**
5-
* Runtime context needed to evaluate enablement conditions.
6-
* Each field is optional — missing context means the condition is unmet.
7-
*/
84
export type EnablementContext = {
9-
/** MCP server runtime statuses keyed by server name. */
105
mcpStatuses?: McpStatusMap;
11-
/** Set of MCP server names that are at least configured (in opencode.json). */
126
mcpConfigured?: Set<string>;
13-
/** Set of connected provider IDs. */
147
connectedProviders?: Set<string>;
15-
/** Set of environment variable keys that are configured. */
168
configuredEnvKeys?: Set<string>;
17-
/** Toggle state reader — returns true if the extension toggle is on. */
189
isToggleEnabled?: (ref: string) => boolean;
1910
};
2011

21-
/**
22-
* Evaluate a single enablement condition against runtime context.
23-
*/
2412
function evaluateCondition(condition: EnablementCondition, ctx: EnablementContext): boolean {
2513
switch (condition.type) {
2614
case "mcp-connected": {
@@ -38,10 +26,6 @@ function evaluateCondition(condition: EnablementCondition, ctx: EnablementContex
3826
}
3927
}
4028

41-
/**
42-
* Evaluate all enablement conditions for an extension.
43-
* Returns per-condition results and an overall `active` boolean.
44-
*/
4529
export function evaluateEnablement(
4630
conditions: EnablementCondition[] | undefined,
4731
ctx: EnablementContext,

‎apps/app/src/app/extensions.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Owned here: reload vocabulary is part of the extension manifest contract.
2-
// types.ts re-exports it for the rest of the app.
31
export type ReloadReason = "plugins" | "skills" | "mcp" | "config" | "agents" | "commands";
42

53
export type OpenWorkExtensionSourceFormat =
@@ -81,10 +79,6 @@ export type OpenWorkExtensionLifecycle = {
8179
detection?: string[];
8280
};
8381

84-
// ---------------------------------------------------------------------------
85-
// Enablement — declarative conditions for extension "active" state
86-
// ---------------------------------------------------------------------------
87-
8882
export type EnablementConditionType =
8983
| "mcp-connected"
9084
| "provider-connected"
@@ -93,13 +87,10 @@ export type EnablementConditionType =
9387

9488
export type EnablementCondition = {
9589
type: EnablementConditionType;
96-
/** What to check — MCP server name, plugin id, env key, etc. */
9790
ref: string;
98-
/** Human-readable label shown in the UI. */
9991
label: string;
10092
};
10193

102-
/** Result of evaluating a single enablement condition at runtime. */
10394
export type EnablementResult = {
10495
condition: EnablementCondition;
10596
met: boolean;
@@ -123,7 +114,6 @@ export type OpenWorkExtensionManifest = {
123114
resources: OpenWorkExtensionResource[];
124115
contributions?: OpenWorkExtensionContribution[];
125116
lifecycle?: OpenWorkExtensionLifecycle;
126-
/** Declarative conditions that must ALL be true for the extension to be "active". */
127117
enablement?: EnablementCondition[];
128118
defaultEnabled?: boolean;
129119
defaultHidden?: boolean;

‎apps/app/src/app/lib/agent-context-diagnostics-transport.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ async function readBoundedResponseText(
100100
return new TextDecoder().decode(bytes);
101101
}
102102

103-
/**
104-
* Runs the diagnostics request under one deadline that remains active until
105-
* the bounded response body has been consumed and parsed.
106-
*/
107103
export async function requestAgentContextDiagnosticsPayload(options: {
108104
fetchImpl: AgentContextDiagnosticsFetch;
109105
url: string;
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
export const DEFAULT_POSTHOG_KEY = "phc_4YnPTlDVYPjgwKvLuNxhbHjV5kadgvd7XLzVHWnCXAI";
22

3-
/**
4-
* Resolve the PostHog project key. `raw` is VITE_OPENWORK_POSTHOG_KEY.
5-
* Unset uses the default key in prod builds and stays silent in dev builds.
6-
* Explicit strings are used after trim; an empty string disables analytics in any build.
7-
*/
83
export function resolvePosthogKey(raw: unknown, isDev: boolean): string {
9-
if (typeof raw === "string") return raw.trim(); // explicit value wins; "" disables
4+
if (typeof raw === "string") return raw.trim();
105
return isDev ? "" : DEFAULT_POSTHOG_KEY;
116
}

‎apps/app/src/app/lib/analytics.ts‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/**
2-
* Product analytics for the OpenWork desktop app (PostHog, zero-dependency).
3-
*
4-
* Principles (mirrors `den-telemetry.ts`):
5-
* - Never send message content, file paths, code, or prompts. Only event
6-
* names, counts, lengths, durations, and coarse context (workspace type,
7-
* provider/model id). Sole exception: answers the user types directly
8-
* into an explicit survey field (e.g. the onboarding attribution survey).
9-
* - Fire-and-forget: analytics must never break or slow the app.
10-
* - Respect the user: a single `analyticsEnabled` preference (Settings ->
11-
* Preferences) turns everything off; an explicitly blank PostHog key means
12-
* no network.
13-
* - Every capture is mirrored into the local app inspector
14-
* (`window.__openwork.record("analytics.<event>")`) so coded evals can
15-
* assert instrumentation without any analytics backend.
16-
*/
171
import { denSessionUpdatedEvent, denSettingsChangedEvent, type DenSessionUpdatedDetail } from "./den-session-events";
182
import { readDenSettings } from "./den";
193
import { readDesktopDistributionInfo } from "./desktop";
@@ -27,9 +11,6 @@ const ENV_APP_VERSION = String(import.meta.env.VITE_OPENWORK_APP_VERSION ?? "").
2711

2812
const DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com";
2913

30-
// Packaged releases use the default publishable key; dev builds stay silent
31-
// unless VITE_OPENWORK_POSTHOG_KEY is set. Set it to "" to disable analytics
32-
// in any build. The inspector mirror still records events locally either way.
3314
const POSTHOG_KEY = resolvePosthogKey(import.meta.env.VITE_OPENWORK_POSTHOG_KEY, import.meta.env.DEV);
3415
const POSTHOG_HOST = (ENV_POSTHOG_HOST || DEFAULT_POSTHOG_HOST).replace(/\/+$/, "");
3516

@@ -105,10 +86,6 @@ function baseProperties(): AnalyticsProperties {
10586
};
10687
}
10788

108-
/**
109-
* Queue an analytics event. Always mirrored to the local inspector;
110-
* only sent over the network when enabled and a key is configured.
111-
*/
11289
export function captureAnalyticsEvent(event: string, properties: AnalyticsProperties = {}) {
11390
try {
11491
const eventProperties = { ...baseProperties(), ...properties };
@@ -125,10 +102,6 @@ export function captureAnalyticsEvent(event: string, properties: AnalyticsProper
125102
}
126103
}
127104

128-
/**
129-
* Link the anonymous distinct id to the signed-in Den user so DAU and
130-
* retention survive sign-in. Sends only the user id — no email or name.
131-
*/
132105
function identify(denUserId: string) {
133106
if (!POSTHOG_KEY || !isAnalyticsEnabled()) return;
134107
queue.push({
@@ -170,14 +143,9 @@ export async function flushAnalytics(): Promise<void> {
170143
}),
171144
});
172145
} catch {
173-
// Network failure — drop silently. Analytics must never surface errors.
174146
}
175147
}
176148

177-
// Task run duration tracking: sendDraft marks the start, the session.idle
178-
// sync event takes it. Also acts as a dedupe guard so idle events that do
179-
// not correspond to an instrumented run (or arrive from a second workspace
180-
// sync) emit nothing.
181149
const taskRunStarts = new Map<string, number>();
182150

183151
export function markTaskRunStart(sessionId: string) {
@@ -191,10 +159,6 @@ export function takeTaskRunStart(sessionId: string): number | null {
191159
return startedAt;
192160
}
193161

194-
/**
195-
* One-time setup: flush loop, unload flush, and cloud sign-in listener.
196-
* Mounted from AppRoot.
197-
*/
198162
export function initAnalytics() {
199163
if (initialized || typeof window === "undefined") return;
200164
initialized = true;

‎apps/app/src/app/lib/app-inspector.ts‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,15 @@
11
import type { Client } from "../types";
22

3-
/**
4-
* Lightweight runtime-inspection surface for the React app.
5-
*
6-
* The goal is to give agents/humans a single readable snapshot of routing,
7-
* workspaces, sessions, composer draft, boot phase, and the last
8-
* refreshRouteState() call — without crawling the UI tree.
9-
*
10-
* Consumers read via `window.__openwork` from a devtools console or from
11-
* browser-tool `evaluate_script`. The surface is intentionally plain JSON so
12-
* it survives postMessage-style bridges.
13-
*
14-
* Writers are any component that wants to publish a named slice via
15-
* `publishInspectorSlice("route", () => ({...}))`. Slices expose a pull
16-
* function so we never hold stale snapshots.
17-
*/
183
export type InspectorSliceGetter = () => unknown;
194

205
type InspectorAPI = {
216
version: number;
22-
/** Active workspace's authenticated OpenCode SDK client when developer mode is enabled. */
237
readonly opencode: Client | null;
248
snapshot(): Record<string, unknown>;
259
slice(name: string): unknown;
2610
listSlices(): string[];
27-
/** Returns the last N records from the event log. */
2811
events(limit?: number): Array<{ at: number; name: string; data: unknown }>;
29-
/** Push a timestamped event for later inspection. */
3012
record(name: string, data?: unknown): void;
31-
/** Clear the in-memory event log. */
3213
clearEvents(): void;
3314
};
3415

0 commit comments

Comments
 (0)