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