feat: reduce debug logging with conditional output based on streamDebugEnabled
This commit is contained in:
@@ -3,6 +3,7 @@ import { useSessionStore } from '@/stores/useSessionStore';
|
||||
import { useDirectoryStore } from '@/stores/useDirectoryStore';
|
||||
import { opencodeClient } from '@/lib/opencode/client';
|
||||
import { checkIsGitRepository } from '@/lib/gitApi';
|
||||
import { streamDebugEnabled } from '@/stores/utils/streamDebug';
|
||||
|
||||
export interface DebugMessageInfo {
|
||||
messageId: string;
|
||||
@@ -631,18 +632,20 @@ export const debugUtils = {
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
(window as any).__opencodeDebug = debugUtils;
|
||||
console.log('[DEBUG] OpenCode Debug Utils loaded! Use window.__opencodeDebug in console');
|
||||
console.log('Available commands:');
|
||||
console.log(' __opencodeDebug.getLastAssistantMessage() - Get last assistant message details');
|
||||
console.log(' __opencodeDebug.getAllMessages(truncate?) - List all messages (truncate=true for short preview)');
|
||||
console.log(' __opencodeDebug.truncateMessages(messages) - Truncate long fields in messages array');
|
||||
console.log(' __opencodeDebug.getAppStatus() - Show app status snapshot');
|
||||
console.log(' __opencodeDebug.checkLastMessage() - Check if last message is problematic');
|
||||
console.log(' __opencodeDebug.findEmptyMessages() - Find all empty assistant messages');
|
||||
console.log(' __opencodeDebug.showRetryHelp() - Show instructions for handling empty responses');
|
||||
console.log(' __opencodeDebug.getStreamingState() - Get streaming state info');
|
||||
console.log(' __opencodeDebug.analyzeMessageCompletionConsistency(opts?) - Compare time.completed vs part timings');
|
||||
console.log(' __opencodeDebug.checkCompletionStatus() - Check completion status of last message');
|
||||
if (streamDebugEnabled()) {
|
||||
console.log('[DEBUG] OpenCode Debug Utils loaded! Use window.__opencodeDebug in console');
|
||||
console.log('Available commands:');
|
||||
console.log(' __opencodeDebug.getLastAssistantMessage() - Get last assistant message details');
|
||||
console.log(' __opencodeDebug.getAllMessages(truncate?) - List all messages (truncate=true for short preview)');
|
||||
console.log(' __opencodeDebug.truncateMessages(messages) - Truncate long fields in messages array');
|
||||
console.log(' __opencodeDebug.getAppStatus() - Show app status snapshot');
|
||||
console.log(' __opencodeDebug.checkLastMessage() - Check if last message is problematic');
|
||||
console.log(' __opencodeDebug.findEmptyMessages() - Find all empty assistant messages');
|
||||
console.log(' __opencodeDebug.showRetryHelp() - Show instructions for handling empty responses');
|
||||
console.log(' __opencodeDebug.getStreamingState() - Get streaming state info');
|
||||
console.log(' __opencodeDebug.analyzeMessageCompletionConsistency(opts?) - Compare time.completed vs part timings');
|
||||
console.log(' __opencodeDebug.checkCompletionStatus() - Check completion status of last message');
|
||||
}
|
||||
|
||||
window.addEventListener('error', (event) => {
|
||||
try {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { refreshAfterOpenCodeRestart } from '@/stores/useAgentsStore';
|
||||
import { useCommandsStore } from '@/stores/useCommandsStore';
|
||||
import { useFileSearchStore } from '@/stores/useFileSearchStore';
|
||||
import { emitConfigChange } from '@/lib/configSync';
|
||||
import { streamDebugEnabled } from '@/stores/utils/streamDebug';
|
||||
import { getSafeStorage } from './utils/safeStorage';
|
||||
|
||||
interface DirectoryStore {
|
||||
@@ -296,13 +297,17 @@ export const useDirectoryStore = create<DirectoryStore>()(
|
||||
setDirectory: (path: string, options?: { showOverlay?: boolean }) => {
|
||||
const homeDir = cachedHomeDirectory || get().homeDirectory || safeStorage.getItem('homeDirectory');
|
||||
const resolvedPath = resolveDirectoryPath(path, homeDir);
|
||||
console.log('[DirectoryStore] setDirectory called with path:', resolvedPath);
|
||||
if (streamDebugEnabled()) {
|
||||
console.log('[DirectoryStore] setDirectory called with path:', resolvedPath);
|
||||
}
|
||||
const showOverlay = options?.showOverlay ?? true;
|
||||
|
||||
opencodeClient.setDirectory(resolvedPath);
|
||||
invalidateFileSearchCache();
|
||||
const restartPromise = notifyOpenCodeWorkingDirectory(resolvedPath, { showOverlay });
|
||||
console.log('[DirectoryStore] notifyOpenCodeWorkingDirectory initiated');
|
||||
if (streamDebugEnabled()) {
|
||||
console.log('[DirectoryStore] notifyOpenCodeWorkingDirectory initiated');
|
||||
}
|
||||
|
||||
set((state) => {
|
||||
|
||||
|
||||
@@ -264,7 +264,6 @@ export function createOpenCodeManager(_context: vscode.ExtensionContext): OpenCo
|
||||
if (!apiPrefixDetected || apiPrefix !== normalized) {
|
||||
apiPrefix = normalized;
|
||||
apiPrefixDetected = true;
|
||||
console.log(`[OpenCode] Detected API prefix: ${apiPrefix || '(root)'}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -354,7 +353,6 @@ export function createOpenCodeManager(_context: vscode.ExtensionContext): OpenCo
|
||||
function setDetectedPort(port: number) {
|
||||
if (detectedPort !== port) {
|
||||
detectedPort = port;
|
||||
console.log(`[OpenCode] Detected port: ${port}`);
|
||||
|
||||
// Notify all waiters
|
||||
const waiters = portWaiters;
|
||||
@@ -362,8 +360,8 @@ export function createOpenCodeManager(_context: vscode.ExtensionContext): OpenCo
|
||||
for (const notify of waiters) {
|
||||
try {
|
||||
notify(port);
|
||||
} catch (e) {
|
||||
console.warn('[OpenCode] Port waiter error:', e);
|
||||
} catch {
|
||||
// Ignore waiter errors
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -536,14 +534,12 @@ export function createOpenCodeManager(_context: vscode.ExtensionContext): OpenCo
|
||||
|
||||
childProcess.stdout?.on('data', (data) => {
|
||||
const text = data.toString();
|
||||
console.log('[OpenCode]', text.trim());
|
||||
detectPortFromOutput(text);
|
||||
detectApiPrefixFromOutput(text);
|
||||
});
|
||||
|
||||
childProcess.stderr?.on('data', (data) => {
|
||||
const text = data.toString();
|
||||
console.error('[OpenCode]', text.trim());
|
||||
detectPortFromOutput(text);
|
||||
detectApiPrefixFromOutput(text);
|
||||
});
|
||||
|
||||
@@ -37,7 +37,9 @@ export function ChatPanel() {
|
||||
const messageText = inputValue.trim();
|
||||
|
||||
if (!currentProviderId || !currentModelId) {
|
||||
console.warn('Missing provider or model selection for sendMessage');
|
||||
if (import.meta.env.DEV) {
|
||||
console.warn('Missing provider or model selection for sendMessage');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2875,7 +2875,6 @@ async function main(options = {}) {
|
||||
|
||||
const resolvedPath = path.resolve(expandedPath);
|
||||
fs.mkdirSync(resolvedPath, { recursive: true });
|
||||
console.log(`Created directory: ${resolvedPath}`);
|
||||
|
||||
res.json({ success: true, path: resolvedPath });
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user