From 5f3b2fa4bfbcbf5730710a792ff265f7a610f6b8 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:28:29 -0800 Subject: [PATCH] feat(artifacts): allow artifact publishing by default for new profiles (#40948) New profiles default artifactSharingEnabled to true. Existing users are unchanged: stored settings win over defaults on load, and a stored profile saved before the key existed loads as false instead of inheriting the new default. The gate still requires an explicit true, sign-in is still required, and web clients still mirror the host (their local fallback no longer inherits the desktop default). showArtifactsButton is unchanged. --- docs/site/content/docs/cli/reference.mdx | 2 +- docs/site/content/docs/editing/markdown.mdx | 2 +- docs/site/content/docs/settings.mdx | 2 +- skill-guides/orca-cli.md | 4 +- src/cli/bundled-skill-guides.ts | 4 +- ...rsistence-artifact-sharing-default.test.ts | 59 +++++++++++++++++++ .../normalize-loaded-global-settings.ts | 2 + .../web-artifact-sharing-setting.test.ts | 18 ++++++ .../web/preload-api/web-preferences-store.ts | 2 +- src/shared/artifacts/artifact-sharing-gate.ts | 2 +- src/shared/default-global-settings.ts | 3 +- src/shared/global-settings-types.ts | 2 +- 12 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 src/main/persistence/applying-settings/persistence-artifact-sharing-default.test.ts create mode 100644 src/renderer/src/web/preload-api/web-artifact-sharing-setting.test.ts diff --git a/docs/site/content/docs/cli/reference.mdx b/docs/site/content/docs/cli/reference.mdx index fb1011130dc..bff53fb760b 100644 --- a/docs/site/content/docs/cli/reference.mdx +++ b/docs/site/content/docs/cli/reference.mdx @@ -427,7 +427,7 @@ A selection applies to every agent of that provider launched on the host after i ## Artifacts -Publish HTML or Markdown through the signed-in Orca account. Viewing a public link does not require sign-in; create/list/update/delete do. **Publishing is off by default** — a human must enable **Settings → Artifacts → Allow publishing public artifact links** on the device. There is no CLI flag that grants the gate. `list`, `unshare`, and `delete` stay available so you can audit or revoke links after turning publishing off. +Publish HTML or Markdown through the signed-in Orca account. Viewing a public link does not require sign-in; create/list/update/delete do. Publishing follows **Settings → Artifacts → Allow publishing public artifact links** on the device: on by default for new profiles, while profiles created before this default keep their previous setting. Only a human can change it; there is no CLI flag that grants the gate. `list`, `unshare`, and `delete` stay available so you can audit or revoke links after turning publishing off. ```bash orca artifacts share ./report.html --json diff --git a/docs/site/content/docs/editing/markdown.mdx b/docs/site/content/docs/editing/markdown.mdx index a84c3991611..32869df4e07 100644 --- a/docs/site/content/docs/editing/markdown.mdx +++ b/docs/site/content/docs/editing/markdown.mdx @@ -51,4 +51,4 @@ For long documents, click the **Table of Contents** button (tree icon) in the ed ## Share as artifact -From the editor header, **Share as artifact** publishes the open Markdown file as a public view link through your signed-in Orca account. Requires **Settings → Artifacts → Allow publishing public artifact links** (off by default). Republish updates the same link when Orca still has the mapping; manage or delete links from the sidebar **Artifacts** page. Agents and scripts can use `orca artifacts share|update|list|delete` — see [CLI reference → Artifacts](/docs/cli/reference#artifacts). +From the editor header, **Share as artifact** publishes the open Markdown file as a public view link through your signed-in Orca account. Requires **Settings → Artifacts → Allow publishing public artifact links** (on by default for new profiles). Republish updates the same link when Orca still has the mapping; manage or delete links from the sidebar **Artifacts** page. Agents and scripts can use `orca artifacts share|update|list|delete` — see [CLI reference → Artifacts](/docs/cli/reference#artifacts). diff --git a/docs/site/content/docs/settings.mdx b/docs/site/content/docs/settings.mdx index 7d71631f1c5..eb489b00875 100644 --- a/docs/site/content/docs/settings.mdx +++ b/docs/site/content/docs/settings.mdx @@ -91,7 +91,7 @@ Settings are grouped into panes. Everything here is searchable with `Cmd-,` then ## Artifacts - **Orca account** — sign in (same account family as Orca Relay) to publish and manage shared files. -- **Allow publishing public artifact links** — **off by default**. Device-wide gate: when on, you, agents, and the `orca` CLI on this machine can upload HTML/Markdown and mint public view links. Turning it off does not delete existing links. +- **Allow publishing public artifact links** — **on by default for new profiles**; profiles created before this default keep their previous setting. Device-wide gate: when on, you, agents, and the `orca` CLI on this machine can upload HTML/Markdown and mint public view links. Turning it off does not delete existing links. - **Show Artifacts** / sidebar shortcut — open the Artifacts list to search, preview, copy, or delete account-owned links. - **Ask Before Deleting Artifacts** — optional confirmation before breaking a public link. - Share from an open local HTML page or Markdown editor with **Share as artifact**, or via `orca artifacts …`. See [CLI reference → Artifacts](/docs/cli/reference#artifacts). diff --git a/skill-guides/orca-cli.md b/skill-guides/orca-cli.md index cb89e0c74e5..ddd4193d06f 100644 --- a/skill-guides/orca-cli.md +++ b/skill-guides/orca-cli.md @@ -308,8 +308,8 @@ Use them only when the user explicitly asks to publish through Orca. A generic r public link, page, or URL does not select Orca, and a provider the user names always wins. **Only a human can turn publishing on or off.** `share` and `update` need the device-wide -setting under Settings → Artifacts ("Allow publishing public artifact links"); there is no -CLI or RPC way to grant it. `list`, `unshare`, and `delete` are never gated, so old links +setting under Settings → Artifacts ("Allow publishing public artifact links"), which is on +for new profiles; there is no CLI or RPC way to grant it. `list`, `unshare`, and `delete` are never gated, so old links stay auditable and revocable. A denied share fails with `artifact_sharing_disabled` before any upload. Do not retry. Tell diff --git a/src/cli/bundled-skill-guides.ts b/src/cli/bundled-skill-guides.ts index 79d85aeda9d..78555b61ed9 100644 --- a/src/cli/bundled-skill-guides.ts +++ b/src/cli/bundled-skill-guides.ts @@ -536,8 +536,8 @@ const ORCA_CLI_MARKDOWN = [ "public link, page, or URL does not select Orca, and a provider the user names always wins.", "", "**Only a human can turn publishing on or off.** `share` and `update` need the device-wide", - "setting under Settings → Artifacts (\"Allow publishing public artifact links\"); there is no", - "CLI or RPC way to grant it. `list`, `unshare`, and `delete` are never gated, so old links", + "setting under Settings → Artifacts (\"Allow publishing public artifact links\"), which is on", + "for new profiles; there is no CLI or RPC way to grant it. `list`, `unshare`, and `delete` are never gated, so old links", "stay auditable and revocable.", "", "A denied share fails with `artifact_sharing_disabled` before any upload. Do not retry. Tell", diff --git a/src/main/persistence/applying-settings/persistence-artifact-sharing-default.test.ts b/src/main/persistence/applying-settings/persistence-artifact-sharing-default.test.ts new file mode 100644 index 00000000000..d6ddd2e94e7 --- /dev/null +++ b/src/main/persistence/applying-settings/persistence-artifact-sharing-default.test.ts @@ -0,0 +1,59 @@ +import { closeTestStores, testState, createStore, writeDataFile } from '../persistence-test-harness' +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' +import { rmSync, mkdtempSync } from 'node:fs' +import { join } from 'node:path' +import { tmpdir } from 'node:os' + +vi.mock('electron', () => ({ + app: { getPath: () => testState.dir }, + safeStorage: { + isEncryptionAvailable: () => true, + encryptString: (plaintext: string) => Buffer.from(`encrypted:${plaintext}`, 'utf-8'), + decryptString: (ciphertext: Buffer) => ciphertext.toString('utf-8').slice('encrypted:'.length) + } +})) +vi.mock('../../telemetry/client', () => ({ track: vi.fn() })) +vi.mock('../../telemetry/cohort-classifier', () => ({ + getCohortAtEmit: () => ({ nth_repo_added: 2 }) +})) + +function writeSettings(settings: Record): void { + writeDataFile({ + schemaVersion: 1, + repos: [], + worktreeMeta: {}, + settings, + ui: {}, + githubCache: { pr: {}, issue: {} }, + workspaceSession: {} + }) +} + +describe('artifact sharing default', () => { + beforeEach(() => { + testState.dir = mkdtempSync(join(tmpdir(), 'orca-test-')) + }) + + afterEach(async () => { + await closeTestStores() + rmSync(testState.dir, { recursive: true, force: true }) + }) + + it('allows publishing on a new profile and keeps it after a reload', async () => { + const store = await createStore() + expect(store.getSettings().artifactSharingEnabled).toBe(true) + store.flush() + await closeTestStores() + expect((await createStore()).getSettings().artifactSharingEnabled).toBe(true) + }) + + it('keeps a stored opt-out', async () => { + writeSettings({ artifactSharingEnabled: false }) + expect((await createStore()).getSettings().artifactSharingEnabled).toBe(false) + }) + + it('keeps publishing off for a stored profile saved before the setting existed', async () => { + writeSettings({ showArtifactsButton: false }) + expect((await createStore()).getSettings().artifactSharingEnabled).toBe(false) + }) +}) diff --git a/src/main/persistence/loading-store/normalize-loaded-global-settings.ts b/src/main/persistence/loading-store/normalize-loaded-global-settings.ts index c75ab18a38c..a29713ace36 100644 --- a/src/main/persistence/loading-store/normalize-loaded-global-settings.ts +++ b/src/main/persistence/loading-store/normalize-loaded-global-settings.ts @@ -98,6 +98,8 @@ export function normalizeLoadedGlobalSettings( ), worktreeVisibilityDefaults: migratedExternalVisibility.defaults, prBotAuthorOverrides: normalizePRBotAuthorOverrides(parsed.settings?.prBotAuthorOverrides), + // Only fresh profiles take the on default; a stored profile saved before the key existed was off. + artifactSharingEnabled: parsed.settings?.artifactSharingEnabled === true, // Carry the retired sidekick flag into pet settings. experimentalPet: parsed.settings?.experimentalPet ?? readLegacySidekickFlag(parsed) ?? false, // Migrate old platform defaults once; retain later opt-outs. diff --git a/src/renderer/src/web/preload-api/web-artifact-sharing-setting.test.ts b/src/renderer/src/web/preload-api/web-artifact-sharing-setting.test.ts new file mode 100644 index 00000000000..90bd76157a2 --- /dev/null +++ b/src/renderer/src/web/preload-api/web-artifact-sharing-setting.test.ts @@ -0,0 +1,18 @@ +// @vitest-environment happy-dom +import { beforeEach, expect, it, vi } from 'vitest' +import { getStoredSettings } from './web-preferences-store' +import { SETTINGS_STORAGE_KEY } from './web-storage' + +vi.mock('./web-runtime-session', () => ({ + webRuntimeState: { activeEnvironment: null }, + requireActiveEnvironmentOrNull: () => null +})) + +beforeEach(() => localStorage.clear()) + +it('reports publishing off until the host grant has been mirrored', () => { + expect(getStoredSettings().artifactSharingEnabled).toBe(false) + + localStorage.setItem(SETTINGS_STORAGE_KEY, JSON.stringify({ artifactSharingEnabled: true })) + expect(getStoredSettings().artifactSharingEnabled).toBe(true) +}) diff --git a/src/renderer/src/web/preload-api/web-preferences-store.ts b/src/renderer/src/web/preload-api/web-preferences-store.ts index 65b2a3f65d8..e06f0135613 100644 --- a/src/renderer/src/web/preload-api/web-preferences-store.ts +++ b/src/renderer/src/web/preload-api/web-preferences-store.ts @@ -33,7 +33,7 @@ type SettingsResult = { settings: Partial } export function getStoredSettings(): GlobalSettings { webRuntimeState.activeEnvironment ??= readStoredWebRuntimeEnvironment() - const defaults = getDefaultSettings('~') + const defaults = { ...getDefaultSettings('~'), artifactSharingEnabled: false } // Host grants it. const rawStoredSettings = window.localStorage.getItem(SETTINGS_STORAGE_KEY) const stored = readJson>(SETTINGS_STORAGE_KEY, {}) const migratedStored = migrateStoredWebSettings(stored) diff --git a/src/shared/artifacts/artifact-sharing-gate.ts b/src/shared/artifacts/artifact-sharing-gate.ts index 3dc47ddb4cc..755c8b88990 100644 --- a/src/shared/artifacts/artifact-sharing-gate.ts +++ b/src/shared/artifacts/artifact-sharing-gate.ts @@ -23,7 +23,7 @@ export class ArtifactSharingDisabledError extends Error { } } -/** Absent or non-`true` denies: an unmigrated profile must not inherit the capability. */ +/** Only explicit `true` grants: new profiles store it from defaults; absent or `false` denies. */ export function isArtifactSharingEnabled( settings: Pick | null | undefined ): boolean { diff --git a/src/shared/default-global-settings.ts b/src/shared/default-global-settings.ts index 830d800d58f..3d6a8d36cdd 100644 --- a/src/shared/default-global-settings.ts +++ b/src/shared/default-global-settings.ts @@ -174,7 +174,8 @@ export function buildDefaultSettings(args: { showTasksButton: true, showAutomationsButton: true, artifactsEnabled: true, - artifactSharingEnabled: false, + // New profiles only; stored profiles without the key load as false (normalizeLoadedGlobalSettings). + artifactSharingEnabled: true, agentSkillSharingEnabled: false, nestedWorkerMaxDepth: NESTED_WORKER_MAX_DEPTH_DEFAULT, nestedWorkerMaxDepthDefaultedToFour: true, diff --git a/src/shared/global-settings-types.ts b/src/shared/global-settings-types.ts index 92baa52f81a..cb2781da828 100644 --- a/src/shared/global-settings-types.ts +++ b/src/shared/global-settings-types.ts @@ -251,7 +251,7 @@ export type GlobalSettings = GlobalSettingsBase & { showAutomationsButton?: boolean /** Deprecated: Artifacts are always available. Use showArtifactsButton for sidebar visibility. */ artifactsEnabled?: boolean - /** Capability gate for agent-driven publishing; off until granted, enforced in main, not just the UI. */ + /** Capability gate for public artifact publishing; on for new profiles, enforced in main, not just the UI. */ artifactSharingEnabled?: boolean /** Capability gate for agent/CLI skill publishing; manual reviewed publishing remains available. */ agentSkillSharingEnabled?: boolean