MCPcopy
hub / github.com/deepnote/deepnote / getBlockLabel

Function getBlockLabel

packages/cli/src/utils/block-label.ts:10–47  ·  view source on GitHub ↗
(block: DeepnoteBlock)

Source from the content-addressed store, hash-verified

8 * Returns a meaningful preview of the block content.
9 */
10export 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.

Callers 7

checkForIssuesFunction · 0.90
buildBlockMapFunction · 0.90
analyzeDagFunction · 0.90
collectExecutableBlocksFunction · 0.90
outputCatJsonFunction · 0.90

Calls 6

shortIdFunction · 0.85
getAgentBlockLabelFunction · 0.85
getCodeBlockLabelFunction · 0.85
getSqlBlockLabelFunction · 0.85
getMarkdownBlockLabelFunction · 0.85
getTextCellLabelFunction · 0.85

Tested by

no test coverage detected