mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Simple debug mode for CLI side (#66)
* Adds debug mode config flag. * Wire through debug lines * Add debug mode logging example * Run format * Run format again
This commit is contained in:
@@ -31,11 +31,8 @@ interface AppProps {
|
||||
export const App = ({ config }: AppProps) => {
|
||||
const [history, setHistory] = useState<HistoryItem[]>([]);
|
||||
const [startupWarnings, setStartupWarnings] = useState<string[]>([]);
|
||||
const { streamingState, submitQuery, initError } = useGeminiStream(
|
||||
setHistory,
|
||||
config.getApiKey(),
|
||||
config.getModel(),
|
||||
);
|
||||
const { streamingState, submitQuery, initError, debugMessage } =
|
||||
useGeminiStream(setHistory, config.getApiKey(), config.getModel());
|
||||
const { elapsedTime, currentLoadingPhrase } =
|
||||
useLoadingIndicator(streamingState);
|
||||
|
||||
@@ -147,7 +144,11 @@ export const App = ({ config }: AppProps) => {
|
||||
</>
|
||||
)}
|
||||
|
||||
<Footer queryLength={query.length} />
|
||||
<Footer
|
||||
queryLength={query.length}
|
||||
debugMode={config.getDebugMode()}
|
||||
debugMessage={debugMessage}
|
||||
/>
|
||||
<ITermDetectionWarning />
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -10,13 +10,22 @@ import { Colors } from '../colors.js';
|
||||
|
||||
interface FooterProps {
|
||||
queryLength: number;
|
||||
debugMode: boolean;
|
||||
debugMessage: string;
|
||||
}
|
||||
|
||||
export const Footer: React.FC<FooterProps> = ({ queryLength }) => (
|
||||
export const Footer: React.FC<FooterProps> = ({
|
||||
queryLength,
|
||||
debugMode,
|
||||
debugMessage,
|
||||
}) => (
|
||||
<Box marginTop={1} justifyContent="space-between">
|
||||
<Box minWidth={15}>
|
||||
<Text color={Colors.SubtleComment}>
|
||||
{queryLength === 0 ? '? for shortcuts' : ''}
|
||||
{debugMode && (
|
||||
<Text color="red"> {debugMessage || 'Running in debug mode.'}</Text>
|
||||
)}
|
||||
</Text>
|
||||
</Box>
|
||||
<Text color={Colors.AccentBlue}>Gemini</Text>
|
||||
|
||||
@@ -49,6 +49,7 @@ export const useGeminiStream = (
|
||||
const [streamingState, setStreamingState] = useState<StreamingState>(
|
||||
StreamingState.Idle,
|
||||
);
|
||||
const [debugMessage, setDebugMessage] = useState<string>('');
|
||||
const [initError, setInitError] = useState<string | null>(null);
|
||||
const abortControllerRef = useRef<AbortController | null>(null);
|
||||
const chatSessionRef = useRef<Chat | null>(null);
|
||||
@@ -104,6 +105,10 @@ export const useGeminiStream = (
|
||||
if (streamingState === StreamingState.Responding) return;
|
||||
if (typeof query === 'string' && query.trim().length === 0) return;
|
||||
|
||||
if (typeof query === 'string') {
|
||||
setDebugMessage(`User query: ${query}`);
|
||||
}
|
||||
|
||||
const userMessageTimestamp = Date.now();
|
||||
const client = geminiClientRef.current;
|
||||
if (!client) {
|
||||
@@ -403,7 +408,7 @@ export const useGeminiStream = (
|
||||
],
|
||||
);
|
||||
|
||||
return { streamingState, submitQuery, initError };
|
||||
return { streamingState, submitQuery, initError, debugMessage };
|
||||
};
|
||||
|
||||
// Define ServerTool interface here if not importing from server (circular dep issue?)
|
||||
|
||||
Reference in New Issue
Block a user