style: auto-fix ESLint issues (curly braces and formatting)
- Add curly braces to all if/else/for/while statements - Fix indentation and trailing spaces - Auto-fixed 372 linting errors using eslint --fix - Remaining issues are warnings only (non-null assertions, explicit any types)
This commit is contained in:
@@ -65,12 +65,12 @@ export function initStatusIndicator() {
|
||||
|
||||
client.onStatusChange((status) => {
|
||||
statusEl.textContent = status === 'connected' ? 'Connected' :
|
||||
status === 'connecting' ? 'Connecting...' : 'Disconnected';
|
||||
status === 'connecting' ? 'Connecting...' : 'Disconnected';
|
||||
statusEl.className = `conn-status ${status}`;
|
||||
});
|
||||
|
||||
// Set initial status
|
||||
statusEl.textContent = client.status === 'connected' ? 'Connected' :
|
||||
client.status === 'connecting' ? 'Connecting...' : 'Disconnected';
|
||||
client.status === 'connecting' ? 'Connecting...' : 'Disconnected';
|
||||
statusEl.className = `conn-status ${client.status}`;
|
||||
}
|
||||
|
||||
@@ -165,18 +165,18 @@ export class FlynnClient {
|
||||
|
||||
const handle = {
|
||||
on(event, callback) {
|
||||
if (!events.has(event)) events.set(event, []);
|
||||
if (!events.has(event)) {events.set(event, []);}
|
||||
events.get(event).push(callback);
|
||||
return handle;
|
||||
},
|
||||
result: new Promise((resolve, reject) => {
|
||||
// Auto-wire done/error to resolve/reject the promise
|
||||
if (!events.has('done')) events.set('done', []);
|
||||
if (!events.has('done')) {events.set('done', []);}
|
||||
events.get('done').push((data) => {
|
||||
this._listeners.delete(id);
|
||||
resolve(data);
|
||||
});
|
||||
if (!events.has('error')) events.set('error', []);
|
||||
if (!events.has('error')) {events.set('error', []);}
|
||||
events.get('error').push((data) => {
|
||||
this._listeners.delete(id);
|
||||
reject(new Error(data.message || 'Agent error'));
|
||||
|
||||
@@ -133,7 +133,7 @@ function createMessageActions(role) {
|
||||
copyBtn.innerHTML = COPY_ICON;
|
||||
copyBtn.addEventListener('click', () => {
|
||||
const msg = bar.closest('.message');
|
||||
if (!msg) return;
|
||||
if (!msg) {return;}
|
||||
const text = getMessageText(msg);
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
copyBtn.innerHTML = CHECK_ICON;
|
||||
@@ -154,7 +154,7 @@ function createMessageActions(role) {
|
||||
editBtn.innerHTML = EDIT_ICON;
|
||||
editBtn.addEventListener('click', () => {
|
||||
const msg = bar.closest('.message');
|
||||
if (!msg) return;
|
||||
if (!msg) {return;}
|
||||
const text = getMessageText(msg);
|
||||
const input = _elements.input;
|
||||
if (input) {
|
||||
@@ -177,7 +177,7 @@ function setSearchMode(active) {
|
||||
_searchMode = active;
|
||||
const btn = _elements.searchBtn;
|
||||
const input = _elements.input;
|
||||
if (!btn || !input) return;
|
||||
if (!btn || !input) {return;}
|
||||
|
||||
if (active) {
|
||||
btn.classList.add('active');
|
||||
@@ -198,7 +198,7 @@ function getFilteredCommands(text) {
|
||||
|
||||
function showSlashPopup(filtered) {
|
||||
const popup = _elements.slashPopup;
|
||||
if (!popup) return;
|
||||
if (!popup) {return;}
|
||||
|
||||
popup.innerHTML = '';
|
||||
if (filtered.length === 0) {
|
||||
@@ -225,13 +225,13 @@ function showSlashPopup(filtered) {
|
||||
|
||||
function hideSlashPopup() {
|
||||
const popup = _elements.slashPopup;
|
||||
if (popup) popup.classList.add('hidden');
|
||||
if (popup) {popup.classList.add('hidden');}
|
||||
_slashPopupIndex = -1;
|
||||
}
|
||||
|
||||
function updatePopupSelection(filtered) {
|
||||
const popup = _elements.slashPopup;
|
||||
if (!popup) return;
|
||||
if (!popup) {return;}
|
||||
const items = popup.querySelectorAll('.slash-popup-item');
|
||||
items.forEach((el, i) => {
|
||||
el.classList.toggle('selected', i === _slashPopupIndex);
|
||||
@@ -240,7 +240,7 @@ function updatePopupSelection(filtered) {
|
||||
|
||||
function selectSlashCommand(name) {
|
||||
const input = _elements.input;
|
||||
if (!input) return;
|
||||
if (!input) {return;}
|
||||
input.value = name;
|
||||
hideSlashPopup();
|
||||
input.focus();
|
||||
@@ -248,14 +248,14 @@ function selectSlashCommand(name) {
|
||||
|
||||
function handleSlashPopupInput() {
|
||||
const input = _elements.input;
|
||||
if (!input) return;
|
||||
if (!input) {return;}
|
||||
const text = input.value;
|
||||
|
||||
// Show popup only when text starts with / and is at most a single word (the command itself)
|
||||
if (text.startsWith('/') && !text.includes(' ')) {
|
||||
const filtered = getFilteredCommands(text);
|
||||
// Clamp selection index
|
||||
if (_slashPopupIndex >= filtered.length) _slashPopupIndex = filtered.length - 1;
|
||||
if (_slashPopupIndex >= filtered.length) {_slashPopupIndex = filtered.length - 1;}
|
||||
showSlashPopup(filtered);
|
||||
} else {
|
||||
hideSlashPopup();
|
||||
@@ -266,7 +266,7 @@ function handleSlashPopupInput() {
|
||||
|
||||
function parseSlashCommand(text) {
|
||||
const trimmed = text.trim();
|
||||
if (!trimmed.startsWith('/')) return null;
|
||||
if (!trimmed.startsWith('/')) {return null;}
|
||||
|
||||
const parts = trimmed.split(/\s+/);
|
||||
const cmd = parts[0].toLowerCase();
|
||||
@@ -405,7 +405,7 @@ async function handleSlashCommand(cmd, client) {
|
||||
|
||||
async function loadSessions(client) {
|
||||
const select = _elements.sessionSelect;
|
||||
if (!select) return;
|
||||
if (!select) {return;}
|
||||
|
||||
try {
|
||||
const result = await client.call('sessions.list');
|
||||
@@ -425,7 +425,7 @@ async function loadSessions(client) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = s.id;
|
||||
opt.textContent = `${s.id} (${s.messageCount} msgs)`;
|
||||
if (s.id === current) opt.selected = true;
|
||||
if (s.id === current) {opt.selected = true;}
|
||||
select.appendChild(opt);
|
||||
}
|
||||
}
|
||||
@@ -439,7 +439,7 @@ async function loadSessions(client) {
|
||||
|
||||
async function loadHistory(client) {
|
||||
const msgs = _elements.messages;
|
||||
if (!msgs || !_currentSession) return;
|
||||
if (!msgs || !_currentSession) {return;}
|
||||
|
||||
msgs.innerHTML = '';
|
||||
|
||||
@@ -464,21 +464,21 @@ async function loadHistory(client) {
|
||||
async function sendMessage(client, overrideText) {
|
||||
const input = _elements.input;
|
||||
const rawText = overrideText ?? input?.value?.trim();
|
||||
if (!rawText || _sending) return;
|
||||
if (!rawText || _sending) {return;}
|
||||
|
||||
// Check for slash commands first
|
||||
const cmd = parseSlashCommand(rawText);
|
||||
if (cmd) {
|
||||
if (!overrideText) input.value = '';
|
||||
if (!overrideText) {input.value = '';}
|
||||
hideSlashPopup();
|
||||
const handled = await handleSlashCommand(cmd, client);
|
||||
if (handled) return;
|
||||
if (handled) {return;}
|
||||
// If not fully handled (e.g. /compact), fall through to send as message
|
||||
}
|
||||
|
||||
_sending = true;
|
||||
_elements.sendBtn.disabled = true;
|
||||
if (!overrideText) input.value = '';
|
||||
if (!overrideText) {input.value = '';}
|
||||
|
||||
// Apply search mode prefix
|
||||
let messageText = rawText;
|
||||
@@ -541,17 +541,17 @@ async function sendMessage(client, overrideText) {
|
||||
placeholder.textContent = `Error: ${err.message}`;
|
||||
} finally {
|
||||
_sending = false;
|
||||
if (_elements.sendBtn) _elements.sendBtn.disabled = false;
|
||||
if (_elements.sendBtn) {_elements.sendBtn.disabled = false;}
|
||||
scrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
// ── Search SVG Icon ─────────────────────────────────────────
|
||||
|
||||
const SEARCH_ICON = `<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.5 3a5.5 5.5 0 0 1 4.38 8.82l4.15 4.15a.75.75 0 0 1-1.06 1.06l-4.15-4.15A5.5 5.5 0 1 1 8.5 3zm0 1.5a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="currentColor"/></svg>`;
|
||||
const COPY_ICON = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z" fill="currentColor"/><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z" fill="currentColor"/></svg>`;
|
||||
const CHECK_ICON = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z" fill="currentColor"/></svg>`;
|
||||
const EDIT_ICON = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.081-.286.235-.547.445-.758l8.61-8.61Zm1.414 1.06a.25.25 0 0 0-.354 0L3.463 11.1l-.47 1.64 1.64-.47 8.61-8.61a.25.25 0 0 0 0-.354Z" fill="currentColor"/></svg>`;
|
||||
const SEARCH_ICON = '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.5 3a5.5 5.5 0 0 1 4.38 8.82l4.15 4.15a.75.75 0 0 1-1.06 1.06l-4.15-4.15A5.5 5.5 0 1 1 8.5 3zm0 1.5a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="currentColor"/></svg>';
|
||||
const COPY_ICON = '<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z" fill="currentColor"/><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z" fill="currentColor"/></svg>';
|
||||
const CHECK_ICON = '<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z" fill="currentColor"/></svg>';
|
||||
const EDIT_ICON = '<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.081-.286.235-.547.445-.758l8.61-8.61Zm1.414 1.06a.25.25 0 0 0-.354 0L3.463 11.1l-.47 1.64 1.64-.47 8.61-8.61a.25.25 0 0 0 0-.354Z" fill="currentColor"/></svg>';
|
||||
|
||||
// ── Page Export ──────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -14,17 +14,17 @@ function formatUptime(seconds) {
|
||||
const m = Math.floor((seconds % 3600) / 60);
|
||||
const s = seconds % 60;
|
||||
const parts = [];
|
||||
if (d > 0) parts.push(`${d}d`);
|
||||
if (h > 0) parts.push(`${h}h`);
|
||||
if (m > 0) parts.push(`${m}m`);
|
||||
if (d > 0) {parts.push(`${d}d`);}
|
||||
if (h > 0) {parts.push(`${h}h`);}
|
||||
if (m > 0) {parts.push(`${m}m`);}
|
||||
parts.push(`${s}s`);
|
||||
return parts.join(' ');
|
||||
}
|
||||
|
||||
function timeAgo(timestamp) {
|
||||
const secs = Math.floor((Date.now() - timestamp) / 1000);
|
||||
if (secs < 60) return `${secs}s ago`;
|
||||
if (secs < 3600) return `${Math.floor(secs / 60)}m ago`;
|
||||
if (secs < 60) {return `${secs}s ago`;}
|
||||
if (secs < 3600) {return `${Math.floor(secs / 60)}m ago`;}
|
||||
return `${Math.floor(secs / 3600)}h ago`;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ function renderSkeleton(el) {
|
||||
|
||||
function updateCounters(metrics, health) {
|
||||
const el = document.getElementById('ops-counters');
|
||||
if (!el) return;
|
||||
if (!el) {return;}
|
||||
|
||||
const sessions = health?.sessions ?? 0;
|
||||
const errCount = metrics?.errors ?? 0;
|
||||
@@ -94,13 +94,13 @@ function updateCounters(metrics, health) {
|
||||
`<div class="stat-card">
|
||||
<div class="stat-label">${c.label}</div>
|
||||
<div class="stat-value ${c.cls}">${c.value}</div>
|
||||
</div>`
|
||||
</div>`,
|
||||
).join('');
|
||||
}
|
||||
|
||||
function updateModelTable(metrics) {
|
||||
const el = document.getElementById('ops-model-table');
|
||||
if (!el) return;
|
||||
if (!el) {return;}
|
||||
|
||||
const mc = metrics?.modelCalls;
|
||||
const calls = mc?.recentCalls ?? [];
|
||||
@@ -155,7 +155,7 @@ function updateModelTable(metrics) {
|
||||
|
||||
function updateEvents(eventsData) {
|
||||
const el = document.getElementById('ops-events');
|
||||
if (!el) return;
|
||||
if (!el) {return;}
|
||||
|
||||
const events = eventsData?.events ?? [];
|
||||
|
||||
@@ -180,7 +180,7 @@ function updateEvents(eventsData) {
|
||||
|
||||
function updateActiveRequests(requestsData) {
|
||||
const el = document.getElementById('ops-requests');
|
||||
if (!el) return;
|
||||
if (!el) {return;}
|
||||
|
||||
const requests = requestsData?.requests ?? [];
|
||||
|
||||
@@ -219,7 +219,7 @@ function updateActiveRequests(requestsData) {
|
||||
|
||||
function updateChannels(channelsData) {
|
||||
const el = document.getElementById('ops-channels');
|
||||
if (!el) return;
|
||||
if (!el) {return;}
|
||||
|
||||
const channels = channelsData?.channels ?? [];
|
||||
|
||||
@@ -232,7 +232,7 @@ function updateChannels(channelsData) {
|
||||
`<div class="channel-card">
|
||||
<span class="channel-dot ${ch.status}"></span>
|
||||
<span class="channel-name">${escapeHtml(ch.name)}</span>
|
||||
</div>`
|
||||
</div>`,
|
||||
).join('');
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ let _client = null;
|
||||
let _el = null;
|
||||
|
||||
async function loadSessionList() {
|
||||
if (!_client || !_el) return;
|
||||
if (!_client || !_el) {return;}
|
||||
|
||||
const listContainer = _el.querySelector('#sessions-list');
|
||||
const detailContainer = _el.querySelector('#session-detail');
|
||||
if (detailContainer) detailContainer.innerHTML = '';
|
||||
if (detailContainer) {detailContainer.innerHTML = '';}
|
||||
|
||||
try {
|
||||
const result = await _client.call('sessions.list');
|
||||
@@ -78,7 +78,7 @@ async function loadSessionList() {
|
||||
|
||||
async function viewSession(sessionId) {
|
||||
const detailContainer = _el.querySelector('#session-detail');
|
||||
if (!detailContainer) return;
|
||||
if (!detailContainer) {return;}
|
||||
|
||||
detailContainer.innerHTML = '<div class="empty-state"><span class="spinner"></span> Loading...</div>';
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ let _client = null;
|
||||
let _el = null;
|
||||
|
||||
async function loadSettings() {
|
||||
if (!_client || !_el) return;
|
||||
if (!_client || !_el) {return;}
|
||||
|
||||
let config, tools, channels;
|
||||
|
||||
@@ -154,7 +154,7 @@ async function saveHooks() {
|
||||
|
||||
// Clear status after 5s
|
||||
setTimeout(() => {
|
||||
if (status) status.textContent = '';
|
||||
if (status) {status.textContent = '';}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,14 +13,14 @@ function formatNumber(n) {
|
||||
}
|
||||
|
||||
function formatCost(n) {
|
||||
if (!n || n === 0) return '$0.00';
|
||||
if (n < 0.01) return `$${n.toFixed(4)}`;
|
||||
if (!n || n === 0) {return '$0.00';}
|
||||
if (n < 0.01) {return `$${n.toFixed(4)}`;}
|
||||
return `$${n.toFixed(2)}`;
|
||||
}
|
||||
|
||||
function truncateId(id) {
|
||||
if (!id) return '-';
|
||||
if (id.length <= 24) return id;
|
||||
if (!id) {return '-';}
|
||||
if (id.length <= 24) {return id;}
|
||||
return id.slice(0, 24) + '\u2026';
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ async function loadUsage(el, client) {
|
||||
let delegationCell = '<span class="text-muted">-</span>';
|
||||
if (delegationEntries.length > 0) {
|
||||
delegationCell = delegationEntries.map(([tier, stats]) =>
|
||||
`<span class="badge ok">${tier}</span> ${formatNumber(stats.inputTokens)}/${formatNumber(stats.outputTokens)}`
|
||||
`<span class="badge ok">${tier}</span> ${formatNumber(stats.inputTokens)}/${formatNumber(stats.outputTokens)}`,
|
||||
).join('<br>');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user