Skip to content

Commit 33ec4be

Browse files
authored
Merge branch 'main' into fix/opencode-go-limits-credential-db
2 parents 7f7b4c2 + 521f5b5 commit 33ec4be

478 files changed

Lines changed: 27118 additions & 6292 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.

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ Architecture and its constraints: `docs/internals/overview.md`. Glossary: `docs/
150150
## Taste
151151

152152
- Complexity belongs at the adapter boundary. Orchestration stays pure, UI stays dumb.
153+
- Client mutations use `createEnvironmentRpcCommand`. Add protected methods to `CLIENT_GUARDED_RPC_SCOPES` in contracts and use the command's `permissionAtom` for UI availability. Grants are checked at execution against the destination environment; the server remains authoritative. Keep raw RPC clients inside `rpc/`, and extend the permission behavior tests when adding a protected method.
153154
- Server features are services; transports stay thin. A `ws.ts` RPC handler, HTTP route, or MCP tool decodes input, calls one service method, and maps errors. See [Effect services](docs/internals/effect-services.md).
154155
- `apps/web/src/components/ui` exports own their look. Pick a `variant` or `size`; do not restyle one with `className`. If none fits and the look is a generic concept, add a variant to the component; a look that belongs to one feature stays in that feature's own component, not in `components/ui`. Layout classes (width, flex, margin, position) belong on the parent. `shadcn/no-restyle` fails lint on violations. See [Web UI](docs/internals/web-ui.md).
155156
- Inferred types over annotations. `any` is the enemy.

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Full docs live in [docs/](./docs). There's no docs site yet.
9494
- [Project settings](./docs/user/project-settings.md)
9595
- [Appearance preferences](./docs/user/appearance.md)
9696
- [Remote access from a phone or another machine](./docs/user/remote-access.md)
97+
- [Connect Claude Code, Codex, ChatGPT and other agents over MCP](./docs/user/outside-agents.md)
9798
- [Keeping app and server in sync](./docs/user/updating.md)
9899
- [Source control integrations](./docs/user/source-control.md)
99100
- Multiple accounts: [Codex](./docs/user/providers-codex.md) · [Claude](./docs/user/providers-claude.md)

‎apps/desktop/src/ipc/channels.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ export const PREVIEW_GET_CONFIG_CHANNEL = "desktop:preview-get-config";
9090
export const PREVIEW_IMPORT_SOURCES_CHANNEL = "desktop:preview-import-sources";
9191
export const PREVIEW_IMPORT_COOKIES_CHANNEL = "desktop:preview-import-cookies";
9292
export const PREVIEW_SET_ANNOTATION_THEME_CHANNEL = "desktop:preview-set-annotation-theme";
93+
export const PREVIEW_SET_ANNOTATION_SEND_ENABLED_CHANNEL =
94+
"desktop:preview-set-annotation-send-enabled";
9395
export const PREVIEW_PICK_ELEMENT_CHANNEL = "desktop:preview-pick-element";
9496
export const PREVIEW_CANCEL_PICK_ELEMENT_CHANNEL = "desktop:preview-cancel-pick-element";
9597
export const PREVIEW_CAPTURE_SCREENSHOT_CHANNEL = "desktop:preview-capture-screenshot";

‎apps/desktop/src/ipc/methods/preview.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
DesktopPreviewAnnotationSendEnabledInputSchema,
23
DesktopPreviewAnnotationThemeInputSchema,
34
DesktopPreviewArtifactInputSchema,
45
DesktopPreviewConfigInputSchema,
@@ -377,6 +378,19 @@ export const pickElement = DesktopIpc.makeIpcMethod({
377378
}),
378379
});
379380

381+
export const setAnnotationSendEnabled = DesktopIpc.makeIpcMethod({
382+
channel: IpcChannels.PREVIEW_SET_ANNOTATION_SEND_ENABLED_CHANNEL,
383+
payload: DesktopPreviewAnnotationSendEnabledInputSchema,
384+
result: Schema.Void,
385+
handler: Effect.fn("desktop.ipc.preview.setAnnotationSendEnabled")(function* ({
386+
tabId,
387+
enabled,
388+
}) {
389+
const manager = yield* PreviewManager.PreviewManager;
390+
yield* manager.setAnnotationSendEnabled(tabId, enabled);
391+
}),
392+
});
393+
380394
export const captureScreenshot = DesktopIpc.makeIpcMethod({
381395
channel: IpcChannels.PREVIEW_CAPTURE_SCREENSHOT_CHANNEL,
382396
payload: DesktopPreviewTabInputSchema,
@@ -438,6 +452,7 @@ export const methods = [
438452
clearCache,
439453
getPreviewConfig,
440454
setAnnotationTheme,
455+
setAnnotationSendEnabled,
441456
pickElement,
442457
cancelPickElement,
443458
captureScreenshot,

‎apps/desktop/src/preload.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ contextBridge.exposeInMainWorld("desktopBridge", {
339339
ipcRenderer.invoke(IpcChannels.PREVIEW_GET_CONFIG_CHANNEL, { environmentId, profileId }),
340340
setAnnotationTheme: (theme) =>
341341
ipcRenderer.invoke(IpcChannels.PREVIEW_SET_ANNOTATION_THEME_CHANNEL, { theme }),
342+
setAnnotationSendEnabled: (tabId, enabled) =>
343+
ipcRenderer.invoke(IpcChannels.PREVIEW_SET_ANNOTATION_SEND_ENABLED_CHANNEL, {
344+
tabId,
345+
enabled,
346+
}),
342347
pickElement: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_PICK_ELEMENT_CHANNEL, { tabId }),
343348
cancelPickElement: (tabId) =>
344349
ipcRenderer.invoke(IpcChannels.PREVIEW_CANCEL_PICK_ELEMENT_CHANNEL, { tabId }),

‎apps/desktop/src/preview/AnnotationKeyboard.test.ts‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,23 @@ const keyboardEvent = (
1515

1616
describe("resolveAnnotationSubmission", () => {
1717
it("attaches on Enter and sends on Cmd/Ctrl+Enter", () => {
18-
expect(resolveAnnotationSubmission(keyboardEvent())).toBe("attach");
19-
expect(resolveAnnotationSubmission(keyboardEvent({ metaKey: true }))).toBe("send");
20-
expect(resolveAnnotationSubmission(keyboardEvent({ ctrlKey: true }))).toBe("send");
18+
expect(resolveAnnotationSubmission(keyboardEvent(), true)).toBe("attach");
19+
expect(resolveAnnotationSubmission(keyboardEvent({ metaKey: true }), true)).toBe("send");
20+
expect(resolveAnnotationSubmission(keyboardEvent({ ctrlKey: true }), true)).toBe("send");
2121
});
2222

2323
it("leaves Shift+Enter and composition events available for editing", () => {
24-
expect(resolveAnnotationSubmission(keyboardEvent({ shiftKey: true }))).toBeNull();
25-
expect(resolveAnnotationSubmission(keyboardEvent({ isComposing: true }))).toBeNull();
26-
expect(resolveAnnotationSubmission(keyboardEvent({ key: " " }))).toBeNull();
24+
expect(resolveAnnotationSubmission(keyboardEvent({ shiftKey: true }), true)).toBeNull();
25+
expect(resolveAnnotationSubmission(keyboardEvent({ isComposing: true }), true)).toBeNull();
26+
expect(resolveAnnotationSubmission(keyboardEvent({ key: " " }), true)).toBeNull();
27+
});
28+
29+
it("keeps attach available while the send shortcut follows permission changes", () => {
30+
const send = keyboardEvent({ ctrlKey: true });
31+
expect(resolveAnnotationSubmission(send, false)).toBeNull();
32+
expect(resolveAnnotationSubmission(keyboardEvent(), false)).toBe("attach");
33+
expect(resolveAnnotationSubmission(send, true)).toBe("send");
34+
expect(resolveAnnotationSubmission(send, false)).toBeNull();
35+
expect(resolveAnnotationSubmission(keyboardEvent({ metaKey: true }), false)).toBeNull();
2736
});
2837
});

‎apps/desktop/src/preview/AnnotationKeyboard.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ interface AnnotationKeyboardEvent {
1010

1111
export function resolveAnnotationSubmission(
1212
event: AnnotationKeyboardEvent,
13+
canSend: boolean,
1314
): PreviewAnnotationSubmission | null {
1415
if (event.key !== "Enter" || event.shiftKey || event.isComposing) return null;
15-
return event.metaKey || event.ctrlKey ? "send" : "attach";
16+
return event.metaKey || event.ctrlKey ? (canSend ? "send" : null) : "attach";
1617
}

‎apps/desktop/src/preview/GuestProtocol.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export const CANCEL_PICK_CHANNEL = "preview:cancel-pick";
33
export const ELEMENT_PICKED_CHANNEL = "preview:element-picked";
44
export const ANNOTATION_CAPTURED_CHANNEL = "preview:annotation-captured";
55
export const ANNOTATION_THEME_CHANNEL = "preview:annotation-theme";
6+
export const ANNOTATION_SEND_ENABLED_CHANNEL = "preview:annotation-send-enabled";
67
export const HUMAN_INPUT_CHANNEL = "preview:human-input";
78
export const MOUSE_NAVIGATE_CHANNEL = "preview:mouse-navigate";
89
export const RECORDING_CURSOR_CHANNEL = "preview:recording-cursor";

‎apps/desktop/src/preview/Manager.test.ts‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3937,6 +3937,85 @@ describe("PreviewManager", () => {
39373937
),
39383938
);
39393939

3940+
effectIt.effect("keeps annotation send grants isolated and updates an active pick", () =>
3941+
withManager((manager) =>
3942+
Effect.gen(function* () {
3943+
const picked = new Map<number, (event: unknown, ...args: unknown[]) => void>();
3944+
const capturePage = vi.fn(async () => ({
3945+
toJPEG: () => Buffer.from("annotation"),
3946+
toDataURL: () => "data:image/png;base64,YW5ub3RhdGlvbg==",
3947+
getSize: () => ({ width: 10, height: 10 }),
3948+
}));
3949+
const guests = new Map(
3950+
[42, 43, 44].map(
3951+
(id) =>
3952+
[
3953+
id,
3954+
Object.assign(makeTestPreviewWebContents(capturePage, id), {
3955+
isFocused: () => true,
3956+
once: vi.fn(),
3957+
ipc: {
3958+
on: vi.fn(
3959+
(channel: string, listener: (event: unknown, ...args: unknown[]) => void) => {
3960+
if (channel === "preview:element-picked") picked.set(id, listener);
3961+
},
3962+
),
3963+
off: vi.fn(),
3964+
removeListener: vi.fn(),
3965+
},
3966+
}),
3967+
] as const,
3968+
),
3969+
);
3970+
fromId.mockImplementation((id) => (id === undefined ? null : (guests.get(id) ?? null)));
3971+
yield* manager.createTab("tab_a");
3972+
yield* manager.createTab("tab_b");
3973+
yield* manager.registerWebview("tab_a", 42);
3974+
yield* manager.registerWebview("tab_b", 43);
3975+
yield* manager.setAnnotationSendEnabled("tab_a", true);
3976+
const annotation = {
3977+
id: "annotation-scopes",
3978+
pageUrl: "https://example.com",
3979+
pageTitle: "Example",
3980+
comment: "Tighten this spacing",
3981+
elements: [],
3982+
regions: [],
3983+
strokes: [],
3984+
styleChanges: [],
3985+
screenshot: null,
3986+
createdAt: "2026-09-05T00:00:00.000Z",
3987+
};
3988+
for (const [tabId, id, nextGrant, expected] of [
3989+
["tab_b", 43, undefined, "attach"],
3990+
["tab_a", 42, false, "attach"],
3991+
["tab_a", 42, true, "send"],
3992+
] as const) {
3993+
const pick = yield* manager.pickElement(tabId).pipe(Effect.forkChild);
3994+
yield* Effect.yieldNow;
3995+
if (nextGrant !== undefined) {
3996+
yield* manager.setAnnotationSendEnabled(tabId, nextGrant);
3997+
}
3998+
picked.get(id)?.({}, annotation, null, "send");
3999+
const result = yield* Fiber.join(pick);
4000+
expect(result?.annotation.id).toBe(annotation.id);
4001+
expect(result?.submission).toBe(expected);
4002+
}
4003+
yield* manager.registerWebview("tab_a", 44);
4004+
const replacementPick = yield* manager.pickElement("tab_a").pipe(Effect.forkChild);
4005+
yield* Effect.yieldNow;
4006+
picked.get(44)?.({}, annotation, null, "send");
4007+
expect((yield* Fiber.join(replacementPick))?.submission).toBe("send");
4008+
yield* manager.closeTab("tab_a");
4009+
yield* manager.createTab("tab_a");
4010+
yield* manager.registerWebview("tab_a", 44);
4011+
const reopenedPick = yield* manager.pickElement("tab_a").pipe(Effect.forkChild);
4012+
yield* Effect.yieldNow;
4013+
picked.get(44)?.({}, annotation, null, "send");
4014+
expect((yield* Fiber.join(reopenedPick))?.submission).toBe("attach");
4015+
}),
4016+
),
4017+
);
4018+
39404019
effectIt.effect("settles the pick when the annotation screenshot never arrives", () =>
39414020
withManager((manager) =>
39424021
Effect.gen(function* () {
@@ -3983,6 +4062,7 @@ describe("PreviewManager", () => {
39834062
const pick = yield* manager.pickElement("tab_1").pipe(Effect.forkChild);
39844063
yield* Effect.yieldNow;
39854064

4065+
yield* manager.setAnnotationSendEnabled("tab_1", true);
39864066
onPicked?.(
39874067
{},
39884068
{

‎apps/desktop/src/preview/Manager.ts‎

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import * as DesktopBrowserHost from "./DesktopBrowserHost.ts";
6565
import * as BrowserSession from "./BrowserSession.ts";
6666
import {
6767
ANNOTATION_CAPTURED_CHANNEL,
68+
ANNOTATION_SEND_ENABLED_CHANNEL,
6869
ANNOTATION_THEME_CHANNEL,
6970
CANCEL_PICK_CHANNEL,
7071
ELEMENT_PICKED_CHANNEL,
@@ -559,6 +560,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
559560

560561
let forwardedShortcuts: ReadonlyArray<PreviewForwardedShortcut> = [];
561562
const annotationThemeRef = yield* Ref.make(DEFAULT_ANNOTATION_THEME);
563+
const annotationSendEnabled = new Map<string, boolean>();
562564
const mainWindowRef = yield* Ref.make<Option.Option<BrowserWindow>>(Option.none());
563565
const tabsRef = yield* SynchronizedRef.make<ReadonlyMap<string, PreviewTabState>>(new Map());
564566
const attachedRef = yield* Ref.make<ReadonlyMap<number, ManagedListeners>>(new Map());
@@ -1713,6 +1715,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
17131715
const closeTabUnlocked = Effect.fn("PreviewManager.closeTabUnlocked")(function* (tabId: string) {
17141716
if (!(yield* SynchronizedRef.get(tabsRef)).has(tabId)) return;
17151717
clearPendingRecording(tabId);
1718+
annotationSendEnabled.delete(tabId);
17161719
yield* Effect.all(
17171720
[
17181721
cancelPickElement(tabId),
@@ -1814,9 +1817,10 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
18141817
// changed. Only push its zoom back down — Chromium may have just handed
18151818
// this guest the app window's zoom level.
18161819
yield* assertTabZoom(tabId);
1817-
yield* attempt({ operation: "registerWebview.sendTheme", tabId, webContentsId }, () =>
1818-
wc.send(ANNOTATION_THEME_CHANNEL, annotationTheme),
1819-
);
1820+
yield* attempt({ operation: "registerWebview.sendTheme", tabId, webContentsId }, () => {
1821+
wc.send(ANNOTATION_THEME_CHANNEL, annotationTheme);
1822+
wc.send(ANNOTATION_SEND_ENABLED_CHANNEL, annotationSendEnabled.get(tabId) === true);
1823+
});
18201824
return;
18211825
}
18221826
const replacedWebContentsId =
@@ -1923,9 +1927,10 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
19231927
// syncTabAudible's ownership check, so re-read and reconcile through the
19241928
// same path the event uses.
19251929
yield* syncTabAudible(tabId, wc, yield* readAudible);
1926-
yield* attempt({ operation: "registerWebview.sendTheme", tabId, webContentsId }, () =>
1927-
wc.send(ANNOTATION_THEME_CHANNEL, annotationTheme),
1928-
);
1930+
yield* attempt({ operation: "registerWebview.sendTheme", tabId, webContentsId }, () => {
1931+
wc.send(ANNOTATION_THEME_CHANNEL, annotationTheme);
1932+
wc.send(ANNOTATION_SEND_ENABLED_CHANNEL, annotationSendEnabled.get(tabId) === true);
1933+
});
19291934
const latestNavStatus = (yield* SynchronizedRef.get(tabsRef)).get(tabId)?.navStatus;
19301935
if (
19311936
pendingUrl &&
@@ -2139,6 +2144,17 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
21392144
);
21402145
});
21412146

2147+
const setAnnotationSendEnabled = Effect.fn("PreviewManager.setAnnotationSendEnabled")(function* (
2148+
tabId: string,
2149+
enabled: boolean,
2150+
) {
2151+
const wc = yield* requireWebContents(tabId);
2152+
yield* attempt({ operation: "setAnnotationSendEnabled", tabId, webContentsId: wc.id }, () => {
2153+
annotationSendEnabled.set(tabId, enabled);
2154+
wc.send(ANNOTATION_SEND_ENABLED_CHANNEL, enabled);
2155+
});
2156+
});
2157+
21422158
const pickElement = Effect.fn("PreviewManager.pickElement")(function* (tabId: string) {
21432159
const wc = yield* requireWebContents(tabId);
21442160
yield* cancelPickElement(tabId);
@@ -2216,7 +2232,8 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
22162232
return;
22172233
}
22182234
const cropRect = normalizeCaptureRect(args[1]);
2219-
const submission = args[2] === "send" ? "send" : "attach";
2235+
const submission =
2236+
args[2] === "send" && annotationSendEnabled.get(tabId) === true ? "send" : "attach";
22202237
runFork(
22212238
captureAnnotationScreenshot(tabId, wc, cropRect).pipe(
22222239
// The renderer cannot tell a dropped crop from a comment-only
@@ -2275,7 +2292,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
22752292
wc.once("destroyed", onDestroyed);
22762293
wc.on("did-start-navigation", onNavigated);
22772294
if (!wc.isFocused()) wc.focus();
2278-
wc.send(START_PICK_CHANNEL, annotationTheme);
2295+
wc.send(START_PICK_CHANNEL, annotationTheme, annotationSendEnabled.get(tabId) === true);
22792296
});
22802297
});
22812298
runFork(
@@ -3356,6 +3373,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
33563373
revealArtifact,
33573374
saveRecording,
33583375
setAnnotationTheme,
3376+
setAnnotationSendEnabled,
33593377
setAudioMuted,
33603378
setColorScheme,
33613379
setMainWindow,
@@ -3580,6 +3598,10 @@ export class PreviewManager extends Context.Service<
35803598
readonly setAnnotationTheme: (
35813599
theme: DesktopPreviewAnnotationTheme,
35823600
) => Effect.Effect<void, PreviewManagerError>;
3601+
readonly setAnnotationSendEnabled: (
3602+
tabId: string,
3603+
enabled: boolean,
3604+
) => Effect.Effect<void, PreviewManagerError>;
35833605
readonly pickElement: (
35843606
tabId: string,
35853607
) => Effect.Effect<PreviewAnnotationSubmissionResult | null, PreviewManagerError>;
@@ -3697,6 +3719,7 @@ export const make = Effect.gen(function* PreviewManagerMake() {
36973719
},
36983720
),
36993721
setAnnotationTheme: operations.setAnnotationTheme,
3722+
setAnnotationSendEnabled: operations.setAnnotationSendEnabled,
37003723
pickElement: operations.pickElement,
37013724
cancelPickElement: operations.cancelPickElement,
37023725
captureScreenshot: operations.captureScreenshot,

0 commit comments

Comments
 (0)