') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); PR-UI-DEAD-EXPORT-SWEEP-0: delete 26 unused ui.tsx exports + lock-contract by jackwener · Pull Request #325 · apache/maka · GitHub
Skip to content

PR-UI-DEAD-EXPORT-SWEEP-0: delete 26 unused ui.tsx exports + lock-contract - #325

Merged
jackwener merged 1 commit into
mainfrom
yuejing/ui-dead-export-sweep
Jun 27, 2026
Merged

PR-UI-DEAD-EXPORT-SWEEP-0: delete 26 unused ui.tsx exports + lock-contract#325
jackwener merged 1 commit into
mainfrom
yuejing/ui-dead-export-sweep

Conversation

@jackwener

Copy link
Copy Markdown
Member

Why

packages/ui/src/ui.tsx accumulated ~30 named exports that no source file outside ui.tsx itself imported. Most were Base UI primitive re-exports (DialogTrigger = BaseDialog.Trigger) or shadcn-style wrappers that components.tsx + every renderer/primitive consumer ignored. They cost autocomplete noise, bundle weight, tsc work, and design-discussion clarity ("we have a Card variant" — except nothing uses it).

This is the 清理 (cleanup) lane per WAWQAQ msg 97d44da7 ("打磨和清理和整理"). Companion to @maka-审美专家's scout note notes/punch-list-organize.md.

What

Net: −222 lines from ui.tsx (797 → 590), +112 lines for the new dead-export contract.

Deleted (no external consumer, no internal use):

  • Card family: Card, CardHeader, CardTitle, CardDescription, CardContent
  • Avatar family: Avatar, AvatarImage, AvatarFallback
  • Accordion (entire section, 5 exports): primitives/accordion.tsx already owns the alive duplicates exported as PrimitiveAccordion*
  • ScrollArea (entire section, 3 exports): primitives/scroll-area.tsx owns the alive impl
  • Popover (entire section, 6 exports): PopoverRoot/Trigger/Portal/Backdrop/Positioner/Popup
  • Dialog sub-pieces: DialogTrigger, DialogTitle, DialogDescription
  • Field sub-pieces: FieldControl, FieldError
  • Tooltip sub-pieces: TooltipRoot, TooltipPortal, TooltipPositioner
  • Sheet sub-piece: SheetRoot
  • Form re-alias of BaseForm

Demoted from export to internal const (used only inside ui.tsx by DialogContent/SheetContent/SheetPopup wrappers):

  • DialogPortal, DialogBackdrop, DialogPopup
  • SheetSide type

Also removed 6 now-unused Base UI imports (Accordion, Avatar, Form, Popover, ScrollArea, Toast) and 1 unused icon (ChevronRight).

Contract

New apps/desktop/src/main/__tests__/ui-tsx-dead-export-contract.test.ts:

  • every named export in ui.tsx must have a consumer outside ui.tsx OR be in ALLOWED_PENDING with a justification (empty by default; capped at 5)
  • second assertion prevents ALLOWED_PENDING from rotting unmaintained

Updated existing ui-tsx-design-contract.test.ts: z-50 count 5 → 4 (PopoverPopup deletion), transition-[height] entry removed (Accordion deletion).

Tests

  • npm -w @maka/ui run build — clean
  • npm -w @maka/desktop run typecheck — clean
  • npm -w @maka/desktop run test — 1578/1580 pass
    • 2 pre-existing failures (streaming-handoff, subagent-ui-contract — React useRef issues that also fail on main without these changes) are unrelated; verified by git stash + re-running on upstream/main

Scope discipline

  • Zero visual change (no consumer of the deleted symbols ever existed)
  • Zero runtime behavior change
  • components.tsxCard import removed (had been unused since the Card JSX never appeared)
  • ALLOWED_PENDING starts empty — future deviations need explicit ack

Locks the rule WAWQAQ + aesthetics expert called for: don't reintroduce dead exports in ui.tsx.

…tract
Net: -222 lines from ui.tsx (797 → 590), +112 lines for the new
dead-export contract.
Background: `packages/ui/src/ui.tsx` accumulated ~30 named exports that
no source file outside ui.tsx itself imported. Most were Base UI primitive
re-exports (`DialogTrigger = BaseDialog.Trigger`) or shadcn-style wrappers
that components.tsx + every renderer/primitive consumer ignored. They
cost autocomplete noise, bundle weight, tsc work, and design-discussion
clarity ("we have a Card variant" — except nothing uses it).
Deleted (no external consumer, no internal use):
- Card family: Card, CardHeader, CardTitle, CardDescription, CardContent
- Avatar family: Avatar, AvatarImage, AvatarFallback
- Accordion (entire section): all 5 — `packages/ui/src/primitives/accordion.tsx`
already owns the alive duplicates exported as `PrimitiveAccordion*`
- ScrollArea (entire section): ScrollAreaRoot, ScrollAreaViewport,
ScrollAreaScrollbar — `primitives/scroll-area.tsx` owns the alive impl
- Popover (entire section): PopoverRoot/Trigger/Portal/Backdrop/Positioner/Popup
- Dialog sub-pieces: DialogTrigger, DialogTitle, DialogDescription
- Field sub-pieces: FieldControl, FieldError
- Tooltip sub-pieces: TooltipRoot, TooltipPortal, TooltipPositioner
- Sheet sub-piece: SheetRoot
- Form re-alias of BaseForm
Demoted from `export` to internal `const` (used only inside ui.tsx by
DialogContent/SheetContent/SheetPopup wrappers):
- DialogPortal, DialogBackdrop, DialogPopup
- SheetSide type
Also removed 6 now-unused Base UI imports (Accordion, Avatar, Form, Popover,
ScrollArea, Toast) and 1 unused icon (`ChevronRight`).
Locked the rule with `ui-tsx-dead-export-contract.test.ts`:
- every named export in ui.tsx must have a consumer outside ui.tsx OR be
in `ALLOWED_PENDING` with a justification (empty by default; capped at 5)
- second assertion prevents `ALLOWED_PENDING` from rotting unmaintained
Updated existing `ui-tsx-design-contract.test.ts`: z-50 count 5 → 4
(PopoverPopup deletion), `transition-[height]` entry removed (Accordion
deletion).
Full desktop test suite: 1578/1580 pass. Two pre-existing failures
(streaming-handoff, subagent-ui-contract — React `useRef` issues that
also fail on main without these changes) are unrelated.
@jackwener
jackwenerforce-pushed the yuejing/ui-dead-export-sweep branch from f25a95d to dac5539CompareJune 27, 2026 12:23
@jackwener
jackwener merged commit 193d7d6 into mainJun 27, 2026
@Astro-Han
Astro-Han deleted the yuejing/ui-dead-export-sweep branch July 14, 2026 05:05
Sign up for freeto 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

@jackwener