Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface UserPreferencesApi {
setDeleteLocalBranch: (next: boolean) => void;
setShowPresetsBar: (next: boolean | ((prev: boolean) => boolean)) => void;
toggleShowPresetsBar: () => void;
setShowActivityPanelAutomatically: (next: boolean) => void;
setChangesViewMode: (next: ChangesViewMode) => void;
setSidebarProjectSortMode: (next: SidebarProjectSortMode) => void;
setSidebarProjectHostFilter: (next: SidebarProjectHostFilter) => void;
Expand Down Expand Up @@ -257,6 +258,22 @@ export function useUserPreferences(): UserPreferencesApi {
setShowPresetsBar((prev) => !prev);
}, [setShowPresetsBar]);

const setShowActivityPanelAutomatically = useCallback(
(next: boolean) => {
if (!collections.userPreferences.has(V2_USER_PREFERENCES_ID)) {
collections.userPreferences.insert({
...DEFAULT_V2_USER_PREFERENCES,
showActivityPanelAutomatically: next,
});
return;
}
collections.userPreferences.update(V2_USER_PREFERENCES_ID, (draft) => {
draft.showActivityPanelAutomatically = next;
});
},
[collections],
);

const setChangesViewMode = useCallback(
(next: ChangesViewMode) => {
const existing = collections.userPreferences.get(V2_USER_PREFERENCES_ID);
Expand Down Expand Up @@ -384,6 +401,7 @@ export function useUserPreferences(): UserPreferencesApi {
setDeleteLocalBranch,
setShowPresetsBar,
toggleShowPresetsBar,
setShowActivityPanelAutomatically,
setChangesViewMode,
setSidebarProjectSortMode,
setSidebarProjectHostFilter,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function resolveActivityPanelHidden(
workspaceHidden: boolean | undefined,
showActivityPanelAutomatically: boolean,
): boolean {
return workspaceHidden ?? !showActivityPanelAutomatically;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { eq } from "@tanstack/db";
import { useLiveQuery } from "@tanstack/react-db";
import { useCallback } from "react";
import { useUserPreferences } from "renderer/hooks/useUserPreferences";
import { useWorkspace } from "renderer/routes/_authenticated/_dashboard/workspace/providers/WorkspaceProvider";
import { useDashboardSidebarState } from "renderer/routes/_authenticated/hooks/useDashboardSidebarState";
import { useCollections } from "renderer/routes/_authenticated/providers/CollectionsProvider";
import { resolveActivityPanelHidden } from "./resolveActivityPanelHidden";

export function useActivityPanelVisibility(workspaceId: string) {
const collections = useCollections();
const { workspace } = useWorkspace();
const { preferences } = useUserPreferences();
const { ensureWorkspaceInSidebar } = useDashboardSidebarState();
const { data: rows = [] } = useLiveQuery(
(query) =>
Expand All @@ -20,10 +23,11 @@ export function useActivityPanelVisibility(workspaceId: string) {
})),
[collections, workspaceId],
);
const hidden =
const hidden = resolveActivityPanelHidden(
rows.find((row) => row.workspaceId === workspaceId)?.hidden ??
collections.workspaceLocalState.get(workspaceId)?.activityPanelHidden ??
false;
collections.workspaceLocalState.get(workspaceId)?.activityPanelHidden,
preferences.showActivityPanelAutomatically,
);
const setHidden = useCallback(
(next: boolean) => {
if (!collections.workspaceLocalState.has(workspaceId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ export const userPreferencesSchema = z.object({
changesFileListOpen: z.boolean().default(true),
deleteLocalBranch: z.boolean().default(false),
showPresetsBar: z.boolean().default(false),
showActivityPanelAutomatically: z.boolean().default(true),
changesViewMode: changesViewModeSchema.default("folders"),
// Ordering of the dashboard sidebar's Projects list; manual = drag order.
sidebarProjectSortMode: persistedSidebarProjectSortModeSchema,
Expand Down Expand Up @@ -565,6 +566,7 @@ export const DEFAULT_V2_USER_PREFERENCES: UserPreferencesRow = {
changesFileListOpen: true,
deleteLocalBranch: false,
showPresetsBar: false,
showActivityPanelAutomatically: true,
changesViewMode: "folders",
sidebarProjectSortMode: "manual",
sidebarProjectHostFilter: "all",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
createCollection,
localStorageCollectionOptions,
} from "@tanstack/react-db";
import { resolveActivityPanelHidden } from "renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/components/WorkspaceActivityMenu/hooks/useActivityPanelVisibility/resolveActivityPanelHidden";
import {
DEFAULT_V2_USER_PREFERENCES,
healUserPreferences,
Expand Down Expand Up @@ -36,27 +37,32 @@ const noopEvents = {
removeEventListener: () => {},
};

function makeActivityCollection(
id: string,
storage: ReturnType<typeof makeMapStorage>["api"],
) {
return createCollection(
localStorageCollectionOptions(
withReadHeal(
{
id,
storageKey: "test-activity-visibility",
schema: workspaceLocalStateSchema,
getKey: (item: WorkspaceLocalStateRow) => item.workspaceId,
storage,
storageEventApi: noopEvents,
},
healWorkspaceLocalState,
),
),
);
}

it("workspace activity choices survive saving and reopening the workspace collection", async () => {
const { api: storage } = makeMapStorage();
const makeCollection = (id: string) =>
createCollection(
localStorageCollectionOptions(
withReadHeal(
{
id,
storageKey: "test-activity-visibility",
schema: workspaceLocalStateSchema,
getKey: (item: WorkspaceLocalStateRow) => item.workspaceId,
storage,
storageEventApi: noopEvents,
},
healWorkspaceLocalState,
),
),
);
const hiddenId = "11111111-1111-4111-8111-111111111111";
const shownId = "22222222-2222-4222-8222-222222222222";
const before = makeCollection("activity-before");
const before = makeActivityCollection("activity-before", storage);
await before.preload();
for (const workspaceId of [hiddenId, shownId]) {
await before.insert({
Expand All @@ -75,19 +81,82 @@ it("workspace activity choices survive saving and reopening the workspace collec
}).isPersisted.promise;
}
await before.cleanup();
const after = makeCollection("activity-after");
const after = makeActivityCollection("activity-after", storage);
await after.preload();
expect(after.get(hiddenId)?.activityPanelHidden).toBe(true);
expect(after.get(shownId)?.activityPanelHidden).toBe(false);
await after.delete(hiddenId).isPersisted.promise;
await after.cleanup();
const reopened = makeCollection("activity-reopened");
const reopened = makeActivityCollection("activity-reopened", storage);
await reopened.preload();
expect(reopened.has(hiddenId)).toBe(false);
expect(reopened.get(shownId)?.activityPanelHidden).toBe(false);
await reopened.cleanup();
});

it("keeps the automatic activity default after deleting the last workspace", async () => {
const { api: storage } = makeMapStorage();
const makePreferences = (id: string) =>
createCollection(
localStorageCollectionOptions(
withReadHeal(
{
id,
storageKey: "test-activity-preferences",
schema: userPreferencesSchema,
getKey: (item: UserPreferencesRow) => item.id,
storage,
storageEventApi: noopEvents,
},
healUserPreferences,
),
),
);
const first = makePreferences("activity-preferences-first");
const workspaces = makeActivityCollection(
"activity-default-workspaces",
storage,
);
await Promise.all([first.preload(), workspaces.preload()]);
await first.insert({
id: V2_USER_PREFERENCES_ID,
sidebarProjectSortMode: "manual",
sidebarProjectHostFilter: "all",
}).isPersisted.promise;
expect(
first.get(V2_USER_PREFERENCES_ID)?.showActivityPanelAutomatically,
).toBe(true);
await first.update(V2_USER_PREFERENCES_ID, (draft) => {
draft.showActivityPanelAutomatically = false;
}).isPersisted.promise;
const workspaceId = "11111111-1111-4111-8111-111111111111";
await workspaces.insert({
workspaceId,
createdAt: new Date(),
sidebarState: { projectId: null },
paneLayout: { version: 1, tabs: [], activeTabId: null },
activityPanelHidden: false,
}).isPersisted.promise;
expect(
resolveActivityPanelHidden(
workspaces.get(workspaceId)?.activityPanelHidden,
first.get(V2_USER_PREFERENCES_ID)?.showActivityPanelAutomatically ?? true,
),
).toBe(false);
await workspaces.delete(workspaceId).isPersisted.promise;
await Promise.all([first.cleanup(), workspaces.cleanup()]);

const reopened = makePreferences("activity-preferences-reopened");
await reopened.preload();
const preference = reopened.get(
V2_USER_PREFERENCES_ID,
)?.showActivityPanelAutomatically;
expect(preference).toBe(false);
expect(resolveActivityPanelHidden(undefined, preference ?? true)).toBe(true);
expect(resolveActivityPanelHidden(true, true)).toBe(true);
await reopened.cleanup();
});

describe("withReadHeal parser", () => {
it("heals each entry's data through the heal fn while preserving the envelope", () => {
const heal = (raw: unknown) => ({ ...(raw as object), healed: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
SETTING_ITEM_ID,
type SettingItemId,
} from "../../../utils/settings-search";
import { ActivityPanelSection } from "./components/ActivityPanelSection";
import { FontSettingSection } from "./components/FontSettingSection";
import { LanguageSection } from "./components/LanguageSection";
import { MarkdownStyleSection } from "./components/MarkdownStyleSection";
Expand Down Expand Up @@ -55,6 +56,10 @@ export function AppearanceSettings({ visibleItems }: AppearanceSettingsProps) {
SETTING_ITEM_ID.APPEARANCE_LANGUAGE,
visibleItems,
);
const showActivityPanel = isItemVisible(
SETTING_ITEM_ID.APPEARANCE_ACTIVITY_PANEL,
visibleItems,
);
const showThemeSection = showTheme || showCustomThemes;

return (
Expand All @@ -69,14 +74,18 @@ export function AppearanceSettings({ visibleItems }: AppearanceSettingsProps) {
</div>

<SectionList>
{(showThemeSection || showLanguage || showMarkdown) && (
{(showThemeSection ||
showLanguage ||
showMarkdown ||
showActivityPanel) && (
<div
key="appearance-card"
className="rounded-lg border border-border overflow-hidden divide-y divide-border"
>
{showThemeSection && <ThemeSection />}
{showLanguage && <LanguageSection />}
{showMarkdown && <MarkdownStyleSection />}
{showActivityPanel && <ActivityPanelSection />}
</div>
)}
{(showEditorFont || showTerminalFont) && (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { useLingui } from "@lingui/react/macro";
import { Label } from "@superset/ui/label";
import { Switch } from "@superset/ui/switch";
import { useId } from "react";
import { useUserPreferences } from "renderer/hooks/useUserPreferences";
import { HighlightText } from "renderer/routes/_authenticated/settings/components/HighlightText";
import { useSettingsSearchQuery } from "renderer/stores/settings-state";

export function ActivityPanelSection() {
const { t } = useLingui();
const { preferences, setShowActivityPanelAutomatically } =
useUserPreferences();
const searchQuery = useSettingsSearchQuery();
const id = useId();

return (
<div className="flex items-center justify-between gap-6 p-4">
<Label htmlFor={id} className="min-w-0 text-sm font-medium">
<HighlightText
text={t({ message: "Show activity panel automatically" })}
query={searchQuery}
/>
</Label>
<Switch
id={id}
checked={preferences.showActivityPanelAutomatically}
onCheckedChange={setShowActivityPanelAutomatically}
/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ActivityPanelSection } from "./ActivityPanelSection";
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ function getIds(items: SettingsItem[]): string[] {
return items.map((item) => item.id);
}

it("finds the activity panel default in Appearance settings", () => {
expect(
searchSettings("activity panel").find(
(item) => item.id === SETTING_ITEM_ID.APPEARANCE_ACTIVITY_PANEL,
)?.section,
).toBe("appearance");
});

describe("settings search - font settings", () => {
it('searching "font" returns both APPEARANCE_EDITOR_FONT and APPEARANCE_TERMINAL_FONT', () => {
const results = searchSettings("font");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const SETTING_ITEM_ID = {
APPEARANCE_THEME: "appearance-theme",
APPEARANCE_LANGUAGE: "appearance-language",
APPEARANCE_MARKDOWN: "appearance-markdown",
APPEARANCE_ACTIVITY_PANEL: "appearance-activity-panel",
APPEARANCE_CUSTOM_THEMES: "appearance-custom-themes",
APPEARANCE_EDITOR_FONT: "appearance-editor-font",
APPEARANCE_TERMINAL_FONT: "appearance-terminal-font",
Expand Down Expand Up @@ -517,6 +518,13 @@ const SETTINGS_ITEMS: SettingsItem[] = [
"customize",
],
},
{
id: SETTING_ITEM_ID.APPEARANCE_ACTIVITY_PANEL,
section: "appearance",
title: "Show activity panel automatically",
description: "Choose whether the workspace activity panel opens by default",
keywords: ["workspace", "activity", "panel", "dock", "hide", "default"],
},
{
id: SETTING_ITEM_ID.APPEARANCE_EDITOR_FONT,
section: "appearance",
Expand Down
3 changes: 3 additions & 0 deletions packages/i18n/locales/cs/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -18536,6 +18536,9 @@ msgstr "Zobrazit před ukončením aplikace potvrzovací dialog"
msgid "Show a microphone in the chat composer. Speech is transcribed by ChatGPT when Codex is signed in to it, otherwise on your Mac when possible, and otherwise by Paradev's servers."
msgstr "Zobrazit v editoru chatu mikrofon. Řeč přepisuje ChatGPT, pokud je k němu přihlášen Codex, jinak se přepisuje na vašem Macu, když to jde, a jinak na serverech Paradev."

msgid "Show activity panel automatically"
msgstr "Automaticky zobrazovat panel aktivity"

msgid "Show all {count}"
msgstr "Zobrazit všech {count}"

Expand Down
3 changes: 3 additions & 0 deletions packages/i18n/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -18536,6 +18536,9 @@ msgstr "Beim Beenden der App einen Bestätigungsdialog anzeigen"
msgid "Show a microphone in the chat composer. Speech is transcribed by ChatGPT when Codex is signed in to it, otherwise on your Mac when possible, and otherwise by Paradev's servers."
msgstr "Im Chat-Eingabefeld ein Mikrofon anzeigen. Sprache wird von ChatGPT transkribiert, wenn Codex dort angemeldet ist, sonst wenn möglich auf deinem Mac und andernfalls auf den Servern von Paradev."

msgid "Show activity panel automatically"
msgstr "Aktivitätsbereich automatisch anzeigen"

msgid "Show all {count}"
msgstr "Alle {count} anzeigen"

Expand Down
3 changes: 3 additions & 0 deletions packages/i18n/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -18536,6 +18536,9 @@ msgstr "Show a confirmation dialog when quitting the app"
msgid "Show a microphone in the chat composer. Speech is transcribed by ChatGPT when Codex is signed in to it, otherwise on your Mac when possible, and otherwise by Paradev's servers."
msgstr "Show a microphone in the chat composer. Speech is transcribed by ChatGPT when Codex is signed in to it, otherwise on your Mac when possible, and otherwise by Paradev's servers."

msgid "Show activity panel automatically"
msgstr "Show activity panel automatically"

msgid "Show all {count}"
msgstr "Show all {count}"

Expand Down
3 changes: 3 additions & 0 deletions packages/i18n/locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -18536,6 +18536,9 @@ msgstr "Mostrar un diálogo de confirmación al salir de la app"
msgid "Show a microphone in the chat composer. Speech is transcribed by ChatGPT when Codex is signed in to it, otherwise on your Mac when possible, and otherwise by Paradev's servers."
msgstr "Mostrar un micrófono en el editor del chat. ChatGPT transcribe la voz cuando Codex tiene la sesión iniciada en él; si no, se transcribe en tu Mac cuando es posible y, si no, en los servidores de Paradev."

msgid "Show activity panel automatically"
msgstr "Mostrar automáticamente el panel de actividad"

msgid "Show all {count}"
msgstr "Mostrar los {count}"

Expand Down
3 changes: 3 additions & 0 deletions packages/i18n/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -18536,6 +18536,9 @@ msgstr "Afficher une boîte de dialogue de confirmation à la fermeture de l'app
msgid "Show a microphone in the chat composer. Speech is transcribed by ChatGPT when Codex is signed in to it, otherwise on your Mac when possible, and otherwise by Paradev's servers."
msgstr "Afficher un micro dans le champ de saisie du chat. La parole est transcrite par ChatGPT lorsque Codex y est connecté, sinon sur votre Mac quand c'est possible, et à défaut par les serveurs de Paradev."

msgid "Show activity panel automatically"
msgstr "Afficher automatiquement le panneau d’activité"

msgid "Show all {count}"
msgstr "Afficher les {count}"

Expand Down
Loading
Loading