forked from ultraworkers/claw-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnullRenderingAttachments.ts
More file actions
70 lines (66 loc) · 2.2 KB
/
Copy pathnullRenderingAttachments.ts
File metadata and controls
70 lines (66 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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)
)
}