Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/desktop/apps/electron/src/preload/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { RoutedClient } from '../transport/routed-client'
import { buildClientApi } from '../transport/build-api'
import { CHANNEL_MAP } from '../transport/channel-map'
import { createCallbackServer } from '@craft-agent/shared/auth/callback-server'
import { isAddSourceButtonEnabled } from '@craft-agent/shared/feature-flags'
import {
CLIENT_OPEN_EXTERNAL,
CLIENT_OPEN_PATH,
Expand Down Expand Up @@ -187,6 +188,7 @@ client.handleCapability(CLIENT_OPEN_FILE_DIALOG, async (spec: FileDialogSpec) =>
const api = buildClientApi(client, CHANNEL_MAP, (ch) => client.isChannelAvailable(ch))

;(api as any).getRuntimeEnvironment = (): 'electron' | 'web' => 'electron'
;(api as any).isAddSourceButtonEnabled = (): boolean => isAddSourceButtonEnabled()

// ---------------------------------------------------------------------------
// Transport connection state logging (for remote connections)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4970,8 +4970,8 @@ function AppShellContent({
</StyledDropdownMenuContent>
</DropdownMenu>
)}
{/* Add Source button (only for sources mode) - uses filter-aware edit config */}
{isSourcesNavigation(navState) && activeWorkspace && (
{/* Add Source button (only for sources mode) - uses filter-aware edit config. Hidden unless enabled via launch flag. */}
{isSourcesNavigation(navState) && activeWorkspace && window.electronAPI.isAddSourceButtonEnabled() && (
<EditPopover
trigger={
<HeaderIconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ export const mockElectronAPI = {
// branch between Electron and web-UI rendering. Must be synchronous.
getRuntimeEnvironment: (): 'electron' | 'web' => 'electron',

// Keep the sources panel "add source" button visible in the playground.
isAddSourceButtonEnabled: () => true,

openFileDialog: async () => {
console.log('[Playground] openFileDialog called')
return [] // Let user use file input or drag-drop
Expand Down
2 changes: 2 additions & 0 deletions packages/desktop/apps/electron/src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ export interface ElectronAPI {
getVersions(): { node: string; chrome: string; electron: string };
/** Returns the renderer host environment without going through RPC. */
getRuntimeEnvironment(): 'electron' | 'web';
/** Whether the sources panel "add source" header button is shown. Preload-local launch flag. */
isAddSourceButtonEnabled(): boolean;
getHomeDir(): Promise<string>;
isDebugMode(): Promise<boolean>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ApiToChannelMapKeys = Exclude<
| 'performOAuth'
| 'getTransportConnectionState'
| 'getRuntimeEnvironment'
| 'isAddSourceButtonEnabled' // reads launch env var in the preload — no IPC needed
| 'onTransportConnectionStateChanged'
| 'reconnectTransport'
| 'isChannelAvailable'
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/apps/webui/src/adapter/web-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export function createWebApi(options: WebApiOptions): {
// System info
getVersions: () => ({ node: 'n/a', chrome: navigator.userAgent, electron: 'web' }),
getRuntimeEnvironment: () => 'web',
isAddSourceButtonEnabled: () => false,
getSystemWarnings: () => Promise.resolve({ vcredistMissing: false }),
isDebugMode: () => Promise.resolve(import.meta.env.DEV),

Expand Down
19 changes: 19 additions & 0 deletions packages/desktop/packages/shared/src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ export function isEmbeddedServerEnabled(): boolean {
return false;
}

/**
* Runtime-evaluated check for the sources panel "add source" header button.
*
* Defaults to disabled. Override with CRAFT_FEATURE_ADD_SOURCE_BUTTON=1|0.
*/
export function isAddSourceButtonEnabled(): boolean {
const override = parseBooleanEnv(getEnv('CRAFT_FEATURE_ADD_SOURCE_BUTTON'));
if (override !== undefined) return override;
return false;
}

export const FEATURE_FLAGS = {
/** Enable Opus 4.7 fast mode (speed:"fast" + beta header). 6x pricing. */
fastMode: false,
Expand Down Expand Up @@ -89,4 +100,12 @@ export const FEATURE_FLAGS = {
get embeddedServer(): boolean {
return isEmbeddedServerEnabled();
},
/**
* Show the "add source" button in the sources panel header.
*
* Defaults to disabled. Override with CRAFT_FEATURE_ADD_SOURCE_BUTTON=1|0.
*/
get addSourceButton(): boolean {
return isAddSourceButtonEnabled();
},
} as const;
Loading