|
|
@@ -18,9 +18,6 @@ import {
|
|
|
SseDetectedDiffSchema,
|
|
|
SseFinalizedSchema,
|
|
|
isReplaceDiff,
|
|
|
- // isInsertDiff,
|
|
|
- // isDeleteDiff,
|
|
|
- // isRetainDiff,
|
|
|
type SseMessage,
|
|
|
type SseDetectedDiff,
|
|
|
type SseFinalized,
|
|
|
@@ -34,7 +31,6 @@ import type { MessageLog } from '../../interfaces/message';
|
|
|
import type { IThreadRelationHasId } from '../../interfaces/thread-relation';
|
|
|
import { ThreadType } from '../../interfaces/thread-relation';
|
|
|
import { AiAssistantDropdown } from '../components/AiAssistant/AiAssistantSidebar/AiAssistantDropdown';
|
|
|
-// import { type FormData } from '../components/AiAssistant/AiAssistantSidebar/AiAssistantSidebar';
|
|
|
import { MessageCard, type MessageCardRole } from '../components/AiAssistant/AiAssistantSidebar/MessageCard';
|
|
|
import { QuickMenuList } from '../components/AiAssistant/AiAssistantSidebar/QuickMenuList';
|
|
|
import { useAiAssistantSidebar } from '../stores/ai-assistant';
|
|
|
@@ -141,7 +137,6 @@ const getLineInfo = (yText: YText, lineNumber: number): { text: string, startInd
|
|
|
|
|
|
export const useEditorAssistant: UseEditorAssistant = () => {
|
|
|
// Refs
|
|
|
- // const positionRef = useRef<number>(0);
|
|
|
const lineRef = useRef<number>(0);
|
|
|
|
|
|
// States
|
|
|
@@ -237,26 +232,6 @@ export const useEditorAssistant: UseEditorAssistant = () => {
|
|
|
useEffect(() => {
|
|
|
const pendingDetectedDiff: DetectedDiff | undefined = detectedDiff?.filter(diff => diff.applied === false);
|
|
|
if (yDocs?.secondaryDoc != null && pendingDetectedDiff != null && pendingDetectedDiff.length > 0) {
|
|
|
-
|
|
|
- // For debug
|
|
|
- // const testDetectedDiff = [
|
|
|
- // {
|
|
|
- // data: { diff: { retain: 9 } },
|
|
|
- // applied: false,
|
|
|
- // id: crypto.randomUUID(),
|
|
|
- // },
|
|
|
- // {
|
|
|
- // data: { diff: { delete: 5 } },
|
|
|
- // applied: false,
|
|
|
- // id: crypto.randomUUID(),
|
|
|
- // },
|
|
|
- // {
|
|
|
- // data: { diff: { insert: 'growi' } },
|
|
|
- // applied: false,
|
|
|
- // id: crypto.randomUUID(),
|
|
|
- // },
|
|
|
- // ];
|
|
|
-
|
|
|
const yText = yDocs.secondaryDoc.getText('codemirror');
|
|
|
yDocs.secondaryDoc.transact(() => {
|
|
|
pendingDetectedDiff.forEach((detectedDiff) => {
|
|
|
@@ -275,15 +250,6 @@ export const useEditorAssistant: UseEditorAssistant = () => {
|
|
|
appendTextLastLine(yText, detectedDiff.data.diff.replace);
|
|
|
}
|
|
|
}
|
|
|
- // if (isInsertDiff(detectedDiff.data)) {
|
|
|
- // yText.insert(positionRef.current, detectedDiff.data.diff.insert);
|
|
|
- // }
|
|
|
- // if (isDeleteDiff(detectedDiff.data)) {
|
|
|
- // yText.delete(positionRef.current, detectedDiff.data.diff.delete);
|
|
|
- // }
|
|
|
- // if (isRetainDiff(detectedDiff.data)) {
|
|
|
- // positionRef.current += detectedDiff.data.diff.retain;
|
|
|
- // }
|
|
|
});
|
|
|
});
|
|
|
|
|
|
@@ -307,7 +273,6 @@ export const useEditorAssistant: UseEditorAssistant = () => {
|
|
|
setSelectedText(undefined);
|
|
|
setDetectedDiff(undefined);
|
|
|
lineRef.current = 0;
|
|
|
- // positionRef.current = 0;
|
|
|
}
|
|
|
}, [detectedDiff]);
|
|
|
|