mirror of
https://github.com/voideditor/void
synced 2026-05-23 09:28:23 +00:00
re-remove streaming state for nwo
This commit is contained in:
parent
64e43fa53e
commit
44438fe1fe
3 changed files with 3 additions and 45 deletions
|
|
@ -38,7 +38,6 @@ import { filenameToVscodeLanguage } from './helpers/detectLanguage.js';
|
|||
import { INotificationService, Severity } from '../../../../platform/notification/common/notification.js';
|
||||
import { isMacintosh } from '../../../../base/common/platform.js';
|
||||
import { EditorOption } from '../../../../editor/common/config/editorOptions.js';
|
||||
import { Emitter, Event } from '../../../../base/common/event.js';
|
||||
// import { Action2, registerAction2 } from '../../../../platform/actions/common/actions.js';
|
||||
// import { ServicesAccessor } from '../../../../editor/browser/editorExtensions.js';
|
||||
// import { localize2 } from '../../../../nls.js';
|
||||
|
|
@ -175,7 +174,6 @@ type HistorySnapshot = {
|
|||
}
|
||||
|
||||
|
||||
export type StreamState = Set<number> // set of streaming diffareaids, only applies to diffzones
|
||||
|
||||
export interface IInlineDiffsService {
|
||||
readonly _serviceBrand: undefined;
|
||||
|
|
@ -183,9 +181,6 @@ export interface IInlineDiffsService {
|
|||
interruptStreaming(diffareaid: number): void;
|
||||
addCtrlKZone(opts: AddCtrlKOpts): number | undefined;
|
||||
removeCtrlKZone(opts: { diffareaid: number }): void;
|
||||
|
||||
onDidChangeStreamState: Event<number>
|
||||
streamingDiffZonesState: StreamState
|
||||
// testDiffs(): void;
|
||||
}
|
||||
|
||||
|
|
@ -202,13 +197,6 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
|
|||
diffOfId: Record<string, Diff> = {}; // redundant with diffArea._diffs
|
||||
|
||||
|
||||
|
||||
// streaming state for React, reflection of the streaming value in the diffarea, only applies to diffZone
|
||||
readonly streamingDiffZonesState: StreamState = new Set()
|
||||
private readonly _onDidChangeStreamState = new Emitter<number>();
|
||||
readonly onDidChangeStreamState: Event<number> = this._onDidChangeStreamState.event;
|
||||
|
||||
|
||||
constructor(
|
||||
// @IHistoryService private readonly _historyService: IHistoryService, // history service is the history of pressing alt left/right
|
||||
@ICodeEditorService private readonly _editorService: ICodeEditorService,
|
||||
|
|
@ -1203,8 +1191,6 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
|
|||
_removeStylesFns: new Set(),
|
||||
}
|
||||
const diffZone = this._addDiffArea(adding)
|
||||
this.streamingDiffZonesState.add(diffZone.diffareaid)
|
||||
this._onDidChangeStreamState.fire(diffZone.diffareaid)
|
||||
|
||||
if (featureName === 'Ctrl+K') {
|
||||
const { diffareaid } = opts
|
||||
|
|
@ -1243,8 +1229,6 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
|
|||
|
||||
const onDone = (hadError: boolean) => {
|
||||
diffZone._streamState = { isStreaming: false, }
|
||||
this.streamingDiffZonesState.delete(diffZone.diffareaid)
|
||||
this._onDidChangeStreamState.fire(diffZone.diffareaid)
|
||||
|
||||
if (featureName === 'Ctrl+K') {
|
||||
const ctrlKZone = this.diffAreaOfId[opts.diffareaid] as CtrlKZone
|
||||
|
|
@ -1327,8 +1311,6 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
|
|||
this._llmMessageService.abort(streamRequestId)
|
||||
|
||||
diffZone._streamState = { isStreaming: false, }
|
||||
this.streamingDiffZonesState.delete(diffZone.diffareaid)
|
||||
this._onDidChangeStreamState.fire(diffZone.diffareaid)
|
||||
}
|
||||
|
||||
_undoHistory(uri: URI) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------*/
|
||||
|
||||
import React, { FormEvent, useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useSettingsState, useSidebarState, useThreadsState, useQuickEditState, useAccessor, useIsStreaming } from '../util/services.js';
|
||||
import { useSettingsState, useSidebarState, useThreadsState, useQuickEditState, useAccessor } from '../util/services.js';
|
||||
import { TextAreaFns, VoidInputBox2 } from '../util/inputs.js';
|
||||
import { QuickEditPropsType } from '../../../quickEditActions.js';
|
||||
import { ButtonStop, ButtonSubmit, IconX } from '../sidebar-tsx/SidebarChat.js';
|
||||
|
|
@ -46,8 +46,7 @@ export const QuickEditChat = ({
|
|||
const isDisabled = instructionsAreEmpty
|
||||
|
||||
const [currStreamingDiffZoneRef, setCurrentlyStreamingDiffZone] = useRefState<number | null>(initStreamingDiffZoneId)
|
||||
|
||||
const isStreaming = useIsStreaming({ diffareaid: currStreamingDiffZoneRef.current })
|
||||
const isStreaming = !!currStreamingDiffZoneRef
|
||||
|
||||
const onSubmit = useCallback((e: FormEvent) => {
|
||||
if (isDisabled) return
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import { IThemeService } from '../../../../../../../platform/theme/common/themeS
|
|||
import { ILLMMessageService } from '../../../../../../../platform/void/common/llmMessageService.js';
|
||||
import { IRefreshModelService } from '../../../../../../../platform/void/common/refreshModelService.js';
|
||||
import { IVoidSettingsService } from '../../../../../../../platform/void/common/voidSettingsService.js';
|
||||
import { IInlineDiffsService, StreamState } from '../../../inlineDiffsService.js';
|
||||
import { IInlineDiffsService } from '../../../inlineDiffsService.js';
|
||||
import { IQuickEditStateService } from '../../../quickEditStateService.js';
|
||||
import { ISidebarStateService } from '../../../sidebarStateService.js';
|
||||
import { IThreadHistoryService } from '../../../threadHistoryService.js';
|
||||
|
|
@ -70,9 +70,6 @@ const refreshModelProviderListeners: Set<(p: RefreshableProviderName, s: Refresh
|
|||
let colorThemeState: ColorScheme
|
||||
const colorThemeStateListeners: Set<(s: ColorScheme) => void> = new Set()
|
||||
|
||||
let streamState: StreamState
|
||||
const diffareaStreamStateListeners: Set<(diffareaid: number) => void> = new Set()
|
||||
|
||||
// must call this before you can use any of the hooks below
|
||||
// this should only be called ONCE! this is the only place you don't need to dispose onDidChange. If you use state.onDidChange anywhere else, make sure to dispose it!
|
||||
let wasCalled = false
|
||||
|
|
@ -150,12 +147,6 @@ export const _registerServices = (accessor: ServicesAccessor) => {
|
|||
})
|
||||
)
|
||||
|
||||
disposables.push(
|
||||
inlineDiffsService.onDidChangeStreamState((diffareaid) => {
|
||||
streamState = inlineDiffsService.streamingDiffZonesState
|
||||
diffareaStreamStateListeners.forEach(l => l(diffareaid))
|
||||
})
|
||||
)
|
||||
|
||||
return disposables
|
||||
}
|
||||
|
|
@ -294,17 +285,3 @@ export const useIsDark = () => {
|
|||
return isDark
|
||||
|
||||
}
|
||||
|
||||
|
||||
export const useIsStreaming = ({ diffareaid }: { diffareaid: number | null }) => {
|
||||
console.log('difareaid', diffareaid)
|
||||
const [s, ss] = useState(diffareaid === null ? false : streamState.has(diffareaid))
|
||||
useEffect(() => { ss(diffareaid === null ? false : streamState.has(diffareaid)) }, [diffareaid])
|
||||
useEffect(() => {
|
||||
const listener = (diffareaid_: number) => { if (diffareaid === diffareaid_) ss(streamState.has(diffareaid)) }
|
||||
diffareaStreamStateListeners.add(listener)
|
||||
return () => { diffareaStreamStateListeners.delete(listener) }
|
||||
}, [ss, diffareaid])
|
||||
|
||||
return s
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue