mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Add memory plugin with semantic search and session planning (#145)
* Add memory plugin with semantic search and session planning * Clarify Memory Plugin is optional in docs
This commit is contained in:
1 parent
da283a82cf
commit
3461f86556
132 files changed
+11448
-2834
No files matched your search
@@ -4,28 +4,23 @@ import { useGit } from '@/hooks/useGit'
|
||||
import { GitFlatFileList } from './GitFlatFileList'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Textarea } from '@/components/ui/textarea'
|
||||
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'
|
||||
import { FileDiffView } from '@/components/file-browser/FileDiffView'
|
||||
import { DiscardDialog } from '@/components/ui/discard-dialog'
|
||||
import { Loader2, GitCommit, FileText, AlertCircle } from 'lucide-react'
|
||||
|
||||
interface ChangesTabProps {
|
||||
repoId: number
|
||||
onFileSelect: (path: string, staged: boolean) => void
|
||||
onClearFileSelection?: () => void
|
||||
selectedFile?: {path: string, staged: boolean}
|
||||
isMobile: boolean
|
||||
onError?: (error: unknown) => void
|
||||
}
|
||||
|
||||
export function ChangesTab({ repoId, onFileSelect, onClearFileSelection, selectedFile, isMobile, onError }: ChangesTabProps) {
|
||||
export function ChangesTab({ repoId, onFileSelect, selectedFile, isMobile, onError }: ChangesTabProps) {
|
||||
const { data: status, isLoading, error } = useGitStatus(repoId)
|
||||
const git = useGit(repoId, onError)
|
||||
const [commitMessage, setCommitMessage] = useState('')
|
||||
|
||||
const [discardDialogOpen, setDiscardDialogOpen] = useState(false)
|
||||
const [discardPaths, setDiscardPaths] = useState<string[]>([])
|
||||
const [discardStaged, setDiscardStaged] = useState(false)
|
||||
|
||||
const stagedFiles = status?.files.filter(f => f.staged) || []
|
||||
const unstagedFiles = status?.files.filter(f => !f.staged) || []
|
||||
const canCommit = commitMessage.trim() && stagedFiles.length > 0 && !git.commit.isPending
|
||||
@@ -38,23 +33,6 @@ export function ChangesTab({ repoId, onFileSelect, onClearFileSelection, selecte
|
||||
git.unstageFiles.mutate(paths)
|
||||
}
|
||||
|
||||
const handleDiscard = (paths: string[], staged: boolean) => {
|
||||
setDiscardPaths(paths)
|
||||
setDiscardStaged(staged)
|
||||
setDiscardDialogOpen(true)
|
||||
}
|
||||
|
||||
const confirmDiscard = () => {
|
||||
git.discardFiles.mutate({ paths: discardPaths, staged: discardStaged })
|
||||
setDiscardDialogOpen(false)
|
||||
setDiscardPaths([])
|
||||
}
|
||||
|
||||
const cancelDiscard = () => {
|
||||
setDiscardDialogOpen(false)
|
||||
setDiscardPaths([])
|
||||
}
|
||||
|
||||
const handleCommit = () => {
|
||||
git.commit.mutate({ message: commitMessage.trim() })
|
||||
setCommitMessage('')
|
||||
@@ -82,13 +60,83 @@ export function ChangesTab({ repoId, onFileSelect, onClearFileSelection, selecte
|
||||
|
||||
if (isMobile && selectedFile) {
|
||||
return (
|
||||
<div className="flex flex-col h-full min-h-0 overflow-hidden">
|
||||
<FileDiffView
|
||||
repoId={repoId}
|
||||
filePath={selectedFile.path}
|
||||
includeStaged={selectedFile.staged}
|
||||
onBack={onClearFileSelection}
|
||||
/>
|
||||
<div className="flex flex-col h-full">
|
||||
<Tabs defaultValue="files" className="flex flex-col h-full">
|
||||
<TabsList className="flex-shrink-0">
|
||||
<TabsTrigger value="files">Files ({stagedFiles.length + unstagedFiles.length})</TabsTrigger>
|
||||
<TabsTrigger value="diff">{selectedFile.path.split('/').pop() || selectedFile.path}</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="files" className="flex-1 overflow-hidden mt-0">
|
||||
<div className="flex flex-col h-full">
|
||||
<div className="flex-1 overflow-y-auto p-3 space-y-4">
|
||||
{status.hasChanges ? (
|
||||
<>
|
||||
{stagedFiles.length > 0 && (
|
||||
<GitFlatFileList
|
||||
files={stagedFiles}
|
||||
staged={true}
|
||||
onSelect={onFileSelect}
|
||||
onUnstage={handleUnstage}
|
||||
selectedFile={selectedFile?.path}
|
||||
/>
|
||||
)}
|
||||
|
||||
{unstagedFiles.length > 0 && (
|
||||
<GitFlatFileList
|
||||
files={unstagedFiles}
|
||||
staged={false}
|
||||
onSelect={onFileSelect}
|
||||
onStage={handleStage}
|
||||
selectedFile={selectedFile?.path}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<div className="text-center py-12 text-muted-foreground">
|
||||
<FileText className="w-8 h-8 mx-auto mb-2 opacity-50" />
|
||||
<p className="text-sm">No uncommitted changes</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{status.hasChanges && (
|
||||
<div className="p-3 border-t border-border space-y-2 flex-shrink-0">
|
||||
<Textarea
|
||||
placeholder="Commit message..."
|
||||
value={commitMessage}
|
||||
onChange={(e) => setCommitMessage(e.target.value)}
|
||||
className="min-h-[80px] md:text-sm resize-none"
|
||||
onKeyDown={(e) => {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter' && canCommit) {
|
||||
handleCommit()
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
onClick={handleCommit}
|
||||
disabled={!canCommit}
|
||||
className="w-full h-9"
|
||||
>
|
||||
{git.commit.isPending ? (
|
||||
<Loader2 className="w-4 h-4 animate-spin mr-2" />
|
||||
) : (
|
||||
<GitCommit className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
Commit {stagedFiles.length > 0 && `(${stagedFiles.length} staged)`}
|
||||
</Button>
|
||||
<p className="text-[10px] text-muted-foreground text-center">
|
||||
{navigator.platform.includes('Mac') ? '⌘' : 'Ctrl'}+Enter to commit
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="diff" className="flex-1 overflow-hidden mt-0">
|
||||
<FileDiffView repoId={repoId} filePath={selectedFile.path} includeStaged={selectedFile.staged} />
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
@@ -103,7 +151,6 @@ export function ChangesTab({ repoId, onFileSelect, onClearFileSelection, selecte
|
||||
staged={true}
|
||||
onSelect={onFileSelect}
|
||||
onUnstage={handleUnstage}
|
||||
onDiscard={handleDiscard}
|
||||
selectedFile={selectedFile?.path}
|
||||
/>
|
||||
)}
|
||||
@@ -114,7 +161,6 @@ export function ChangesTab({ repoId, onFileSelect, onClearFileSelection, selecte
|
||||
staged={false}
|
||||
onSelect={onFileSelect}
|
||||
onStage={handleStage}
|
||||
onDiscard={handleDiscard}
|
||||
selectedFile={selectedFile?.path}
|
||||
/>
|
||||
)}
|
||||
@@ -157,15 +203,6 @@ export function ChangesTab({ repoId, onFileSelect, onClearFileSelection, selecte
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<DiscardDialog
|
||||
open={discardDialogOpen}
|
||||
onOpenChange={setDiscardDialogOpen}
|
||||
onConfirm={confirmDiscard}
|
||||
onCancel={cancelDiscard}
|
||||
fileCount={discardPaths.length}
|
||||
isDiscarding={git.discardFiles.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user