Skip to content

Commit dbe55c5

Browse files
committed
feat(tui): add expandable topic list in sidebar
1 parent 903ea8c commit dbe55c5

3 files changed

Lines changed: 19 additions & 12 deletions

File tree

tui/data/context.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export const createPlaceholderContextSnapshot = (
2828
available: false,
2929
activeBlockCount: 0,
3030
activeBlocks: [],
31-
activeBlockTopicTotal: 0,
3231
},
3332
messageStatuses: [],
3433
allTimeStats: { totalTokensSaved: 0, sessionCount: 0 },
@@ -88,8 +87,6 @@ const loadContextSnapshot = async (
8887
.map((blockID) => state.prune.messages.blocksById.get(blockID))
8988
.filter((block): block is NonNullable<typeof block> => !!block && !!block.topic)
9089
.map((block) => ({ topic: block.topic, summary: cleanBlockSummary(block.summary) }))
91-
const blocks = allBlocks.slice(0, 5)
92-
const topicTotal = allBlocks.length
9390

9491
const notes: string[] = []
9592
if (persisted) {
@@ -107,8 +104,7 @@ const loadContextSnapshot = async (
107104
persisted: {
108105
available: !!persisted,
109106
activeBlockCount: state.prune.messages.activeBlockIds.size,
110-
activeBlocks: blocks,
111-
activeBlockTopicTotal: topicTotal,
107+
activeBlocks: allBlocks,
112108
lastUpdated: persisted?.lastUpdated,
113109
},
114110
messageStatuses,

tui/shared/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export interface DcpPersistedSummary {
1717
available: boolean
1818
activeBlockCount: number
1919
activeBlocks: DcpActiveBlockInfo[]
20-
activeBlockTopicTotal: number
2120
lastUpdated?: string
2221
}
2322

tui/slots/sidebar-top.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,13 @@ const SidebarContext = (props: {
283283
),
284284
)
285285

286-
const blocks = createMemo(() => snapshot().persisted.activeBlocks)
287-
const topicTotal = createMemo(() => snapshot().persisted.activeBlockTopicTotal)
288-
const topicOverflow = createMemo(() => topicTotal() - blocks().length)
286+
const TOPIC_LIMIT = 3
287+
const allBlocks = createMemo(() => snapshot().persisted.activeBlocks)
288+
const [topicsExpanded, setTopicsExpanded] = createSignal(false)
289+
const blocks = createMemo(() =>
290+
topicsExpanded() ? allBlocks() : allBlocks().slice(0, TOPIC_LIMIT),
291+
)
292+
const topicOverflow = createMemo(() => allBlocks().length - TOPIC_LIMIT)
289293

290294
const navigateToSummary = (block: DcpActiveBlockInfo) => {
291295
props.api.route.navigate(props.names.routes.summary, {
@@ -419,12 +423,20 @@ const SidebarContext = (props: {
419423
<box flexDirection="row" width="100%" height={1}>
420424
<box flexGrow={1} flexShrink={1} height={1}>
421425
<text {...DIM_TEXT} fg={props.palette.muted}>
422-
... {topicOverflow()} more topics
426+
{topicsExpanded()
427+
? `showing all ${allBlocks().length} topics`
428+
: `... ${topicOverflow()} more topics`}
423429
</text>
424430
</box>
425431
<box flexShrink={0} height={1} paddingLeft={1}>
426-
<box backgroundColor={props.palette.base} height={1}>
427-
<text fg={props.palette.accent}></text>
432+
<box
433+
backgroundColor={props.palette.base}
434+
height={1}
435+
onMouseUp={() => setTopicsExpanded(!topicsExpanded())}
436+
>
437+
<text fg={props.palette.accent}>
438+
{topicsExpanded() ? " ▲ " : " ▼ "}
439+
</text>
428440
</box>
429441
</box>
430442
</box>

0 commit comments

Comments
 (0)