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:
@@ -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 ──────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user