Skip to content

Trim dead exports and consolidate duplicated helpers - #85

Merged
Juliusolsson05 merged 1 commit into
mainfrom
cleanup/tier1-dead-exports-v2
May 13, 2026
Merged

Juliusolsson05 merged 1 commit into
mainfrom
cleanup/tier1-dead-exports-v2

Conversation

@Juliusolsson05

Copy link
Copy Markdown
Owner

Summary

Salvages the high-signal portion of the parked cleanup/tier1-dead-exports branch (commit e2285b3, May 12), re-derived on top of post-rename main. No "cc-shell" strings introduced.

Two threads of cleanup land together.

Dead exports / dead returns

File Change
src/main/window/mainWindow.ts Delete getMainWindow() — zero importers (internal or external).
src/main/sessionManager.ts Privatize ManagerEvents, SpawnOptions, SpawnResult. Consumed only by the EventEmitter overloads in the same file.
src/renderer/.../claudeImages.ts Privatize 5 internal-only symbols. Public surface is just the predicates and ingress functions.
src/providers/claude/runtime/claudeSession.ts Remove terminalToMarkdown re-export — compat shim with zero callers; real definition is in src/shared/runtime/ptyScreen.ts.
src/renderer/.../useClaudeImagePaste.ts Drop appendDraftImages from hook return. Only caller (TileLeaf) destructures handlePaste + removeDraftImage only.
src/providers/codex/types/codexTranscript.ts Delete unused CodexSessionMeta, CodexResponseItem, CodexEventMsg, isCodexConversationEntry. Zero external imports.

New shared helpers + dedup call sites

Five new modules replace hand-duplicated copies on main:

Helper Replaces
src/renderer/src/lib/relativeTime.ts 4 copies (PathPickerModal, PromptSearchModal, AgentActivityModal, WorktreesBar).
src/renderer/.../features/workspace/lib/sessionDisplay.ts (cwdBasename + providerGlyph) 2 copies each.
src/renderer/.../features/system-perf/formatBytes.ts 2 copies (SystemPerfBadge, SystemPerfPopover).
src/renderer/.../workspace/codex/eventCursor.ts (codexTurnIdFromEventPayload + codexEventType) 3 copies (history.ts, initialHistory.ts, useIpcSubscriptions.ts).
src/shared/lib/asRecord.ts 2 copies (workspace/codex/rollout.ts, providers/codex/renderer/rows/CodexRows.tsx).

One semantic delta worth flagging

CodexRows.tsx's local asRecord did NOT exclude arrays. The shared helper does. Every call site there uses .raw / .input property reads that would be undefined on arrays anyway, so the stricter check is a free safety improvement, documented in a WHY-comment at the import.

A handful of UI surfaces will also pick up a 'just now' label for sub-5s timestamps (they previously rendered 1s ago / 2s ago). Softer UX, no regression risk.

Why salvaged, not rebased

Same reason as PR #84 — the parked branch was authored before the cc-shell → agent-code rename and would reintroduce "cc-shell" strings across README, package.json, CLAUDE.md, AGENTS.md, etc. The intent was extracted and re-applied carefully on current main.

Test plan

  • npm run test:review-fixes (settings, prompt-templates, session-ownership) — pass
  • npm run test:work-context — pass
  • npm run build:app — pass
  • git diff main | grep -ic 'cc-shell' — 0
  • Manual: open command palette → Agent Activity, Prompt Search, Path Picker, Worktrees bar; verify relative times render and provider glyphs look right
  • Manual: paste an image in a Claude composer to confirm image-paste still works after appendDraftImages was made internal

Stats

17 modified + 5 new files, +88/-263.

🤖 Generated with Claude Code

Salvages the high-signal portion of the parked
`cleanup/tier1-dead-exports` branch (commit `e2285b3`, May 12),
re-derived on top of post-rename `main`. No "cc-shell" strings
introduced.

Two threads of cleanup land together.

## Dead exports / dead returns

- src/main/window/mainWindow.ts — delete `getMainWindow()` (zero
  importers internal or external).
- src/main/sessionManager.ts — privatize `ManagerEvents`,
  `SpawnOptions`, `SpawnResult`. These three types are consumed only
  by the EventEmitter overloads on the SessionManager interface in
  the same file. WHY-comments capture why they should stay private.
- src/renderer/.../claudeImages.ts — privatize 5 internal-only
  symbols: `MAX_CLAUDE_IMAGE_BYTES`, `SUPPORTED_CLAUDE_IMAGE_MEDIA_TYPES`,
  `fileToDataUrl`, `parseDataUrl`, `estimateBase64DecodedBytes`. The
  only consumer (useClaudeImagePaste) only pulls the predicates and
  ingress functions. WHY-comment documents the public surface.
- src/providers/claude/runtime/claudeSession.ts — remove the
  `terminalToMarkdown` re-export. It was a compat shim from when the
  function lived inline; today its sole definition is in
  src/shared/runtime/ptyScreen.ts and nothing imports it via
  claudeSession. HISTORICAL note left in place.
- src/renderer/.../useClaudeImagePaste.ts — drop `appendDraftImages`
  from the hook's return object. The only caller (TileLeaf) only
  destructures `handlePaste` and `removeDraftImage`; the append
  helper is purely internal now (paste-only ingress).
- src/providers/codex/types/codexTranscript.ts — delete unused
  `CodexSessionMeta`, `CodexResponseItem`, `CodexEventMsg` types and
  the `isCodexConversationEntry` guard. Zero external imports;
  consumers handle `payload: unknown` with inline narrowing.

## New shared helpers + dedup call sites

Five new modules replace hand-duplicated copies:

- src/renderer/src/lib/relativeTime.ts — replaces 4 copies in
  PathPickerModal, PromptSearchModal, AgentActivityModal, and
  WorktreesBar. Picked the most complete variant (years + 'just now'
  branch). UX delta for callers that lacked 'just now': fresh
  timestamps now show 'just now' instead of '2s ago' — softer, no
  regression risk.
- src/renderer/.../features/workspace/lib/sessionDisplay.ts —
  consolidates `cwdBasename` + `providerGlyph` from AgentActivityModal
  and PromptSearchModal. Wider provider signature (claude|codex|terminal)
  so the agent-activity surface doesn't have to special-case.
- src/renderer/.../features/system-perf/formatBytes.ts — consolidates
  the two badge/popover copies of the SI byte formatter. Tunable
  `fractionDigits = 2` default.
- src/renderer/.../workspace/codex/eventCursor.ts —
  `codexTurnIdFromEventPayload` + `codexEventType`, replacing three
  copies across history.ts / initialHistory.ts / useIpcSubscriptions.ts.
  WHY-comment captures why the payload-level turn_id is load-bearing
  fallback evidence (pagination + IPC bursts can start after the
  defining `turn_context`).
- src/shared/lib/asRecord.ts — shared unknown-JSON narrowing helper.
  Replaces two copies in workspace/codex/rollout.ts and
  providers/codex/renderer/rows/CodexRows.tsx. NOTE: CodexRows' local
  copy did NOT exclude arrays — replacing with the stricter shared
  helper means arrays now return null. Every call site uses `.raw` /
  `.input` property reads that would be undefined on arrays anyway,
  so this is a free safety improvement, documented in a WHY-comment
  at the import.

## Verification

- npm run test:review-fixes — settings/prompt-templates/session-ownership all green
- npm run test:work-context — green
- npm run build:app — green
- git diff main | grep -ic "cc-shell" — 0

17 modified + 5 new files, +88/-263.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Juliusolsson05
Juliusolsson05 merged commit 5b5637d into main May 13, 2026
@Juliusolsson05
Juliusolsson05 deleted the cleanup/tier1-dead-exports-v2 branch July 7, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant