feat(controller): route status messages through notifications

- Send controller connected and disabled messages over a new IPC channel so they follow ankiConnect.behavior.notificationType
- Remove the separate controller status toast from the overlay
- Only announce connected controllers when controller.enabled is on
- Announce a controller again after it reconnects, and update usage docs
This commit is contained in:
sudacode committed 2026-11-03 21:55:55 -08:00
1 parent 1c50d249e0
commit 8976d78390
15 files changed
+84 -167

No files matched your search

+23
View File
@@ -146,6 +146,7 @@ function createRegisterIpcDeps(overrides: Partial<IpcServiceDeps> = {}): IpcServ
saveControllerConfig: async () => {},
reportActiveController: () => {},
getActiveControllerId: () => null,
notifyControllerStatus: () => {},
getSecondarySubMode: () => 'hover',
getCurrentSecondarySub: () => '',
focusMainWindow: () => {},
@@ -257,6 +258,26 @@ test('registerIpcHandlers stores the controller the overlay reports for Alt+C to
assert.equal(await handlers.handle.get(IPC_CHANNELS.request.getActiveControllerId)?.({}), null);
});
test('registerIpcHandlers forwards controller status messages and drops invalid ones', () => {
const { registrar, handlers } = createFakeIpcRegistrar();
const messages: string[] = [];
registerIpcHandlers(
createRegisterIpcDeps({
notifyControllerStatus: (message) => {
messages.push(message);
},
}),
registrar,
);
const notify = handlers.on.get(IPC_CHANNELS.command.notifyControllerStatus);
notify?.({}, 'Controller connected: pad-1');
notify?.({}, 42);
notify?.({}, ' ');
assert.deepEqual(messages, ['Controller connected: pad-1']);
});
test('registerIpcHandlers runs AniList update after manual mark watched succeeds', async () => {
const { registrar, handlers } = createFakeIpcRegistrar();
const calls: string[] = [];
@@ -361,6 +382,7 @@ test('registerIpcHandlers rejects malformed runtime-option payloads', async () =
saveControllerConfig: () => {},
reportActiveController: () => {},
getActiveControllerId: () => null,
notifyControllerStatus: () => {},
getSecondarySubMode: () => 'hover',
getCurrentSecondarySub: () => '',
focusMainWindow: () => {},
@@ -644,6 +666,7 @@ test('registerIpcHandlers ignores malformed fire-and-forget payloads', () => {
saveControllerConfig: () => {},
reportActiveController: () => {},
getActiveControllerId: () => null,
notifyControllerStatus: () => {},
getSecondarySubMode: () => 'hover',
getCurrentSecondarySub: () => '',
focusMainWindow: () => {},
+8
View File
@@ -92,6 +92,7 @@ export interface IpcServiceDeps {
/** The overlay reports the controller it is reading (null when none). */
reportActiveController: (gamepadId: string | null) => void;
getActiveControllerId: () => string | null;
notifyControllerStatus: (message: string) => void;
getSecondarySubMode: () => unknown;
getCurrentSecondarySub: () => string;
focusMainWindow: () => void;
@@ -362,6 +363,7 @@ export interface IpcDepsRuntimeOptions {
/** The overlay reports the controller it is reading (null when none). */
reportActiveController: (gamepadId: string | null) => void;
getActiveControllerId: () => string | null;
notifyControllerStatus: (message: string) => void;
getSecondarySubMode: () => unknown;
getMpvClient: () => MpvClientLike | null;
focusMainWindow: () => void;
@@ -440,6 +442,7 @@ export function createIpcDepsRuntime(options: IpcDepsRuntimeOptions): IpcService
saveControllerConfig: options.saveControllerConfig,
reportActiveController: options.reportActiveController,
getActiveControllerId: options.getActiveControllerId,
notifyControllerStatus: options.notifyControllerStatus,
getSecondarySubMode: options.getSecondarySubMode,
getCurrentSecondarySub: () => options.getMpvClient()?.currentSecondarySubText || '',
focusMainWindow: () => {
@@ -777,6 +780,11 @@ export function registerIpcHandlers(deps: IpcServiceDeps, ipc: IpcMainRegistrar
return deps.getActiveControllerId();
});
ipc.on(IPC_CHANNELS.command.notifyControllerStatus, (_event: unknown, message: unknown) => {
if (typeof message !== 'string' || message.trim().length === 0) return;
deps.notifyControllerStatus(message);
});
ipc.handle(IPC_CHANNELS.request.getSecondarySubMode, () => {
return deps.getSecondarySubMode();
});