Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:23blocks OS Ai maestro Chat Utils

From Leeroopedia
Knowledge Sources
Domains Chat, UI
Last Updated 2026-10-26 18:00 GMT

Overview

Concrete tool for shared chat view utilities — tool burst grouping, tool preview generation, and path shortening — used by both ChatView and MobileChatView, provided by AI Maestro's `lib/chat-utils.ts`.

Description

The chat-utils module provides shared utilities for the chat view. `groupToolBursts` collapses consecutive tool-only messages into a single `ToolBurst` (with tool names and counts), reducing noise in the conversation view. `shortenPath` shortens a file path to the last 3 segments. Tool preview text generation produces a one-line summary of a tool call. These utilities are shared between `ChatView.tsx` and `MobileChatView.tsx`.

Usage

Call `groupToolBursts(messages)` before rendering. Use `shortenPath(path)` in tool output previews.

Code Reference

Source Location

  • Repository: ai-maestro
  • File: lib/chat-utils.ts
  • Lines: L1-L226

Signature

export interface ToolBurst { _isBurst: true; messages: Message[]; tools: { name: string; count: number }[]; totalCount: number }
export type GroupedItem = Message | ToolBurst

export function shortenPath(p: string): string
export function groupToolBursts(messages: Message[]): GroupedItem[]
export function getToolPreview(message: Message): string

Import

import { groupToolBursts, shortenPath, getToolPreview } from '@/lib/chat-utils'

I/O Contract

Name Type Description
groupToolBursts() returns GroupedItem[] Messages with consecutive tools collapsed into bursts
shortenPath() returns string Path shortened to last 3 segments

Usage Examples

import { groupToolBursts } from '@/lib/chat-utils'

const grouped = groupToolBursts(messages)
for (const item of grouped) {
  if ('_isBurst' in item) {
    console.log(`Tool burst: ${item.tools.map(t => t.name).join(', ')}`)
  } else {
    console.log(item.content)
  }
}

Related Pages

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment