Skip to content

Commit f4a24a2

Browse files
fazxesclaude
andcommitted
fix(dev-monitor): fix dedup flush causing duplicate entries
- Reset dedup count after flushing to prevent re-writing same entries - Add console.warn logs for initialization visibility - Fixes issue where 16k+ duplicate entries were written 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 38a8beb commit f4a24a2

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎apps/agent/src/dev-monitor/dedup.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,17 @@ function flushDedupEntry(dedup: DedupEntry): DevLogEntry {
163163
* Flush all pending dedup entries with counts > 1.
164164
*
165165
* Call on shutdown or periodic flush to ensure counts are written.
166+
* After flushing, resets the count to 1 so entries aren't re-flushed.
166167
*/
167168
export function flushAllDedup(): DevLogEntry[] {
168169
const entries: DevLogEntry[] = [];
169170

170171
for (const dedup of dedupMap.values()) {
171172
if (dedup.count > 1) {
172173
entries.push(flushDedupEntry(dedup));
174+
// Reset count so we don't flush the same summary again
175+
dedup.count = 1;
176+
dedup.firstSeen = dedup.lastSeen;
173177
}
174178
}
175179

‎apps/agent/src/dev-monitor/index.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ export async function initDevMonitor(options?: InitOptions): Promise<void> {
7878
// Production: do nothing (tree-shaken)
7979
if (import.meta.env.PROD) return;
8080

81+
console.warn('[DevMonitor] Starting initialization...');
82+
8183
try {
8284
// Dynamic import only happens in dev
8385
const { devTrace, init } = await import('./dev-trace');
@@ -87,6 +89,8 @@ export async function initDevMonitor(options?: InitOptions): Promise<void> {
8789

8890
// Initialize auto-capture, storage, etc.
8991
await init(options);
92+
93+
console.warn('[DevMonitor] ✓ Ready - trace methods are now active');
9094
} catch (err: unknown) {
9195
// Init failed - stay on noop, log error
9296
console.error('[DevMonitor] Initialization failed:', err);

‎apps/agent/src/dev-monitor/storage.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export async function initStorage(options: InitOptions = {}): Promise<void> {
6363
}, config.flushInterval);
6464

6565
initialized = true;
66+
67+
// Log success to console so user knows it's working
68+
const outputPath = workspacePath ? `${workspacePath}/${config.outputDir}` : '(no workspace)';
69+
console.warn(`[DevMonitor] ✓ Initialized - output: ${outputPath}`);
6670
} catch (err: unknown) {
6771
console.error('[DevMonitor] Storage init failed:', err);
6872
}

0 commit comments

Comments
 (0)