Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2566,8 +2566,8 @@ def clear_history():
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
except Exception:
pass
except Exception as exc:
logger.warning("Failed to remove execution log entry %s: %s", file_path, exc)

# Clear session logs
if os.path.exists(SESSION_LOG_DIR):
Expand All @@ -2578,8 +2578,8 @@ def clear_history():
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
except Exception:
pass
except Exception as exc:
logger.warning("Failed to remove session log entry %s: %s", file_path, exc)

return jsonify({
'success': True,
Expand Down
45 changes: 45 additions & 0 deletions ui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ let state = {
sessionId: null,
lastSaveTimestamp: 0,
runningScripts: {}, // termId -> { step, total, command, status }
terminalTimerInterval: null,
reliabilitySummary: null,
reliabilityFailures: null,
reliabilityTrends: null,
Expand Down Expand Up @@ -1035,11 +1036,51 @@ function cleanupRunningScript(termId) {
delete state.runningScripts[termId];

if (termId === state.activeTerminalId) {
stopTerminalTimer();
updateRunButton();
updateProgressTrackerUI();
}
}

function formatElapsedTime(ms) {
const totalSeconds = Math.max(0, Math.floor(ms / 1000));
const minutes = String(Math.floor(totalSeconds / 60)).padStart(2, '0');
const seconds = String(totalSeconds % 60).padStart(2, '0');
return `${minutes}:${seconds}`;
}

function updateTerminalTimer() {
const timer = document.getElementById('terminal-session-timer');
if (!timer) return;

const running = state.runningScripts[state.activeTerminalId];
if (!running?.startedAt) {
timer.style.display = 'none';
timer.textContent = '00:00';
return;
}

timer.textContent = formatElapsedTime(Date.now() - running.startedAt);
timer.style.display = 'inline-flex';
}

function startTerminalTimer() {
stopTerminalTimer(false);
updateTerminalTimer();
state.terminalTimerInterval = setInterval(updateTerminalTimer, 1000);
}

function stopTerminalTimer(reset = true) {
if (state.terminalTimerInterval) {
clearInterval(state.terminalTimerInterval);
state.terminalTimerInterval = null;
}

if (reset) {
updateTerminalTimer();
}
}

async function abortScriptRun(termId = state.activeTerminalId) {
const running = state.runningScripts[termId];
if (!running) return;
Expand Down Expand Up @@ -1145,9 +1186,11 @@ async function executeScriptWithArguments(relPath, argumentsText) {
total: 0,
command: 'Starting script...',
status: 'running',
startedAt: Date.now(),
controller: controller
};
updateRunButton();
startTerminalTimer();

if (termId === state.activeTerminalId) {
runStatus.textContent = 'Executing...';
Expand Down Expand Up @@ -2805,9 +2848,11 @@ function switchTerminal(id) {
runStatus.textContent = running.aborting ? 'Aborting...' : 'Executing...';
runStatus.className = 'run-status running';
resourcePanel.style.display = 'none';
startTerminalTimer();
} else {
runStatus.textContent = '';
runStatus.className = 'run-status';
stopTerminalTimer();
}
updateRunButton();
highlightTerminalSearch();
Expand Down
1 change: 1 addition & 0 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ <h2>Scripts</h2>
<span id="cli-search-results"></span>
</div>
<span class="run-status" id="run-status"></span>
<span class="timer-badge" id="terminal-session-timer" aria-live="polite" style="display: none;">00:00</span>
<button class="btn-icon" id="btn-lock-terminal" title="Lock Terminal"
aria-label="Lock terminal">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24"
Expand Down
14 changes: 14 additions & 0 deletions ui/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,20 @@ body {
animation: pulse 1.5s infinite;
}

.timer-badge {
align-items: center;
min-width: 46px;
height: 24px;
padding: 0 8px;
border: 1px solid rgba(245, 158, 11, 0.35);
border-radius: 999px;
background: rgba(245, 158, 11, 0.08);
color: var(--accent-orange);
font-family: var(--font-mono);
font-size: 11px;
font-weight: 600;
}

@keyframes pulse {

0%,
Expand Down
Loading