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
24 changes: 22 additions & 2 deletions packages/ui/src/components/folder-tree-node.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, createSignal, Show, For } from "solid-js"
import { Component, createSignal, Show, For, createEffect, onCleanup } from "solid-js"
import { ChevronRight, ChevronDown, File, Folder, FolderOpen } from "lucide-solid"
import type { FileSystemEntry } from "../../../server/src/api-types"
import { SECTION_EXPANSION_EVENT, type SectionExpansionRequest } from "../lib/section-expansion"

/**
* Props for FolderTreeNode component
Expand Down Expand Up @@ -38,6 +39,25 @@ const FolderTreeNode: Component<FolderTreeNodeProps> = (props) => {
const [isLoading, setIsLoading] = createSignal(false)
const [error, setError] = createSignal<string | null>(null)

// Listen for folder expansion requests from search system
createEffect(() => {
if (typeof window === "undefined") return

const handler = (event: Event) => {
const detail = (event as CustomEvent<SectionExpansionRequest>).detail
if (
detail.action === "expand-folder-node" &&
detail.elementId === props.entry.path
) {
// Auto-expand the folder
setIsExpanded(true)
}
}

window.addEventListener(SECTION_EXPANSION_EVENT, handler)
onCleanup(() => window.removeEventListener(SECTION_EXPANSION_EVENT, handler))
})

const isDirectory = () => props.entry.type === "directory"
const isMarkdownFile = () => {
return props.entry.type === "file" && props.entry.name.toLowerCase().endsWith(".md")
Expand Down Expand Up @@ -123,7 +143,7 @@ const FolderTreeNode: Component<FolderTreeNodeProps> = (props) => {
}

return (
<div class="folder-tree-node" data-level={props.level}>
<div class="folder-tree-node" data-node-id={props.entry.path} data-level={props.level}>
{/* Node row */}
<div
class="folder-tree-node-row"
Expand Down
29 changes: 29 additions & 0 deletions packages/ui/src/components/instance/instance-shell2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import type { Instance } from "../../types/instance"
import type { Command } from "../../lib/commands"
import type { BackgroundProcess } from "../../../../server/src/api-types"
import type { Session } from "../../types/session"
import { SECTION_EXPANSION_EVENT, type SectionExpansionRequest } from "../../lib/section-expansion"
import {
activeParentSessionId,
activeSessionId as activeSessionMap,
Expand All @@ -46,6 +47,7 @@ import { messageStoreBus } from "../../stores/message-v2/bus"
import { clearSessionRenderCache } from "../message-block"

import { isOpen as isCommandPaletteOpen, hideCommandPalette, showCommandPalette } from "../../stores/command-palette"
import { openSearch } from "../../stores/search-store"
import SessionList from "../session-list"
import KeyboardHint from "../keyboard-hint"
import InstanceWelcomeView from "../instance-welcome-view"
Expand All @@ -63,6 +65,7 @@ import Kbd from "../kbd"
import { TodoListView } from "../tool-call/renderers/todo"
import ContextUsagePanel from "../session/context-usage-panel"
import SessionView from "../session/session-view"
import SearchPanel from "../search-panel"
import { formatTokenTotal } from "../../lib/formatters"
import { sseManager } from "../../lib/sse-manager"
import { getLogger } from "../../lib/logger"
Expand Down Expand Up @@ -441,6 +444,11 @@ const InstanceShell2: Component<InstanceShellProps> = (props) => {
showCommandPalette(props.instance.id)
}

const openCurrentSessionSearch = () => {
const currentSessionId = activeSessionIdForInstance()
openSearch(props.instance.id, currentSessionId || undefined)
}

const openBackgroundOutput = (process: BackgroundProcess) => {
setSelectedBackgroundProcess(process)
setShowBackgroundOutput(true)
Expand Down Expand Up @@ -1137,6 +1145,27 @@ const InstanceShell2: Component<InstanceShellProps> = (props) => {
setRightPanelExpandedItems(values)
}

// Listen for sidebar accordion expansion requests from search system
createEffect(() => {
if (typeof window === "undefined") return

const handler = (event: Event) => {
const detail = (event as CustomEvent<SectionExpansionRequest>).detail
if (
detail.action === "expand-sidebar-accordion" &&
detail.instanceId === props.instance.id
) {
const sectionId = detail.sectionId
if (sectionId && !rightPanelExpandedItems().includes(sectionId)) {
setRightPanelExpandedItems((prev) => [...prev, sectionId])
}
}
}

window.addEventListener(SECTION_EXPANSION_EVENT, handler)
onCleanup(() => window.removeEventListener(SECTION_EXPANSION_EVENT, handler))
})

const isSectionExpanded = (id: string) => rightPanelExpandedItems().includes(id)

return (
Expand Down
Loading