nullRenderingAttachments.ts
components/messages/nullRenderingAttachments.ts
71
Lines
2257
Bytes
2
Exports
2
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with ui-flow. It contains 71 lines, 2 detected imports, and 2 detected exports.
Important relationships
- components/messages/AdvisorMessage.tsx
- components/messages/AssistantRedactedThinkingMessage.tsx
- components/messages/AssistantTextMessage.tsx
- components/messages/AssistantThinkingMessage.tsx
- components/messages/AssistantToolUseMessage.tsx
- components/messages/AttachmentMessage.tsx
- components/messages/CollapsedReadSearchContent.tsx
- components/messages/CompactBoundaryMessage.tsx
Detected exports
NullRenderingAttachmentTypeisNullRenderingAttachment
Keywords
attachmentmessagerenderattachmentmessagemessagesbeforenull_rendering_typesattachmentsnormalizedmessagetypes
Detected imports
src/utils/attachments.js../../types/message.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
import type { Attachment } from 'src/utils/attachments.js'
import type { Message, NormalizedMessage } from '../../types/message.js'
/**
* Attachment types that AttachmentMessage renders as `null` unconditionally
* (no visible output regardless of runtime state). Messages.tsx filters these
* out BEFORE the render cap / message count so invisible entries don't consume
* the 200-message render budget (CC-724).
*
* Sync is enforced by TypeScript: AttachmentMessage's switch `default:` branch
* asserts `attachment.type satisfies NullRenderingAttachmentType`. Adding a new
* Attachment type without either a case or an entry here will fail typecheck.
*/
const NULL_RENDERING_TYPES = [
'hook_success',
'hook_additional_context',
'hook_cancelled',
'command_permissions',
'agent_mention',
'budget_usd',
'critical_system_reminder',
'edited_image_file',
'edited_text_file',
'opened_file_in_ide',
'output_style',
'plan_mode',
'plan_mode_exit',
'plan_mode_reentry',
'structured_output',
'team_context',
'todo_reminder',
'context_efficiency',
'deferred_tools_delta',
'mcp_instructions_delta',
'companion_intro',
'token_usage',
'ultrathink_effort',
'max_turns_reached',
'task_reminder',
'auto_mode',
'auto_mode_exit',
'output_token_usage',
'pen_mode_enter',
'pen_mode_exit',
'verify_plan_reminder',
'current_session_memory',
'compaction_reminder',
'date_change',
] as const satisfies readonly Attachment['type'][]
export type NullRenderingAttachmentType = (typeof NULL_RENDERING_TYPES)[number]
const NULL_RENDERING_ATTACHMENT_TYPES: ReadonlySet<Attachment['type']> =
new Set(NULL_RENDERING_TYPES)
/**
* True when this message is an attachment that AttachmentMessage renders as
* null with no visible output. Messages.tsx filters these out before counting
* and before applying the 200-message render cap, so invisible hook
* attachments (hook_success, hook_additional_context, hook_cancelled) don't
* inflate the "N messages" count or eat into the render budget (CC-724).
*/
export function isNullRenderingAttachment(
msg: Message | NormalizedMessage,
): boolean {
return (
msg.type === 'attachment' &&
NULL_RENDERING_ATTACHMENT_TYPES.has(msg.attachment.type)
)
}