-
Notifications
You must be signed in to change notification settings - Fork 231
feat: add ability to pin agents which will be visible everytime user … #1353
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
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,7 +1,8 @@ | ||||||||||||||||||||||||||||||||
| import React, { useState } from 'react'; | ||||||||||||||||||||||||||||||||
| import React, { useEffect, useState } from 'react'; | ||||||||||||||||||||||||||||||||
| import { rpc } from '@/lib/rpc'; | ||||||||||||||||||||||||||||||||
| import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select'; | ||||||||||||||||||||||||||||||||
| import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from './ui/tooltip'; | ||||||||||||||||||||||||||||||||
| import { Info, ExternalLink } from 'lucide-react'; | ||||||||||||||||||||||||||||||||
| import { Info, ExternalLink, Pin } from 'lucide-react'; | ||||||||||||||||||||||||||||||||
| import { type Agent } from '../types'; | ||||||||||||||||||||||||||||||||
| import { type AgentRun } from '../types/chat'; | ||||||||||||||||||||||||||||||||
| import { agentConfig } from '../lib/agentConfig'; | ||||||||||||||||||||||||||||||||
|
|
@@ -24,8 +25,47 @@ export const MultiAgentDropdown: React.FC<MultiAgentDropdownProps> = ({ | |||||||||||||||||||||||||||||||
| className = '', | ||||||||||||||||||||||||||||||||
| disabledAgents = [], | ||||||||||||||||||||||||||||||||
| }) => { | ||||||||||||||||||||||||||||||||
| // Use agentConfig order directly (already properly ordered) | ||||||||||||||||||||||||||||||||
| const sortedAgents = Object.entries(agentConfig); | ||||||||||||||||||||||||||||||||
| // Setup state for pinned agents (using localStorage to remember preferences) | ||||||||||||||||||||||||||||||||
| const [pinnedAgents, setPinnedAgents] = useState<string[]>([]); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
| // Setup state for pinned agents (using localStorage to remember preferences) | |
| const [pinnedAgents, setPinnedAgents] = useState<string[]>([]); | |
| // Setup state for pinned agents (persisted in app settings) | |
| const [pinnedAgents, setPinnedAgents] = useState<string[]>([]); |
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.
No rollback on settings save failure
setPinnedAgents(next) is called optimistically before the async rpc.appSettings.update call. If the update fails, the UI reflects the pin as toggled but the setting is never persisted — on the next app launch (or the next time this component mounts) the pin will silently disappear, leaving the user confused. The state should be rolled back when the call fails.
| setPinnedAgents(next); | |
| try { | |
| await rpc.appSettings.update({ pinnedAgents: next }); | |
| } catch (error) { | |
| console.error('Failed to save pinned agents', error); | |
| } | |
| setPinnedAgents(next); | |
| try { | |
| await rpc.appSettings.update({ pinnedAgents: next }); | |
| } catch (error) { | |
| console.error('Failed to save pinned agents', error); | |
| setPinnedAgents(pinnedAgents); // rollback optimistic update | |
| } |
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.
Missing deduplication for
pinnedAgentsThe
hiddenOpenInAppsnormalization immediately above uses[...new Set(validated)]to deduplicate entries.pinnedAgentsskips this step, so a corrupt or manually edited settings file could contain duplicate agent IDs. Duplicates won't break rendering but will cause an agent to appear pinned even after being "unpinned" (sincefilteronly removes it once per call).