(block: DeepnoteBlock)
| 8 | * Returns a meaningful preview of the block content. |
| 9 | */ |
| 10 | export function getBlockLabel(block: DeepnoteBlock): string { |
| 11 | // For input blocks, show variable name |
| 12 | if (block.type.startsWith('input-')) { |
| 13 | const metadata = block.metadata as { deepnote_variable_name?: string } | undefined |
| 14 | if (metadata?.deepnote_variable_name) { |
| 15 | return metadata.deepnote_variable_name |
| 16 | } |
| 17 | return `input (${shortId(block.id)})` |
| 18 | } |
| 19 | |
| 20 | // For agent blocks, show first line of prompt |
| 21 | if (block.type === 'agent') { |
| 22 | return getAgentBlockLabel(block.content ?? '') |
| 23 | } |
| 24 | |
| 25 | // For code blocks, show first comment or first line of code |
| 26 | if (block.type === 'code') { |
| 27 | return getCodeBlockLabel(block.content ?? '') |
| 28 | } |
| 29 | |
| 30 | // For SQL blocks, show first line of query |
| 31 | if (block.type === 'sql') { |
| 32 | return getSqlBlockLabel(block.content ?? '') |
| 33 | } |
| 34 | |
| 35 | // For markdown blocks, show first line |
| 36 | if (block.type === 'markdown') { |
| 37 | return getMarkdownBlockLabel(block.content ?? '') |
| 38 | } |
| 39 | |
| 40 | // For text cell blocks (h1, h2, h3, p, bullet, etc.), show content |
| 41 | if (block.type.startsWith('text-cell-')) { |
| 42 | return getTextCellLabel(block.content ?? '', block.type) |
| 43 | } |
| 44 | |
| 45 | // Default: show type and short ID |
| 46 | return `${block.type} (${shortId(block.id)})` |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Get label for an agent block - show first non-empty line of the prompt. |
no test coverage detected