forked from op7418/CodePilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseSplit.ts
More file actions
32 lines (27 loc) · 813 Bytes
/
useSplit.ts
File metadata and controls
32 lines (27 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use client";
import { createContext, useContext } from "react";
export interface SplitSession {
sessionId: string;
title: string;
workingDirectory: string;
projectName: string;
mode?: string;
}
export interface SplitContextValue {
splitSessions: SplitSession[];
activeColumnId: string;
isSplitActive: boolean;
addToSplit: (session: SplitSession) => void;
removeFromSplit: (sessionId: string) => void;
setActiveColumn: (sessionId: string) => void;
exitSplit: () => void;
isInSplit: (sessionId: string) => boolean;
}
export const SplitContext = createContext<SplitContextValue | null>(null);
export function useSplit(): SplitContextValue {
const ctx = useContext(SplitContext);
if (!ctx) {
throw new Error("useSplit must be used within a SplitProvider");
}
return ctx;
}