fix: address reviewer feedback — stdin error logging, JSON schema, i18n

- Log non-EPIPE stdin errors at debug level instead of silently
  swallowing them
- Add proper JSON schema properties for statusLine (type, command,
  padding) with enum, required, and additionalProperties constraints
- Add missing i18n entry for /statusline command description
This commit is contained in:
wenshao 2026-04-08 20:08:36 +08:00
parent fc7ac2abb7
commit 841eb3c70c
8 changed files with 39 additions and 2 deletions

View file

@ -6,6 +6,7 @@
import { useState, useEffect, useRef, useCallback } from 'react';
import { exec, type ChildProcess } from 'child_process';
import { createDebugLogger } from '@qwen-code/qwen-code-core';
import { useSettings } from '../contexts/SettingsContext.js';
import { useUIState } from '../contexts/UIStateContext.js';
import { useConfig } from '../contexts/ConfigContext.js';
@ -71,6 +72,8 @@ interface StatusLineConfig {
padding?: number;
}
const debugLog = createDebugLogger('STATUS_LINE');
function getStatusLineConfig(
settings: ReturnType<typeof useSettings>,
): StatusLineConfig | undefined {
@ -297,7 +300,11 @@ export function useStatusLine(): {
// Pass structured JSON context via stdin.
// Guard against EPIPE if the child exits before we finish writing.
if (child.stdin) {
child.stdin.on('error', () => {});
child.stdin.on('error', (err) => {
if ((err as NodeJS.ErrnoException).code !== 'EPIPE') {
debugLog.error('statusline stdin error:', err.message);
}
});
child.stdin.write(JSON.stringify(input));
child.stdin.end();
}