mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Refactor SSE event handling and consolidate notification contexts
This commit is contained in:
1 parent
9851ec06e0
commit
f7fd3176d4
30 files changed
+2226
-988
No files matched your search
@@ -8,15 +8,15 @@ import { Header } from "@/components/ui/header";
|
||||
import { SwitchConfigDialog } from "@/components/repo/SwitchConfigDialog";
|
||||
import { RepoMcpDialog } from "@/components/repo/RepoMcpDialog";
|
||||
import { useCreateSession } from "@/hooks/useOpenCode";
|
||||
import { useSSE } from "@/hooks/useSSE";
|
||||
import { OPENCODE_API_ENDPOINT, API_BASE_URL } from "@/config";
|
||||
import { useSwipeBack } from "@/hooks/useMobile";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { BranchSwitcher } from "@/components/repo/BranchSwitcher";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Plug, FolderOpen, Plus, GitBranch } from "lucide-react";
|
||||
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { Plug, FolderOpen, Plus, GitBranch, Loader2 } from "lucide-react";
|
||||
import { PendingActionsGroup } from "@/components/notifications/PendingActionsGroup";
|
||||
|
||||
export function RepoDetail() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
@@ -59,6 +59,8 @@ export function RepoDetail() {
|
||||
|
||||
const repoDirectory = repo?.fullPath;
|
||||
|
||||
useSSE(opcodeUrl, repoDirectory);
|
||||
|
||||
const createSessionMutation = useCreateSession(opcodeUrl, repoDirectory);
|
||||
|
||||
const handleCreateSession = async (options?: {
|
||||
@@ -140,6 +142,9 @@ export function RepoDetail() {
|
||||
) : null}
|
||||
</div>
|
||||
<Header.Actions>
|
||||
<div className="hidden sm:flex items-center gap-1">
|
||||
<PendingActionsGroup />
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => setMcpDialogOpen(true)}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { FileBrowserSheet } from "@/components/file-browser/FileBrowserSheet";
|
||||
import { Header } from "@/components/ui/header";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Plus, FolderOpen } from "lucide-react";
|
||||
import { PendingActionsGroup } from "@/components/notifications/PendingActionsGroup";
|
||||
|
||||
export function Repos() {
|
||||
const [addRepoOpen, setAddRepoOpen] = useState(false);
|
||||
@@ -21,6 +22,7 @@ export function Repos() {
|
||||
<Header.Title logo>OpenCode</Header.Title>
|
||||
</div>
|
||||
<Header.Actions>
|
||||
<PendingActionsGroup />
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
|
||||
@@ -33,6 +33,9 @@ import { showToast } from "@/lib/toast";
|
||||
import { RepoMcpDialog } from "@/components/repo/RepoMcpDialog";
|
||||
import { createOpenCodeClient } from "@/api/opencode";
|
||||
import { useSessionStatus } from "@/stores/sessionStatusStore";
|
||||
import { useQuestions } from "@/contexts/EventContext";
|
||||
import { QuestionPrompt } from "@/components/session/QuestionPrompt";
|
||||
import { PendingActionsGroup } from "@/components/notifications/PendingActionsGroup";
|
||||
|
||||
export function SessionDetail() {
|
||||
const { id, sessionId } = useParams<{ id: string; sessionId: string }>();
|
||||
@@ -112,6 +115,7 @@ export function SessionDetail() {
|
||||
const isEditingMessage = useUIState((state) => state.isEditingMessage);
|
||||
const { isPlaying, stop } = useTTS();
|
||||
const setSessionStatus = useSessionStatus((state) => state.setStatus);
|
||||
const { current: currentQuestion, reply: replyToQuestion, reject: rejectQuestion } = useQuestions();
|
||||
|
||||
const handleNewSession = useCallback(async () => {
|
||||
try {
|
||||
@@ -332,6 +336,9 @@ export function SessionDetail() {
|
||||
/>
|
||||
</div>
|
||||
<Header.Actions className="gap-2 sm:gap-4">
|
||||
<div className="hidden sm:flex items-center gap-1">
|
||||
<PendingActionsGroup />
|
||||
</div>
|
||||
<ContextUsageIndicator
|
||||
opcodeUrl={opcodeUrl}
|
||||
sessionID={sessionId}
|
||||
@@ -458,6 +465,14 @@ export function SessionDetail() {
|
||||
<span className="text-sm font-medium hidden sm:inline">Stop Audio</span>
|
||||
</button>
|
||||
)}
|
||||
{currentQuestion && currentQuestion.sessionID === sessionId && (
|
||||
<QuestionPrompt
|
||||
key={currentQuestion.id}
|
||||
question={currentQuestion}
|
||||
onReply={replyToQuestion}
|
||||
onReject={rejectQuestion}
|
||||
/>
|
||||
)}
|
||||
<PromptInput
|
||||
ref={promptInputRef}
|
||||
opcodeUrl={opcodeUrl}
|
||||
|
||||
Reference in new issue
Block a user