fix(desktop): read bot-mode state through the plugin SDK
Plugins cannot import the contrib store. host.pluginDecisions is the read-only door, and absence still means the plugin default.
This commit is contained in:
@@ -30,6 +30,16 @@ const { clearBotAttentionMock, hostMock, noteBotAttentionMock, UnboundedCache }
|
||||
clearBotAttentionMock: vi.fn(),
|
||||
hostMock: {
|
||||
onEvent: vi.fn(),
|
||||
pluginDecisions: {
|
||||
get: () => {
|
||||
try {
|
||||
const raw = window.localStorage.getItem('hermes.desktop.pluginDecisions.v2')
|
||||
return raw ? (JSON.parse(raw) as Record<string, boolean>) : {}
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
},
|
||||
profileRoutes: vi.fn(),
|
||||
requestProfile: vi.fn(),
|
||||
retainProfileSocket: vi.fn()
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
import { host, LruCache } from '@hermes/plugin-sdk'
|
||||
|
||||
import { pluginActive } from '@/contrib/plugins-store'
|
||||
|
||||
import { botHandle, clearBotAttention, noteBotAttention } from './data'
|
||||
import { ID } from './shared'
|
||||
import type { ProfileRoute, RosterRow } from './types'
|
||||
@@ -120,7 +118,9 @@ const RELAY_OUTBOX_ANY = '*'
|
||||
const routesWithOutboxWork = new Set<string>()
|
||||
|
||||
function relayBotModeOn(): boolean {
|
||||
return pluginActive(ID)
|
||||
const decisions = host.pluginDecisions.get()
|
||||
|
||||
return ID in decisions ? Boolean(decisions[ID]) : true
|
||||
}
|
||||
|
||||
function noteRelayOutboxWork(event?: { connectionId?: string }) {
|
||||
|
||||
Reference in New Issue
Block a user