fix(logging): apply cli log level on second-instance commands

This commit is contained in:
2026-02-28 20:07:45 -08:00
parent 55c577e911
commit 4309e0dec3
8 changed files with 54 additions and 3 deletions

View File

@@ -220,6 +220,18 @@ test('handleCliCommand processes --start for second-instance when overlay runtim
);
});
test('handleCliCommand applies cli log level for second-instance commands', () => {
const { deps, calls } = createDeps({
setLogLevel: (level) => {
calls.push(`setLogLevel:${level}`);
},
});
handleCliCommand(makeArgs({ start: true, logLevel: 'debug' }), 'second-instance', deps);
assert.ok(calls.includes('setLogLevel:debug'));
});
test('handleCliCommand runs texthooker flow with browser open', () => {
const { deps, calls } = createDeps();
const args = makeArgs({ texthooker: true });

View File

@@ -1,6 +1,7 @@
import { CliArgs, CliCommandSource, commandNeedsOverlayRuntime } from '../../cli/args';
export interface CliCommandServiceDeps {
setLogLevel?: (level: NonNullable<CliArgs['logLevel']>) => void;
getMpvSocketPath: () => string;
setMpvSocketPath: (socketPath: string) => void;
setMpvClientSocketPath: (socketPath: string) => void;
@@ -127,6 +128,7 @@ interface AppCliRuntime {
}
export interface CliCommandDepsRuntimeOptions {
setLogLevel?: (level: NonNullable<CliArgs['logLevel']>) => void;
mpv: MpvCliRuntime;
texthooker: TexthookerCliRuntime;
overlay: OverlayCliRuntime;
@@ -149,6 +151,7 @@ export function createCliCommandDepsRuntime(
options: CliCommandDepsRuntimeOptions,
): CliCommandServiceDeps {
return {
setLogLevel: options.setLogLevel,
getMpvSocketPath: options.mpv.getSocketPath,
setMpvSocketPath: options.mpv.setSocketPath,
setMpvClientSocketPath: (socketPath) => {
@@ -232,6 +235,10 @@ export function handleCliCommand(
source: CliCommandSource = 'initial',
deps: CliCommandServiceDeps,
): void {
if (args.logLevel) {
deps.setLogLevel?.(args.logLevel);
}
const hasNonStartAction =
args.stop ||
args.toggle ||