Skip to content

Visual artifacts when configuring package extensions with multi-line tool descriptions #14

Description

@joshuajbrunner

Description

When running /extensions and pressing c to configure extensions for pi-subagents, the configuration panel displays visual artifacts:

  1. Tool description text ("EXECUTION (use exactly ON...") appears on separate lines
  2. List items appear duplicated multiple times

Root Cause

In src/utils/fs.ts, the readSummary() function extracts tool descriptions using regex:

const descriptionPatterns = [
  /registerCommand\(\s*["'`][^"'`]+["'`]\s*,\s*\{[\s\S]*?description\s*:\s*["'`]([^"'`]+)["'`]/m,
  /registerTool\(\s*\{[\s\S]*?description\s*:\s*["'`]([^"'`]+)["'`]/m,
  /description\s*:\s*["'`]([^"'`]+)["'`]/m,
];

The character class [^"']` matches any character except quotes, including newlines. For extensions with multi-line template literal descriptions (like pi-subagents):

description: `Delegate to subagents or manage agent definitions.

EXECUTION (use exactly ONE mode):
• SINGLE: { agent, task } - one task
...`

The extracted summary becomes:

"Delegate to subagents or manage agent definitions.\n\nEXECUTION (use exactly ON..."

The truncate() function only checks text.length, preserving embedded newlines. When rendered in the SettingsList label, the \n\n causes text to break across multiple lines, corrupting the TUI layout.

Steps to Reproduce

  1. Install pi-subagents package
  2. Run /extensions
  3. Navigate to pi-subagents and press c to configure
  4. Visual artifacts appear in the configuration panel

Suggested Fix

Normalize extracted text in readSummary() before truncating:

function normalizeSummary(text: string): string {
  return text.replace(/[\r\n]+/g, " ").replace(/\s+/g, " ").trim();
}

// Then use:
if (value) return truncate(normalizeSummary(value), 80);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions