Skip to content

Sidebar: workspace chat list not visible until clicking folder chevron #134

Description

@PhilippeRoy

Sidebar: workspace chat list is not visible until clicking the folder chevron

Describe the bug
When navigating to a workspace (either via URL or by clicking the workspace name in the sidebar), the chat list remains hidden. The user must click a small folder chevron icon to expand the workspace and see the chat list. Clicking the workspace name should also expand the workspace to show its chats.

To Reproduce

  1. Open the app with ?workspace=/some/path (or any workspace path)
  2. Notice the sidebar shows the workspace name but no chat list
  3. The chat list only appears after clicking the tiny folder chevron icon next to the workspace name

Expected behavior

  • When navigating to a workspace (clicking its name), the workspace should auto-expand to show the chat list
  • When loading a page with a ?workspace= URL parameter, that workspace should auto-expand

Technical details
The issue is in SidebarWorkspaceList.svelte. The openWorkspace() function navigates to the workspace URL but does not expand the workspace. The onMount also does not auto-expand the workspace from the URL.

Patch (source-level diff)

Two changes to cptr/frontend/src/lib/components/SidebarWorkspaceList.svelte:

Change 1 — openWorkspace() function:

function openWorkspace(e: MouseEvent, path: string) {
    if (e.metaKey || e.ctrlKey) return;
    e.preventDefault();
    // NEW: expand the workspace when clicking the name
    if (!expandedWorkspaces.has(path)) {
        const next = new Set(expandedWorkspaces);
        next.add(path);
        expandedWorkspaces = next;
        if (!wsChatsCache.has(path)) fetchWorkspaceChats(path);
    }
    goto(`/?workspace=${encodeURIComponent(path)}`);
    closeMobileSidebar();
}

Change 2 — inside onMount():

onMount(async () => {
    // ... existing sortable setup ...
    // ... existing socket listener ...

    // NEW: auto-expand the workspace from the URL on page load
    if (currentPath && !expandedWorkspaces.has(currentPath)) {
        const next = new Set(expandedWorkspaces);
        next.add(currentPath);
        expandedWorkspaces = next;
        await fetchWorkspaceChats(currentPath);
    }
});

For pipx installations (no source available):
Edit the compiled JS file at _app/immutable/nodes/0.<hash>.js:

  1. In function N(e,t){...} — add ,l(x).has(t)||O(t) after the goto() call
  2. In L(()=>{...}) — add ,l(D)&&!l(x).has(l(D))&&O(l(D)) before the closing })
  3. Bump the service worker version timestamp to force re-cache

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions