Skip to content

Agent Zero AI framework

fix: file browser deletion bug + parent directory

Alessandrobb980ea6b93a
diff --git a/python/helpers/file_browser.py b/python/helpers/file_browser.py
index 0016151f2..9ed72209b 100644
--- a/python/helpers/file_browser.py
+++ b/python/helpers/file_browser.py
@@ -133,8 +133,16 @@ class FileBrowser:
# Get parent directory path if not at root
parent_path = ""
if current_path:
- parent = (Path(current_path).parent)
- parent_path = str(parent) if parent != Path(".") else ""
+ try:
+ # Get the absolute path of current directory
+ current_abs = (self.base_dir / current_path).resolve()
+
+ # parent_path is empty only if we're already at root
+ if str(current_abs) != str(self.base_dir):
+ parent_path = str(Path(current_path).parent)
+
+ except Exception as e:
+ parent_path = ""
return {
"entries": all_entries,
diff --git a/webui/css/file_browser.css b/webui/css/file_browser.css
index 36ffb2c7f..55c68b167 100644
--- a/webui/css/file_browser.css
+++ b/webui/css/file_browser.css
@@ -123,8 +123,14 @@
background-color: var(--color-secondary-dark);
}
-.current-path {
- font-family: monospace;
+#current-path {
+ opacity: 0.9;
+}
+
+#path-text {
+ font-family: 'Roboto Mono', monospace;
+ font-optical-sizing: auto;
+ -webkit-font-optical-sizing: auto;
opacity: 0.9;
}
diff --git a/webui/css/modals.css b/webui/css/modals.css
index e1ea64194..62e62a8f0 100644
--- a/webui/css/modals.css
+++ b/webui/css/modals.css
@@ -40,16 +40,10 @@
}
.modal-header h2 {
- color: var(--color-primary);
font-size: var(--font-size-large);
margin: 0;
}
-.modal-header > svg {
- fill: var(--color-primary);
- max-height: 30px !important;
-}
-
.modal-subheader {
padding: 0.7rem 1.5rem;
display: inline;
@@ -220,34 +214,44 @@ h2 {
}
@media (max-width: 768px) {
+ .modal-header {
+ padding-left: 1.1rem;
+ text-wrap: nowrap;
+ }
.modal-content {
- padding: 1rem;
- overflow-y: auto;
- flex-grow: 1;
+ padding: 0.5rem 0.5rem 0rem 0.5rem;
+ overflow-y: auto;
+ flex-grow: 1;
}
.modal-footer {
- padding: var(--spacing-md) 0rem var(--spacing-md) 0 !important;
+ padding: var(--spacing-sm) 0rem var(--spacing-sm) 0 !important;
}
.section {
- margin-bottom: 1.5rem;
- padding: 1rem;
- border: 1px solid var(--color-border);
- border-radius: 0.5rem;
+ margin-bottom: 1.5rem;
+ padding: 1rem;
+ border: 1px solid var(--color-border);
+ border-radius: 0.5rem;
}
#buttons-container {
margin: 0 auto;
}
+ .btn {
+ padding: 0.5rem 1.7rem;
+ }
}
@media (max-width: 540px) {
- .modal-header {
- text-wrap: nowrap;
+ .modal-header h2 {
+ font-size: var(--font-size-normal);
+ margin: 0;
}
#buttons-container {
max-height: 50px;
}
.btn {
text-wrap: wrap;
+ font-size: var(--font-size-small);
+ padding: 0.5rem 0.85rem;
}
.btn-upload {
margin: 0 auto;
diff --git a/webui/css/settings.css b/webui/css/settings.css
index 3555694f1..915e9644f 100644
--- a/webui/css/settings.css
+++ b/webui/css/settings.css
@@ -223,6 +223,10 @@ nav ul li a img {
background-color: var(--color-secondary-light);
}
+.light-mode textarea:focus {
+ background-color: #dddddd;
+}
+
@media (max-width: 768px) {
.field-control {
width: 100%;
diff --git a/webui/css/toast.css b/webui/css/toast.css
index 86334eb25..ce0dfa18b 100644
--- a/webui/css/toast.css
+++ b/webui/css/toast.css
@@ -1,43 +1,75 @@
#toast {
- /* position: fixed;
- bottom: 20px;
- left: 50%;
- transform: translateX(-50%); */
- margin: 0.5em;
- background-color: #333;
- color: #fff;
- padding: 0.3em;
- border-radius: 0.3125em;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
- display: none;
- align-items: center;
- z-index: 9999;
+ position: relative;
+ width: 98.5%;
+ bottom: var(--spacing-xs);
+ left: var(--spacing-xs);
+ background-color: #333;
+ color: #fff;
+ padding: 0.3em;
+ border-radius: 0.3125em;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
+ display: none;
+ align-items: center;
+ z-index: 9999;
+}
+
+#toast.show {
+ display: flex;
+ animation: toastIn 0.3s ease-out forwards;
+}
+
+#toast.hide {
+ animation: toastOut 0.3s ease-in forwards;
+}
+
+#toast.toast--success {
+ background-color: #4CAF50;
+}
+
+#toast.toast--error {
+ background-color: #731811;
+}
+
+#toast.toast--info {
+ background-color: #2196F3;
+}
+
+.toast__message {
+ margin-left: var(--spacing-xs);
+ margin-right: 16px;
+ flex-grow: 1;
+}
+
+.toast__close,
+.toast__copy {
+ background-color: transparent;
+ border: none;
+ color: #fff;
+ cursor: pointer;
+ font-size: 16px;
+ margin-left: 8px;
+}
+
+/* Animations */
+
+@keyframes toastIn {
+ from {
+ opacity: 0;
+ transform: translateY(20px);
}
-
- #toast.toast--success {
- background-color: #4CAF50;
+ to {
+ opacity: 1;
+ transform: translateY(0);
}
-
- #toast.toast--error {
- background-color: #731811;
+}
+
+@keyframes toastOut {
+ from {
+ opacity: 1;
+ transform: translateY(0);
}
-
- #toast.toast--info {
- background-color: #2196F3;
+ to {
+ opacity: 0;
+ transform: translateY(20px);
}
-
- .toast__message {
- margin-left: var(--spacing-xs);
- margin-right: 16px;
- flex-grow: 1;
- }
-
- .toast__close,
- .toast__copy {
- background-color: transparent;
- border: none;
- color: #fff;
- cursor: pointer;
- font-size: 16px;
- margin-left: 8px;
- }
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/webui/index.html b/webui/index.html
index 97cd3e157..974ce583e 100644
--- a/webui/index.html
+++ b/webui/index.html
@@ -195,7 +195,7 @@
</div>
<div id="toast" class="toast">
<div class="toast__message"></div>
- <button class="toast__copy">Copy</button>
+ <button class="toast__copy" style="display: none;">Copy</button>
<button class="toast__close">Close</button>
</div>
<div id="progress-bar-box" x-data="{ isSpeaking: false }" x-init="
@@ -538,7 +538,9 @@
Up
</button>
- <span class="current-path" x-text="browser.currentPath || 'Current Path: /'"></span>
+ <div id="current-path">
+ <span id="path-text" x-text="browser.currentPath"></span>
+ </div>
</div>
<div class="files-list">
diff --git a/webui/index.js b/webui/index.js
index 5ee658f91..dad86d04d 100644
--- a/webui/index.js
+++ b/webui/index.js
@@ -652,21 +652,31 @@ function removeClassFromElement(element, className) {
function toast(text, type = 'info') {
const toast = document.getElementById('toast');
-
+
// Update the toast content and type
- toast.querySelector('#toast .toast__message').textContent = text;
+ toast.querySelector('.toast__message').textContent = text;
toast.className = `toast toast--${type}`;
+
+ // Remove any existing animation classes
+ toast.classList.remove('show', 'hide');
+
+ // Show the toast and trigger animation
toast.style.display = 'flex';
-
+ // Force a reflow to ensure the animation triggers
+ void toast.offsetWidth;
+ toast.classList.add('show');
+
+ // Show/hide copy button based on toast type
+ const copyButton = toast.querySelector('.toast__copy');
+ copyButton.style.display = type === 'error' ? 'inline-block' : 'none';
+
// Add the close button event listener
- const closeButton = toast.querySelector('#toast .toast__close');
+ const closeButton = toast.querySelector('.toast__close');
closeButton.onclick = () => {
- toast.style.display = 'none';
- clearTimeout(toast.timeoutId);
+ hideToast();
};
-
+
// Add the copy button event listener
- const copyButton = toast.querySelector('#toast .toast__copy');
copyButton.onclick = () => {
navigator.clipboard.writeText(text);
copyButton.textContent = 'Copied!';
@@ -674,15 +684,27 @@ function toast(text, type = 'info') {
copyButton.textContent = 'Copy';
}, 2000);
};
-
+
// Clear any existing timeout
clearTimeout(toast.timeoutId);
-
- // Automatically close the toast after 5 seconds
+
+ // Automatically close the toast after 10 seconds
toast.timeoutId = setTimeout(() => {
- toast.style.display = 'none';
+ hideToast();
}, 10000);
}
+
+ function hideToast() {
+ const toast = document.getElementById('toast');
+ toast.classList.remove('show');
+ toast.classList.add('hide');
+
+ // Remove the element from display after animation completes
+ setTimeout(() => {
+ toast.style.display = 'none';
+ toast.classList.remove('hide');
+ }, 300); // Match this with animation duration
+}
function scrollChanged(isAtBottom) {
const inputAS = Alpine.$data(autoScrollSwitch);
diff --git a/webui/js/file_browser.js b/webui/js/file_browser.js
index 8f8f1621c..6823e0f98 100644
--- a/webui/js/file_browser.js
+++ b/webui/js/file_browser.js
@@ -110,7 +110,7 @@ const fileBrowserModalProxy = {
}
try {
- const response = await fetch('/deleteWorkDirFile', {
+ const response = await fetch('/delete_work_dir_file', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
diff --git a/webui/js/modal.js b/webui/js/modal.js
index d873a9c5c..52acdd513 100644
--- a/webui/js/modal.js
+++ b/webui/js/modal.js
@@ -1,6 +1,9 @@
const genericModalProxy = {
isOpen: false,
isLoading: false,
+ title: '',
+ description: '',
+ html: '',
async openModal(title, description, html) {
const modalEl = document.getElementById('genericModal');