Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(settings): add admin panel for debug actions (#3968)

Aidan Holloway-Bidwell4072ad3e3d54
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index 517270ab64..0e43efef6f 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -66,6 +66,7 @@ import { SplitPanelContext } from '@app/component/split-layout/context';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import { LIST_VIEW_DOCS_URL } from '@app/constants/docs-links';
import { isListViewID, type ListView } from '@app/constants/list-views';
+import { DEBUG_SETTING_KEYS, useDebugSetting } from '@app/lib/debugSettings';
import { usePreference } from '@app/preferences/use-preference';
import { CustomScrollbar } from '@core/component/CustomScrollbar';
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
@@ -634,6 +635,11 @@ export const SoupViewList = (props: SoupViewListProps) => {
const { hasActiveRefinements, hasHiddenItems, resetToTabDefaults } =
useFilterRefinements();
+ // Debug: force nav views to render their empty state regardless of content.
+ const forceEmptyState = useDebugSetting(
+ DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES
+ );
+
const { isKeypressActive } = useIsKeyPressActive();
const [virtualizerHandle, setVirtualizerHandle] =
@@ -1108,7 +1114,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
Searching...
</div>
</Match>
- <Match when={!rows().length}>
+ <Match when={!rows().length || forceEmptyState()}>
<EmptyState
listView={currentView()}
search={!!searchText()}
diff --git a/js/app/packages/app/component/settings/Account.tsx b/js/app/packages/app/component/settings/Account.tsx
index 32fd12aa15..7ade7e13cf 100644
--- a/js/app/packages/app/component/settings/Account.tsx
+++ b/js/app/packages/app/component/settings/Account.tsx
@@ -52,6 +52,7 @@ import {
Switch,
} from 'solid-js';
import { usePermissions } from '@core/context/user';
+import { PERMISSION_IDS } from '@core/constant/permissions';
import { useSettingsState } from '@core/constant/SettingsState';
import PaywallComponent from '../paywall/PaywallComponent';
import PaywallTeamMemberView from '../paywall/PaywallTeamMemberView';
@@ -459,7 +460,7 @@ export function Account() {
</Panel.Header>
<Panel.Toolbar class="h-full w-full">
- <Show when={permissions()?.includes('write:stripe_subscription') && !isNativeMobilePlatform()}>
+ <Show when={permissions()?.includes(PERMISSION_IDS.WRITE_STRIPE_SUBSCRIPTION) && !isNativeMobilePlatform()}>
<div class="px-4 py-2 w-full">
<ShowFeatureFlag
key="enable-new-pricing"
diff --git a/js/app/packages/app/component/settings/Admin.tsx b/js/app/packages/app/component/settings/Admin.tsx
new file mode 100644
index 0000000000..7afa706fe5
--- /dev/null
+++ b/js/app/packages/app/component/settings/Admin.tsx
@@ -0,0 +1,68 @@
+import { For } from 'solid-js';
+import { Button, Panel, ToggleSwitch } from '@ui';
+import {
+ type DebugSettingDef,
+ DEBUG_SETTINGS,
+ clearAllDebugSettings,
+ debugSettings,
+ getDebugSetting,
+ setDebugSetting,
+} from '@app/lib/debugSettings';
+
+function DebugSettingRow(props: { setting: DebugSettingDef }) {
+ const checked = () => getDebugSetting(props.setting.key);
+
+ return (
+ <div class="flex items-center justify-between gap-4 py-2 px-6">
+ <div class="min-w-0">
+ <div class="text-sm">{props.setting.label}</div>
+ <div class="text-xs text-ink-extra-muted">
+ {props.setting.description}
+ </div>
+ </div>
+ <ToggleSwitch
+ checked={checked()}
+ onChange={(value) => setDebugSetting(props.setting.key, value)}
+ />
+ </div>
+ );
+}
+
+export function Admin() {
+ const hasActiveSettings = () => Object.keys(debugSettings()).length > 0;
+
+ return (
+ <div class="h-full overflow-hidden flex justify-center p-2">
+ <div class="max-w-200 size-full">
+ <Panel depth={2}>
+ <Panel.Header>
+ <div class="flex items-center justify-between gap-4 w-full px-2 py-2">
+ <div>
+ <div class="text-sm font-medium">Debug settings</div>
+ <div class="text-xs text-ink-extra-muted">
+ Local toggles for debugging — only visible to Macro staff.
+ </div>
+ </div>
+ <Button
+ variant="base"
+ size="sm"
+ disabled={!hasActiveSettings()}
+ onClick={clearAllDebugSettings}
+ >
+ Reset all
+ </Button>
+ </div>
+ </Panel.Header>
+
+ <Panel.Body scroll>
+ <div class="flex flex-col py-2">
+ <For each={DEBUG_SETTINGS}>
+ {(setting) => <DebugSettingRow setting={setting} />}
+ </For>
+ </div>
+ </Panel.Body>
+ </Panel>
+ </div>
+ </div>
+ );
+}
diff --git a/js/app/packages/app/component/settings/Settings.tsx b/js/app/packages/app/component/settings/Settings.tsx
index 3b9426820a..413eb17f95 100644
--- a/js/app/packages/app/component/settings/Settings.tsx
+++ b/js/app/packages/app/component/settings/Settings.tsx
@@ -6,7 +6,10 @@ import { DEV_MODE_ENV, ENABLE_APP_STORE_QR_CODE, ENABLE_TEAMS_OVERRIDE } from '@
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { MobileApp } from './MobileApp';
import { Agent } from './Agent';
+import { Admin } from './Admin';
import { Appearance } from './Appearance';
+import { useHasPermission } from '@core/context/user';
+import { PERMISSION_IDS } from '@core/constant/permissions';
import { TabsInset } from '@core/component/TabsInset';
import { TabsInsetDropdown } from '@core/component/TabsInsetDropdown';
import { Account } from './Account';
@@ -42,6 +45,7 @@ type SettingsPanelProps = {
function SettingsPanel(props: SettingsPanelProps) {
const { closeSettings, activeTabId, setActiveTabId } = useSettingsState();
const teamsFlag = useFeatureFlag('enable-teams-settings', { enabledOverride: ENABLE_TEAMS_OVERRIDE });
+ const hasAdminPanel = useHasPermission(PERMISSION_IDS.WRITE_ADMIN_PANEL);
// Set up hotkey scope for settings panel
const [attachHotkeys, settingsHotkeyScope] = useHotkeyDOMScope('settings');
@@ -57,6 +61,7 @@ function SettingsPanel(props: SettingsPanelProps) {
if (ENABLE_APP_STORE_QR_CODE && !isNativeMobilePlatform()) { tabs.push({ value: 'Mobile App', label: 'App' }) }
if (!isNativeMobilePlatform()) { tabs.push({ value: 'Agent', label: 'MCPs' }) }
if (isNativeMobilePlatform() && DEV_MODE_ENV) { tabs.push({ value: 'Mobile', label: 'Mobile Dev Tools' }) }
+ if (hasAdminPanel()) { tabs.push({ value: 'Admin', label: 'Admin' }) }
return tabs;
}
@@ -224,6 +229,9 @@ function SettingsPanel(props: SettingsPanelProps) {
<Show when={activeTabId() === 'Agent' && !isNativeMobilePlatform()}>
<Agent />
</Show>
+ <Show when={activeTabId() === 'Admin' && hasAdminPanel()}>
+ <Admin />
+ </Show>
</div>
<Show when={isMobile()}>
diff --git a/js/app/packages/app/lib/debugSettings.ts b/js/app/packages/app/lib/debugSettings.ts
new file mode 100644
index 0000000000..b026d03b2b
--- /dev/null
+++ b/js/app/packages/app/lib/debugSettings.ts
@@ -0,0 +1,92 @@
+import { type Accessor, createSignal } from 'solid-js';
+
+/**
+ * Local, client-only debug settings for internal staff.
+ *
+ * Unlike PostHog feature flags (which are evaluated per-user via rollout),
+ * these are simple booleans an admin toggles for their own session — surfaced
+ * in the Admin settings panel and persisted to localStorage. They never touch
+ * PostHog; a setting defaults to `false` when not explicitly enabled.
+ */
+
+export const DEBUG_SETTING_KEYS = {
+ FORCE_EMPTY_STATES: 'force-empty-states',
+} as const;
+
+export type DebugSettingKey =
+ (typeof DEBUG_SETTING_KEYS)[keyof typeof DEBUG_SETTING_KEYS];
+
+export type DebugSettingDef = {
+ key: DebugSettingKey;
+ label: string;
+ description: string;
+};
+
+/** Debug settings surfaced in the Admin panel. */
+export const DEBUG_SETTINGS: DebugSettingDef[] = [
+ {
+ key: DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES,
+ label: 'Force empty states',
+ description:
+ 'Short-circuits sidebar nav views to their empty state regardless of content, for debugging empty states.',
+ },
+];
+
+const STORAGE_KEY = 'macro:debug-settings';
+
+function readPersisted(): Record<string, boolean> {
+ try {
+ const raw = globalThis.localStorage?.getItem(STORAGE_KEY);
+ if (!raw) return {};
+ const parsed = JSON.parse(raw);
+ if (parsed && typeof parsed === 'object') {
+ return parsed as Record<string, boolean>;
+ }
+ } catch {
+ // ignore malformed / unavailable storage
+ }
+ return {};
+}
+
+function persist(settings: Record<string, boolean>): void {
+ try {
+ globalThis.localStorage?.setItem(STORAGE_KEY, JSON.stringify(settings));
+ } catch {
+ // ignore unavailable storage
+ }
+}
+
+const [settings, setSettings] = createSignal<Record<string, boolean>>(
+ readPersisted()
+);
+
+/** Reactive accessor for the full debug-settings map. */
+export { settings as debugSettings };
+
+/** Reactive read of a single debug setting (defaults to `false`). */
+export function getDebugSetting(key: DebugSettingKey): boolean {
+ return settings()[key] ?? false;
+}
+
+/** Enable or disable a debug setting. */
+export function setDebugSetting(key: DebugSettingKey, value: boolean): void {
+ const next = { ...settings() };
+ if (value) {
+ next[key] = true;
+ } else {
+ delete next[key];
+ }
+ setSettings(next);
+ persist(next);
+}
+
+/** Turn every debug setting back off. */
+export function clearAllDebugSettings(): void {
+ setSettings({});
+ persist({});
+}
+
+/** Reactive accessor hook for a single debug setting. */
+export function useDebugSetting(key: DebugSettingKey): Accessor<boolean> {
+ return () => getDebugSetting(key);
+}
diff --git a/js/app/packages/core/constant/SettingsState.tsx b/js/app/packages/core/constant/SettingsState.tsx
index 62d9635ced..065669aac8 100644
--- a/js/app/packages/core/constant/SettingsState.tsx
+++ b/js/app/packages/core/constant/SettingsState.tsx
@@ -14,7 +14,8 @@ export type SettingsTab =
| 'Shortcuts'
| 'Mobile App'
| 'Agent'
- | 'Team';
+ | 'Team'
+ | 'Admin';
const [activeTabId, setActiveTabId] = createSignal<SettingsTab>('Appearance');
diff --git a/js/app/packages/core/constant/permissions.ts b/js/app/packages/core/constant/permissions.ts
new file mode 100644
index 0000000000..526dd856d0
--- /dev/null
+++ b/js/app/packages/core/constant/permissions.ts
@@ -0,0 +1,25 @@
+/**
+ * RBAC permission identifiers, mirroring the backend `PermissionId` enum
+ * (rust/cloud-storage/roles_and_permissions/src/domain/model.rs). The user's
+ * granted permissions are exposed on the frontend via `usePermissions()` /
+ * `useHasPermission()` in `@core/context/user`.
+ *
+ * Prefer referencing these constants over hardcoding the raw permission strings.
+ */
+export const PERMISSION_IDS = {
+ WRITE_STRIPE_SUBSCRIPTION: 'write:stripe_subscription',
+ READ_PROFESSIONAL_FEATURES: 'read:professional_features',
+ WRITE_RELEASE_EMAIL: 'write:release_email',
+ WRITE_ADMIN_PANEL: 'write:admin_panel',
+ WRITE_ENTERPRISE_SUBSCRIPTIONS: 'write:enterprise_subscriptions',
+ WRITE_DISCOUNT: 'write:discount',
+ WRITE_IT_PANEL: 'write:it_panel',
+ WRITE_EMAIL_TOOL: 'write:email_tool',
+ WRITE_AI_FEATURES: 'write:ai_features',
+ READ_DOCX_EDITOR: 'read:docx_editor',
+ WRITE_HAIKU: 'write:haiku',
+ WRITE_SONNET: 'write:sonnet',
+ WRITE_OPUS: 'write:opus',
+} as const;
+
+export type PermissionId = (typeof PERMISSION_IDS)[keyof typeof PERMISSION_IDS];
diff --git a/js/app/packages/core/context/user.ts b/js/app/packages/core/context/user.ts
index df3f0bb141..b771ec405a 100644
--- a/js/app/packages/core/context/user.ts
+++ b/js/app/packages/core/context/user.ts
@@ -1,3 +1,4 @@
+import type { PermissionId } from '@core/constant/permissions';
import { type UserInfoData, useUserInfoQuery } from '@queries/auth/user-info';
import { queryReadyGate } from '@queries/gate';
import { type Accessor, createMemo } from 'solid-js';
@@ -86,6 +87,12 @@ export function usePermissions() {
return useUserContext().permissions;
}
+/** Reactive check for whether the current user has a specific permission. */
+export function useHasPermission(id: PermissionId): Accessor<boolean> {
+ const permissions = usePermissions();
+ return () => permissions().includes(id);
+}
+
export function useAuthor() {
return useUserContext().author;
}