Skip to content
Merged
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
38 changes: 28 additions & 10 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2310,23 +2310,16 @@ def parse_script_metadata(filepath):
for line in f:
line = line.strip()
if line.startswith("# name:"):
metadata["name"] = line[7:].strip()
name_val = line[7:].strip()
if name_val:
metadata["name"] = name_val
elif line.startswith("# desc:"):
metadata["desc"] = line[7:].strip()
elif line.startswith("# tag:"):
metadata["tag"] = line[6:].strip()
elif line.startswith("# url:"):
metadata["url"] = line[6:].strip()
elif not line.startswith("#") and line:
if line.startswith('# name:'):
name_val = line[7:].strip()
if name_val:
metadata['name'] = name_val
elif line.startswith('# desc:'):
metadata['desc'] = line[7:].strip()
elif line.startswith('# tag:'):
metadata['tag'] = line[6:].strip()
elif not line.startswith('#') and line:
break
except Exception: # nosec B110
pass
Expand Down Expand Up @@ -2464,6 +2457,31 @@ def clear_history():
pass
with open(FAILED_HISTORY_FILE, 'w', encoding='utf-8') as f:
pass

# Clear execution logs
if os.path.exists(EXECUTION_LOG_DIR):
for filename in os.listdir(EXECUTION_LOG_DIR):
file_path = os.path.join(EXECUTION_LOG_DIR, filename)
try:
if os.path.isfile(file_path) or os.path.islink(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
except Exception:
pass

# Clear session logs
if os.path.exists(SESSION_LOG_DIR):
for filename in os.listdir(SESSION_LOG_DIR):
file_path = os.path.join(SESSION_LOG_DIR, filename)
try:
if os.path.isfile(file_path) or os.path.islink(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
except Exception:
pass

return jsonify({
'success': True,
'message': 'Execution history cleared successfully'
Expand Down
50 changes: 35 additions & 15 deletions ui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const API = {
pr: '/api/git/pr',
history: '/api/history',
history_export: '/api/history/export',
history_clear: '/api/history/clear',
kill: '/api/scripts/kill',
command_history_clear: '/api/command_history/clear',
reliability_summary: '/api/reliability/summary',
reliability_failures: '/api/reliability/failures',
reliability_trends: '/api/reliability/trends',
Expand Down Expand Up @@ -3526,9 +3528,9 @@ function bindEvents() {
const historyOverlay = document.getElementById('history-modal-overlay');
const historyClose = document.getElementById('history-modal-close');
const historySearch = document.getElementById('history-search');
const historyFilters = document.querySelectorAll('.history-filter');
const historyExportTxt = document.getElementById('history-export-txt');
const historyExportLog = document.getElementById('history-export-log');
const btnClearHistory = document.getElementById('btn-clear-history');

if (historyClose) historyClose.addEventListener('click', closeHistoryViewer);
if (historyOverlay) {
Expand All @@ -3553,31 +3555,49 @@ function bindEvents() {
if (historyExportTxt) historyExportTxt.addEventListener('click', () => exportExecutionHistory('txt'));
if (historyExportLog) historyExportLog.addEventListener('click', () => exportExecutionHistory('log'));


const historyClearBtn = document.getElementById('history-clear-btn');
if (historyClearBtn) {
historyClearBtn.addEventListener('click', async () => {
const confirmation = confirm('Are you sure you want to permanently clear your command history log?');
const confirmation = confirm('Are you sure you want to permanently clear your command and execution history? This will delete all script and command run logs, and reset CLI command history. This action cannot be undone.');
if (!confirmation) return;

try {
const response = await fetch('/api/command_history/clear', {
// Clear command history
const cmdRes = await fetch(API.command_history_clear, {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
const result = await response.json();
const cmdResult = await cmdRes.json();

if (result.success) {
const targetDisplayList = document.getElementById('history-list');
if (targetDisplayList) {
targetDisplayList.innerHTML = '<div class="history-empty-state">Command history cleared successfully.</div>';
}
const targetSummaryWidget = document.getElementById('history-summary');
if (targetSummaryWidget) {
targetSummaryWidget.innerHTML = '';
}
notify('Command history cleared successfully!', 'success');
// Clear execution history
const execRes = await fetch(API.history_clear, {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
const execResult = await execRes.json();

if (cmdResult.success && execResult.success) {
// Reset client-side state
state.cmdHistory = [];
state.cmdHistoryIndex = -1;
state.historyEntries = [];
state.historySummary = {
total: 0,
failed: 0,
successful: 0,
scripts: 0,
commands: 0
};

// Re-render components
renderHistorySummary(state.historySummary);
renderHistoryEntries(state.historyEntries);

notify('Command and execution history cleared successfully!', 'success');
} else {
notify('Server failed to clear history: ' + (result.error || 'Unknown error'), 'error');
const errMsg = (cmdResult.error || execResult.error || 'Unknown error');
notify('Server failed to clear history: ' + errMsg, 'error');
}
} catch (err) {
console.error('Error clearing history:', err);
Expand Down