Skip to content

refactor(ui): lift useDelayedFlag/createDelayedFlag into @maka/ui - #4848

Closed
liuxiaocs7 wants to merge 1 commit into
apache:mainfrom
liuxiaocs7:refactor/delayed-flag-to-ui
Closed

refactor(ui): lift useDelayedFlag/createDelayedFlag into @maka/ui#4848
liuxiaocs7 wants to merge 1 commit into
apache:mainfrom
liuxiaocs7:refactor/delayed-flag-to-ui

Conversation

@liuxiaocs7

Copy link
Copy Markdown
Member

Summary

Split from the review of #4655 (P3) — tracked in #4844.

The side-conversation panel needed the main chat's rising-edge running-status timing (useDelayedFlag + the 200ms delay), but the workbar feature layer can't import the renderer-legacyuse-delayed-flag.ts / model-wait-state.ts (the renderer-architecture gate walls features off from legacy). So #4655 added a feature-local copy of useDelayedFlag and a const RUNNING_STATUS_DELAY_MS = 200 to quote-companion-panel.tsx — two authorities for one delay, a literal that would drift, and no timing tests.

This lifts the shared pieces into a new @maka/uidelayed-flag module:

  • createDelayedFlag (+ DelayedFlag, DelayedFlagScheduler) — moved out of model-wait-state.ts.
  • useDelayedFlag React binding — moved out of use-delayed-flag.ts (deleted).
  • RUNNING_STATUS_DELAY_MS — one shared delay.

The main chat (use-shell-live-turn) and the side chat (quote-companion-panel) now import one implementation; the feature-local copy is gone. The use-delayed-flag.ts closure drops off the renderer-architecture ledger (net debt reduction).

No behavior change — the timing implementation is identical, just relocated to a package both sides may import.

Fixes#4844

Verification

Local (all pass):

  • tsc renderer + main, @maka/ui build — 0 errors.
  • biome check — clean; knip (apps/desktop + packages/ui) — clean.
  • check:architecture — renderer snapshot + monotonic-debt ratchet pass (debt down: 1 insertion / 21 deletions in the ledger).
  • Newpackages/ui/src/__tests__/delayed-flag.test.ts — 5 fake-timer cases (rising-edge delay, no-flash on a fast drop, immediate fall, single-arm re-entrancy, dispose cancels). createDelayedFlag had no tests before.
  • Desktop companion + workbar + chat-view suites — 83/83.
  • Full desktop e2e — 77 passed / 1 skipped / 0 failed (running-status in both the main and side chat unchanged).

AI use

  • Generative tooling made a substantive contribution

Tool(s) and scope: Claude Code — investigation, implementation, and local verification. The commit carries a Generated-by: Claude Code trailer.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes
  • No — behavior-preserving refactor (shared timing relocated to @maka/ui)

The side-conversation panel needed the main chat's rising-edge running-status
timing (useDelayedFlag + the 200ms delay), but the workbar feature layer cannot
import the renderer-legacy use-delayed-flag.ts / model-wait-state.ts (the
architecture gate walls features off from legacy), so apache#4655 added a feature-local
copy of useDelayedFlag and a `const RUNNING_STATUS_DELAY_MS = 200` to
quote-companion-panel.tsx — two authorities for one delay, a literal that would
drift, and no test coverage for the timing.
Move the pure createDelayedFlag (+ DelayedFlag, DelayedFlagScheduler), the
useDelayedFlag React binding, and RUNNING_STATUS_DELAY_MS into a new @maka/ui
`delayed-flag` module. The main chat (use-shell-live-turn) and the side chat
(quote-companion-panel) now import one implementation; the feature-local copy
and the renderer-legacy use-delayed-flag.ts are removed. Adds fake-timer unit
tests for createDelayedFlag (there were none), and drops the use-delayed-flag.ts
closure from the renderer-architecture ledger (net debt reduction).
Fixesapache#4844
Generated-by: Claude Code
@github-actionsgithub-actionsBot added the effort/M Under 500 readable lines label Sep 5, 2026
@liuxiaocs7

Copy link
Copy Markdown
MemberAuthor

Closing — blocked by the renderer-architecture monotonic-debt ratchet.

The main chat's consumer use-shell-live-turn.ts is a frozen legacy file with no @maka/ui edge in the base ledger. The ratchet lets a legacy file lose dependencies but never gain one (there's no migration-swap exemption for the legacy zone), so pointing it at a lifted @maka/ui module fails CI with use-shell-live-turn.ts: new dependency debt @maka/ui. Routing the re-export through use-delayed-flag.ts / model-wait-state.ts doesn't help — neither carries an @maka/ui edge in the base either.

Making it legal would require migrating a 4-file legacy closure — use-shell-live-turn + model-wait-state + live-turn-snapshot + session-event-health — out of the legacy zone across shell / @maka/core / @maka/ui, updating ~6 importers (the app-shell family + a feature) and 2 tests. That's disproportionate to de-duplicating a ~30-line rising-edge timer, so we're not pursuing it. See #4844.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/MUnder 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lift useDelayedFlag/createDelayedFlag into @maka/ui (dedupe side-chat running-status timing)

1 participant

@liuxiaocs7