Skip to content

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

Description

@liuxiaocs7

Context

Split from the review of #4655 (P3, deferred). The side-chat panel needed the main chat's rising-edge running-status timing — useDelayedFlag + the 200ms delay — but the workbar feature layer cannot import the renderer-legacyuse-delayed-flag.ts / model-wait-state.ts (the renderer-architecture gate walls feature code 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.

That leaves:

  • Two authorities for one delay/timing — the panel's copy will drift from the main chat's useDelayedFlag.
  • A duplicated literal (200) with no single source of truth.
  • No unit-test coverage for the timing on the side-chat path (and, in fact, createDelayedFlag has no fake-timer tests anywhere today).

Proposal

Lift the shared pieces into @maka/ui so both sides import one implementation:

  • Move the pure createDelayedFlag (+ DelayedFlag, DelayedFlagScheduler) out of apps/desktop/src/renderer/model-wait-state.ts and the useDelayedFlag React binding out of apps/desktop/src/renderer/use-delayed-flag.ts into a new @maka/ui module; export a shared RUNNING_STATUS_DELAY_MS.
  • Update the main chat (use-shell-live-turn.ts) and the side chat (quote-companion-panel.tsx) to import from @maka/ui; delete the feature-local copy + literal.
  • Re-export from the legacy modules where needed for back-compat / minimal churn.
  • Add fake-timer unit tests for createDelayedFlag in @maka/ui (rising-edge delay, no-flash on a fast drop, immediate fall).

Benefits

  • One authority for the running-status timing and delay constant.
  • Removes the feature→renderer-legacy walled-off duplication — should take the use-delayed-flag.ts / model-wait-state.ts closure entries off the renderer-architecture ledger.
  • Establishes the timing unit-test coverage that's missing today.

Origin: #4655 review by @Astro-Han.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions