diff --git a/src/vs/base/common/observableInternal/logging/debugger/debuggerApi.d.ts b/src/vs/base/common/observableInternal/logging/debugger/debuggerApi.d.ts index 138732f44b21..10557a758649 100644 --- a/src/vs/base/common/observableInternal/logging/debugger/debuggerApi.d.ts +++ b/src/vs/base/common/observableInternal/logging/debugger/debuggerApi.d.ts @@ -24,9 +24,15 @@ export type ObsDebuggerApi = { getDerivedInfo(instanceId: ObsInstanceId): IDerivedObservableDetailedInfo; getAutorunInfo(instanceId: ObsInstanceId): IAutorunDetailedInfo; getObservableValueInfo(instanceId: ObsInstanceId): IObservableValueInfo; + setValue(instanceId: ObsInstanceId, jsonValue: unknown): void; getValue(instanceId: ObsInstanceId): unknown; + // For autorun and deriveds + rerun(instanceId: ObsInstanceId): void; + + logValue(instanceId: ObsInstanceId): void; + getTransactionState(): ITransactionState | undefined; } }; diff --git a/src/vs/base/common/observableInternal/logging/debugger/devToolsLogger.ts b/src/vs/base/common/observableInternal/logging/debugger/devToolsLogger.ts index 2405a11138cc..513921408a58 100644 --- a/src/vs/base/common/observableInternal/logging/debugger/devToolsLogger.ts +++ b/src/vs/base/common/observableInternal/logging/debugger/devToolsLogger.ts @@ -135,7 +135,25 @@ export class DevToolsLogger implements IObservableLogger { } return undefined; - } + }, + logValue: (instanceId) => { + const obs = this._aliveInstances.get(instanceId); + if (obs && 'get' in obs) { + console.log('Logged Value:', obs.get()); + } else { + throw new BugIndicatingError('Observable is not supported'); + } + }, + rerun: (instanceId) => { + const obs = this._aliveInstances.get(instanceId); + if (obs instanceof Derived) { + obs.debugRecompute(); + } else if (obs instanceof AutorunObserver) { + obs.debugRerun(); + } else { + throw new BugIndicatingError('Observable is not supported'); + } + }, } }; }); diff --git a/src/vs/base/common/observableInternal/observables/derivedImpl.ts b/src/vs/base/common/observableInternal/observables/derivedImpl.ts index bbedd1518a66..011e9c76f189 100644 --- a/src/vs/base/common/observableInternal/observables/derivedImpl.ts +++ b/src/vs/base/common/observableInternal/observables/derivedImpl.ts @@ -400,6 +400,14 @@ export class Derived extends BaseObserv this._value = newValue as any; } + public debugRecompute(): void { + if (!this._isComputing) { + this._recompute(); + } else { + this._state = DerivedState.stale; + } + } + public setValue(newValue: T, tx: ITransaction, change: TChange): void { this._value = newValue; const observers = this._observers;