mirror of
https://github.com/open-webui/computer.git
synced 2026-11-22 21:50:43 -05:00
refac
This commit is contained in:
1 parent
a9cf9661b4
commit
0155b93408
5 files changed
+181
-791
No files matched your search
+1
-1
@@ -1 +1 @@
|
||||
3.9
|
||||
3.13
|
||||
@@ -27,6 +27,14 @@ app = FastAPI()
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup():
|
||||
# Use OS certificate store (Windows CertStore, macOS Keychain, etc.)
|
||||
# instead of the bundled certifi CA bundle — fixes #31.
|
||||
import logging as _logging
|
||||
import truststore
|
||||
|
||||
truststore.inject_into_ssl()
|
||||
_logging.getLogger(__name__).info("truststore: using system certificate store")
|
||||
|
||||
await init_db()
|
||||
from cptr.env import STARTUP_TOKEN
|
||||
|
||||
|
||||
@@ -131,6 +131,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleNewChat(wsPath: string) {
|
||||
// Navigate to the workspace if not already there
|
||||
const currentWsPath = $page.url.searchParams.get('workspace');
|
||||
if ($page.url.pathname !== '/' || currentWsPath !== wsPath) {
|
||||
await goto(`/?workspace=${encodeURIComponent(wsPath)}`);
|
||||
}
|
||||
// Wait for loadWorkspace() to finish populating currentWorkspace
|
||||
// (it runs async in a $effect after goto resolves)
|
||||
const ws = get(currentWorkspace);
|
||||
if (!ws || ws.path !== wsPath) {
|
||||
await new Promise<void>((resolve) => {
|
||||
const unsub = currentWorkspace.subscribe((w) => {
|
||||
if (w && w.path === wsPath) {
|
||||
unsub();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
openChatTab();
|
||||
if (typeof window !== 'undefined' && window.innerWidth < 768) {
|
||||
sidebarOpen.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Socket listener for chat events — invalidate cache when chats update
|
||||
const seenChatIds = new Set<string>();
|
||||
|
||||
@@ -346,40 +371,42 @@
|
||||
{@const chats = wsChatsCache.get(ws.path)}
|
||||
{@const isLoading = wsChatsLoading.has(ws.path)}
|
||||
<div class="ws-item">
|
||||
<a
|
||||
href="/?workspace={encodeURIComponent(ws.path)}"
|
||||
class="group flex items-center gap-1.5 w-full h-7 px-2 rounded-lg text-xs font-medium transition-colors duration-100 no-underline
|
||||
{ws.path === currentPath
|
||||
? 'bg-gray-200/50 text-gray-900 dark:bg-white/8 dark:text-white'
|
||||
: 'text-gray-500 hover:text-gray-700 dark:hover:text-gray-300'}"
|
||||
onclick={(e) => handleWorkspaceClick(e, ws.path)}
|
||||
>
|
||||
<!-- Icon: folder by default, chevron on hover (when chat enabled) -->
|
||||
{#if $chatEnabled}
|
||||
<span
|
||||
class="ws-icon-toggle shrink-0"
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
onclick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
toggleWorkspaceExpand(ws.path);
|
||||
}}
|
||||
aria-label={isExpanded ? 'Collapse' : 'Expand'}
|
||||
>
|
||||
<span class="ws-icon-folder"><Icon name="folder" size={14} /></span>
|
||||
<span class="ws-icon-chevron" style="transform: rotate({isExpanded ? '90deg' : '0deg'})">
|
||||
<Icon name="chevron-right" size={11} />
|
||||
</span>
|
||||
</span>
|
||||
{:else}
|
||||
<Icon name="folder" size={14} />
|
||||
{/if}
|
||||
<span class="flex-1 text-left overflow-hidden text-ellipsis whitespace-nowrap"
|
||||
>{ws.name}</span
|
||||
<div class="group flex items-center gap-1 w-full h-7 px-2 rounded-lg text-xs font-medium transition-colors duration-100
|
||||
{ws.path === currentPath
|
||||
? 'bg-gray-200/50 text-gray-900 dark:bg-white/8 dark:text-white'
|
||||
: 'text-gray-500 hover:text-gray-700 dark:hover:text-gray-300'}">
|
||||
<a
|
||||
href="/?workspace={encodeURIComponent(ws.path)}"
|
||||
class="flex items-center gap-1 flex-1 min-w-0 no-underline text-inherit"
|
||||
onclick={(e) => handleWorkspaceClick(e, ws.path)}
|
||||
>
|
||||
<!-- Icon: folder by default, chevron on hover (when chat enabled) -->
|
||||
{#if $chatEnabled}
|
||||
<span
|
||||
class="ws-icon-toggle shrink-0"
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
onclick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
toggleWorkspaceExpand(ws.path);
|
||||
}}
|
||||
aria-label={isExpanded ? 'Collapse' : 'Expand'}
|
||||
>
|
||||
<span class="ws-icon-folder"><Icon name="folder" size={14} /></span>
|
||||
<span class="ws-icon-chevron" style="transform: rotate({isExpanded ? '90deg' : '0deg'})">
|
||||
<Icon name="chevron-right" size={11} />
|
||||
</span>
|
||||
</span>
|
||||
{:else}
|
||||
<Icon name="folder" size={14} />
|
||||
{/if}
|
||||
<span class="flex-1 text-left overflow-hidden text-ellipsis whitespace-nowrap"
|
||||
>{ws.name}</span
|
||||
>
|
||||
</a>
|
||||
<span
|
||||
class="flex items-center justify-center w-5 h-5 rounded shrink-0 text-gray-400 opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-white/10 transition-all duration-75"
|
||||
class="flex items-center justify-center w-4 h-4 shrink-0 text-gray-400 opacity-0 group-hover:opacity-100 hover:text-gray-600 dark:hover:text-gray-300 transition-all duration-75"
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
onclick={(e) => openWsMenu(e, ws.path)}
|
||||
@@ -387,7 +414,19 @@
|
||||
>
|
||||
<Icon name="three-dots" size={11} />
|
||||
</span>
|
||||
</a>
|
||||
{#if $chatEnabled}
|
||||
<span
|
||||
class="flex items-center justify-center w-4 h-4 shrink-0 text-gray-400 opacity-0 group-hover:opacity-100 hover:text-gray-600 dark:hover:text-gray-300 transition-all duration-75"
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
onclick={() => handleNewChat(ws.path)}
|
||||
aria-label="New Chat"
|
||||
use:tooltip={'New Chat'}
|
||||
>
|
||||
<Icon name="pencil" size={11} />
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Collapsible chat list -->
|
||||
{#if $chatEnabled && isExpanded}
|
||||
|
||||
+3
-2
@@ -4,7 +4,7 @@ version = "0.2.0"
|
||||
description = "Your computer, from anywhere. Code, manage, and control your machine from the web."
|
||||
license = {file = "LICENSE"}
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.9"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
"click>=8.1",
|
||||
"fastapi[standard]>=0.128.8",
|
||||
@@ -18,6 +18,7 @@ dependencies = [
|
||||
"cryptography>=42.0",
|
||||
"python-socketio[asgi]>=5.11",
|
||||
"python-dateutil>=2.8",
|
||||
"truststore>=0.10",
|
||||
"pywinpty>=2.0; sys_platform == 'win32'",
|
||||
]
|
||||
|
||||
@@ -46,7 +47,7 @@ exclude = ["cptr/frontend"]
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 100
|
||||
target-version = "py39"
|
||||
target-version = "py310"
|
||||
extend-exclude = [
|
||||
"cptr/frontend",
|
||||
"dist",
|
||||
|
||||
Reference in new issue
Block a user