included more features

This commit is contained in:
rob 2025-10-15 22:29:51 -03:00
parent 9049531298
commit 58afa54a7d
3 changed files with 24 additions and 3 deletions

View File

@ -119,7 +119,7 @@ example: true
- AI_REPO_STOP(): emergency stop
- AI_REPO.clearHistory: clear dedupe history
- window.AI_REPO_COMMANDER: monitor, config, tests, history
- window.AI_REPO: monitor, config, tests, history
## Security Model
- Bridge key stored locally and masked, never logged

View File

@ -31,6 +31,27 @@
this.info(`${icon} ${action} [${status}]`, extra);
}
/**
* Special logger for preventing log spam from aggressive loops or frequently repeated operations.
*
* Use this when logging inside tight loops, mutation observers, or frequently-fired events
* to avoid polluting the logs and making it hard to find other information.
*
* Features:
* - Limits each unique message to max 10 occurrences
* - Only logs within the watch window (default 120s from logger start)
* - Shows occurrence count (e.g., "Processing message (3x)")
* - WARN messages bypass the time window restriction
*
* @param {string} kind - Log level: 'ERROR', 'WARN', or 'INFO'
* @param {string} msg - The message to log
*
* @example
* // Inside a mutation observer that fires rapidly:
* observer.observe(() => {
* log.logLoop('INFO', 'Processing DOM mutation'); // Won't spam after 10 times
* });
*/
logLoop(kind, msg) {
const k = `${kind}:${msg}`;
const cur = this.loopCounts.get(k) || 0;

View File

@ -6,7 +6,7 @@
const log = () => window.AI_REPO_LOGGER;
function findComposer() {
const sels = [
const selectors = [
'#prompt-textarea',
'.ProseMirror#prompt-textarea',
'.ProseMirror[role="textbox"][contenteditable="true"]',
@ -17,7 +17,7 @@
'textarea',
'[contenteditable="true"]'
];
for (const s of sels) {
for (const s of selectors) {
const el = document.querySelector(s);
if (!el) continue;
const st = window.getComputedStyle(el);