Add repo-added notifications (#19)
* repo-added notifications feature - Add repo-added notifications * Fix lint issues in repos slice: use type alias, add curly braces Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
cfc3dfcbb4
commit
9d8ede4980
@@ -1,8 +1,8 @@
|
||||
import { useEffect } from 'react'
|
||||
import { Toaster } from 'sonner'
|
||||
import { Minimize2, PanelLeft, PanelRight } from 'lucide-react'
|
||||
import { TOGGLE_TERMINAL_PANE_EXPAND_EVENT } from '@/constants/terminal'
|
||||
import { syncZoomCSSVar } from '@/lib/ui-zoom'
|
||||
import { Toaster } from '@/components/ui/sonner'
|
||||
import { useAppStore } from './store'
|
||||
import { useIpcEvents } from './hooks/useIpcEvents'
|
||||
import Sidebar from './components/Sidebar'
|
||||
@@ -275,12 +275,7 @@ function App(): React.JSX.Element {
|
||||
</div>
|
||||
{showSidebar && rightSidebarOpen ? <RightSidebar /> : null}
|
||||
</div>
|
||||
<Toaster
|
||||
theme="system"
|
||||
position="bottom-right"
|
||||
closeButton
|
||||
toastOptions={{ className: 'font-sans text-sm' }}
|
||||
/>
|
||||
<Toaster closeButton toastOptions={{ className: 'font-sans text-sm' }} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
CircleCheckIcon,
|
||||
InfoIcon,
|
||||
Loader2Icon,
|
||||
OctagonXIcon,
|
||||
TriangleAlertIcon
|
||||
} from 'lucide-react'
|
||||
import { Toaster as Sonner, type ToasterProps } from 'sonner'
|
||||
import { useAppStore } from '@/store'
|
||||
|
||||
const Toaster = ({ ...props }: ToasterProps) => {
|
||||
const theme = useAppStore((s) => s.settings?.theme) || 'system'
|
||||
|
||||
return (
|
||||
<Sonner
|
||||
theme={theme as ToasterProps['theme']}
|
||||
position="bottom-right"
|
||||
className="toaster group"
|
||||
icons={{
|
||||
success: <CircleCheckIcon className="size-4" />,
|
||||
info: <InfoIcon className="size-4" />,
|
||||
warning: <TriangleAlertIcon className="size-4" />,
|
||||
error: <OctagonXIcon className="size-4" />,
|
||||
loading: <Loader2Icon className="size-4 animate-spin" />
|
||||
}}
|
||||
style={
|
||||
{
|
||||
'--normal-bg': 'var(--popover)',
|
||||
'--normal-text': 'var(--popover-foreground)',
|
||||
'--normal-border': 'var(--border)',
|
||||
'--border-radius': 'var(--radius)'
|
||||
} as React.CSSProperties
|
||||
}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Toaster }
|
||||
@@ -1,8 +1,9 @@
|
||||
import type { StateCreator } from 'zustand'
|
||||
import { toast } from 'sonner'
|
||||
import type { AppState } from '../types'
|
||||
import type { Repo } from '../../../../shared/types'
|
||||
|
||||
export interface RepoSlice {
|
||||
export type RepoSlice = {
|
||||
repos: Repo[]
|
||||
activeRepoId: string | null
|
||||
fetchRepos: () => Promise<void>
|
||||
@@ -31,9 +32,22 @@ export const createRepoSlice: StateCreator<AppState, [], [], RepoSlice> = (set,
|
||||
addRepo: async () => {
|
||||
try {
|
||||
const path = await window.api.repos.pickFolder()
|
||||
if (!path) return null
|
||||
if (!path) {
|
||||
return null
|
||||
}
|
||||
const repo = await window.api.repos.add({ path })
|
||||
set((s) => ({ repos: [...s.repos, repo] }))
|
||||
const alreadyAdded = get().repos.some((r) => r.id === repo.id)
|
||||
set((s) => {
|
||||
if (s.repos.some((r) => r.id === repo.id)) {
|
||||
return s
|
||||
}
|
||||
return { repos: [...s.repos, repo] }
|
||||
})
|
||||
if (alreadyAdded) {
|
||||
toast.info('Repo already added', { description: repo.displayName })
|
||||
} else {
|
||||
toast.success('Repo added', { description: repo.displayName })
|
||||
}
|
||||
return repo
|
||||
} catch (err) {
|
||||
console.error('Failed to add repo:', err)
|
||||
|
||||
Reference in New Issue
Block a user