6ede33ccdb
Build and Push Docker Images / create_manifest (web, surfsense-web, , cpu) (push) Has been cancelled
Build and Push Docker Images / finalize_release (push) Has been cancelled
Obsidian Plugin Lint / lint (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / compute_version (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / verify_digests (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, , cpu) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda, cuda) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda126, cuda126) (push) Has been cancelled
107 lines
2.6 KiB
TypeScript
107 lines
2.6 KiB
TypeScript
import { atom } from "jotai";
|
|
import type { ChatVisibility } from "@/lib/chat/thread-persistence";
|
|
import { reportPanelAtom } from "./report-panel.atom";
|
|
|
|
interface CurrentThreadState {
|
|
id: number | null;
|
|
workspaceId: number | null;
|
|
visibility: ChatVisibility | null;
|
|
hasComments: boolean;
|
|
}
|
|
|
|
interface CurrentThreadMetadataPatch {
|
|
id: number | null;
|
|
workspaceId?: number | null;
|
|
visibility?: ChatVisibility | null;
|
|
hasComments?: boolean;
|
|
}
|
|
|
|
interface CurrentThreadMetadataUpdate {
|
|
id: number;
|
|
visibility?: ChatVisibility | null;
|
|
hasComments?: boolean;
|
|
}
|
|
|
|
const initialState: CurrentThreadState = {
|
|
id: null,
|
|
workspaceId: null,
|
|
visibility: null,
|
|
hasComments: false,
|
|
};
|
|
|
|
export const currentThreadAtom = atom<CurrentThreadState>(initialState);
|
|
|
|
export const commentsEnabledAtom = atom(
|
|
(get) => get(currentThreadAtom).visibility === "SEARCH_SPACE"
|
|
);
|
|
|
|
export const setCurrentThreadMetadataAtom = atom(
|
|
null,
|
|
(get, set, metadata: CurrentThreadMetadataPatch) => {
|
|
const current = get(currentThreadAtom);
|
|
const isSameThread = current.id === metadata.id;
|
|
|
|
set(currentThreadAtom, {
|
|
...current,
|
|
id: metadata.id,
|
|
workspaceId:
|
|
"workspaceId" in metadata
|
|
? (metadata.workspaceId ?? null)
|
|
: isSameThread
|
|
? current.workspaceId
|
|
: null,
|
|
visibility:
|
|
"visibility" in metadata
|
|
? (metadata.visibility ?? null)
|
|
: isSameThread
|
|
? current.visibility
|
|
: null,
|
|
hasComments:
|
|
"hasComments" in metadata
|
|
? (metadata.hasComments ?? false)
|
|
: isSameThread
|
|
? current.hasComments
|
|
: false,
|
|
});
|
|
}
|
|
);
|
|
|
|
export const patchCurrentThreadMetadataAtom = atom(
|
|
null,
|
|
(get, set, patch: CurrentThreadMetadataUpdate) => {
|
|
const current = get(currentThreadAtom);
|
|
if (current.id !== patch.id) {
|
|
return;
|
|
}
|
|
|
|
set(currentThreadAtom, {
|
|
...current,
|
|
visibility: "visibility" in patch ? (patch.visibility ?? null) : current.visibility,
|
|
hasComments: "hasComments" in patch ? (patch.hasComments ?? false) : current.hasComments,
|
|
});
|
|
}
|
|
);
|
|
|
|
export const resetCurrentThreadAtom = atom(null, (_, set) => {
|
|
set(currentThreadAtom, initialState);
|
|
set(reportPanelAtom, {
|
|
isOpen: false,
|
|
reportId: null,
|
|
title: null,
|
|
wordCount: null,
|
|
shareToken: null,
|
|
contentType: "markdown",
|
|
});
|
|
});
|
|
|
|
/** Target comment ID to scroll to (from URL navigation or inbox click) */
|
|
export const targetCommentIdAtom = atom<number | null>(null);
|
|
|
|
export const setTargetCommentIdAtom = atom(null, (_, set, commentId: number | null) => {
|
|
set(targetCommentIdAtom, commentId);
|
|
});
|
|
|
|
export const clearTargetCommentIdAtom = atom(null, (_, set) => {
|
|
set(targetCommentIdAtom, null);
|
|
});
|