feat: implement preferences management for plugins

Added functionality to manage plugin preferences, including getting and setting preferences through the sidecar. Introduced a PreferencesStore to handle preference persistence and retrieval. Updated relevant components to support preference interactions, enhancing user experience in plugin settings.
This commit is contained in:
ByteAtATime 2025-06-15 14:14:16 -07:00
parent 09486045c8
commit 3e0fb8fca3
No known key found for this signature in database
9 changed files with 417 additions and 11 deletions

View file

@ -72,13 +72,32 @@ const LogMessageSchema = z.object({
export const SidecarMessageSchema = z.union([BatchUpdateSchema, CommandSchema, LogMessageSchema]);
export type SidecarMessage = z.infer<typeof SidecarMessageSchema>;
export const PreferenceSchema = z.object({
name: z.string(),
title: z.string(),
description: z.string().optional(),
type: z.enum(['textfield', 'dropdown', 'checkbox', 'directory']),
required: z.boolean().optional(),
default: z.union([z.string(), z.boolean()]).optional(),
data: z
.array(
z.object({
title: z.string(),
value: z.string()
})
)
.optional()
});
export type Preference = z.infer<typeof PreferenceSchema>;
export const PluginInfoSchema = z.object({
title: z.string(),
description: z.string().optional(),
pluginName: z.string(),
commandName: z.string(),
pluginPath: z.string(),
icon: z.string().optional()
icon: z.string().optional(),
preferences: z.array(PreferenceSchema).optional()
});
export type PluginInfo = z.infer<typeof PluginInfoSchema>;
@ -88,6 +107,15 @@ export const PluginListSchema = z.object({
});
export type PluginList = z.infer<typeof PluginListSchema>;
export const PreferenceValuesSchema = z.object({
type: z.literal('preference-values'),
payload: z.object({
pluginName: z.string(),
values: z.record(z.string(), z.unknown())
})
});
export type PreferenceValues = z.infer<typeof PreferenceValuesSchema>;
export const GoBackToPluginListSchema = z.object({
type: z.literal('go-back-to-plugin-list'),
payload: z.object({})
@ -99,6 +127,7 @@ export const SidecarMessageWithPluginsSchema = z.union([
CommandSchema,
LogMessageSchema,
PluginListSchema,
PreferenceValuesSchema,
GoBackToPluginListSchema
]);
export type SidecarMessageWithPlugins = z.infer<typeof SidecarMessageWithPluginsSchema>;