-
Notifications
You must be signed in to change notification settings - Fork 152
Filter control for what models on main tab #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| import { useMemo } from "react" | ||
| import type { PluginMeta } from "@/lib/plugin-types" | ||
| import type { ManifestLine, PluginMeta } from "@/lib/plugin-types" | ||
| import type { PluginSettings } from "@/lib/settings" | ||
|
|
||
| export type SettingsPluginState = { | ||
| id: string | ||
| name: string | ||
| enabled: boolean | ||
| lines: ManifestLine[] | ||
| disabledOverviewLabels: string[] | ||
| } | ||
|
Comment on lines
5
to
11
|
||
|
|
||
| type UseSettingsPluginListArgs = { | ||
|
|
@@ -26,6 +28,8 @@ export function useSettingsPluginList({ pluginSettings, pluginsMeta }: UseSettin | |
| id, | ||
| name: meta.name, | ||
| enabled: !pluginSettings.disabled.includes(id), | ||
| lines: meta.lines, | ||
| disabledOverviewLabels: pluginSettings.disabledOverviewLabels?.[id] || [], | ||
| } | ||
| }) | ||
| .filter((plugin): plugin is SettingsPluginState => Boolean(plugin)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ export const REFRESH_COOLDOWN_MS = 300_000; | |
| export type PluginSettings = { | ||
| order: string[]; | ||
| disabled: string[]; | ||
| disabledOverviewLabels?: Record<string, string[]>; | ||
| }; | ||
|
|
||
| export type AutoUpdateIntervalMinutes = 5 | 15 | 30 | 60; | ||
|
|
@@ -83,6 +84,7 @@ const DEFAULT_ENABLED_PLUGINS = new Set(["claude", "codex", "cursor"]); | |
| export const DEFAULT_PLUGIN_SETTINGS: PluginSettings = { | ||
| order: [], | ||
| disabled: [], | ||
| disabledOverviewLabels: {}, | ||
| }; | ||
|
|
||
| export async function loadPluginSettings(): Promise<PluginSettings> { | ||
|
|
@@ -91,6 +93,7 @@ export async function loadPluginSettings(): Promise<PluginSettings> { | |
| return { | ||
| order: Array.isArray(stored.order) ? stored.order : [], | ||
| disabled: Array.isArray(stored.disabled) ? stored.disabled : [], | ||
| disabledOverviewLabels: stored.disabledOverviewLabels || {}, | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -148,7 +151,16 @@ export function normalizePluginSettings( | |
| disabled.push(id); | ||
| } | ||
| } | ||
| return { order, disabled }; | ||
| const disabledOverviewLabels: Record<string, string[]> = {}; | ||
| if (settings.disabledOverviewLabels) { | ||
| for (const [id, labels] of Object.entries(settings.disabledOverviewLabels)) { | ||
| if (knownSet.has(id) && Array.isArray(labels)) { | ||
| disabledOverviewLabels[id] = labels; | ||
| } | ||
| } | ||
|
Comment on lines
+154
to
+160
|
||
| } | ||
|
|
||
| return { order, disabled, disabledOverviewLabels }; | ||
| } | ||
|
|
||
| export function arePluginSettingsEqual( | ||
|
|
@@ -163,6 +175,19 @@ export function arePluginSettingsEqual( | |
| for (let i = 0; i < a.disabled.length; i += 1) { | ||
| if (a.disabled[i] !== b.disabled[i]) return false; | ||
| } | ||
| const aLabels = a.disabledOverviewLabels || {}; | ||
| const bLabels = b.disabledOverviewLabels || {}; | ||
| const aKeys = Object.keys(aLabels); | ||
| const bKeys = Object.keys(bLabels); | ||
| if (aKeys.length !== bKeys.length) return false; | ||
| for (const key of aKeys) { | ||
| const aList = aLabels[key]; | ||
| const bList = bLabels[key]; | ||
| if (!bList || aList.length !== bList.length) return false; | ||
| for (let i = 0; i < aList.length; i += 1) { | ||
| if (aList[i] !== bList[i]) return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the last disabled label is re-enabled,
handleToggleOverviewLabelwill persist an empty array for that plugin id (e.g.{ disabledOverviewLabels: { [pluginId]: [] } }). This is semantically equivalent to omitting the key, butarePluginSettingsEqual()will treat{}vs{id: []}as different and it also bloats the stored settings. Consider deleting the key whennextDisabled.length === 0instead of storing an empty list.