这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions frontend/src/components/WorkspaceChat/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ export default function WorkspaceChat({ loading, workspace }) {
const [history, setHistory] = useState([]);
const [loadingHistory, setLoadingHistory] = useState(true);

// --- Agent Mode Toggle State ---
const [agentMode, setAgentMode] = useState(
JSON.parse(localStorage.getItem("agentMode") || "false")
);

useEffect(() => {
localStorage.setItem("agentMode", JSON.stringify(agentMode));
}, [agentMode]);
// -------------------------------

useEffect(() => {
async function getHistory() {
if (loading) return;
Expand All @@ -34,9 +44,10 @@ export default function WorkspaceChat({ loading, workspace }) {
setLoadingHistory(false);
}
getHistory();
}, [workspace, loading]);
}, [workspace, loading, threadSlug]);

if (loadingHistory) return <LoadingChat />;

if (!loading && !loadingHistory && !workspace) {
return (
<>
Expand Down Expand Up @@ -77,10 +88,30 @@ export default function WorkspaceChat({ loading, workspace }) {
}

setEventDelegatorForCodeSnippets();

return (
<TTSProvider>
<DnDFileUploaderProvider workspace={workspace} threadSlug={threadSlug}>
<ChatContainer workspace={workspace} knownHistory={history} />
{/* Agent Mode Toggle UI */}
<div className="flex items-center justify-end mb-2 px-4">
<label className="flex items-center gap-2 text-sm text-gray-300 cursor-pointer">
<input
type="checkbox"
checked={agentMode}
onChange={() => setAgentMode(!agentMode)}
className="accent-blue-500"
/>
Agent Mode
</label>
</div>

{/* Pass agentMode and setter to ChatContainer */}
<ChatContainer
workspace={workspace}
knownHistory={history}
agentMode={agentMode}
setAgentMode={setAgentMode}
/>
</DnDFileUploaderProvider>
</TTSProvider>
);
Expand Down