Skip to content

refactor: extract PromiseGuard and DebouncerMap shared utilities#6566

Merged
siddseethepalli merged 1 commit into
mainfrom
do/extract-shared-utilities
Feb 22, 2026
Merged

refactor: extract PromiseGuard and DebouncerMap shared utilities#6566
siddseethepalli merged 1 commit into
mainfrom
do/extract-shared-utilities

Conversation

@siddseethepalli
Copy link
Copy Markdown
Contributor

@siddseethepalli siddseethepalli commented Feb 22, 2026

Summary

  • Extract PromiseGuard<T> utility that deduplicates concurrent async factory calls with automatic clear-on-failure, replacing hand-rolled initPromise patterns in parser.ts, embedding-local.ts, and git-service.ts
  • Extract Debouncer (single-key) and DebouncerMap (multi-key with limit enforcement and protected key prefixes) utilities, replacing manual setTimeout/clearTimeout patterns in HookManager, DaemonServer, and all handler files
  • Net reduction of ~70 lines across 16 files while improving consistency and reducing duplication

Original prompt

Extract shared utility patterns (PromiseGuard, Debounce) — Promise guard logic is duplicated in LazyTool, sessionCreating map, and elsewhere. Debounce patterns duplicated in HookManager and DaemonServer. Extract to shared utilities.

🤖 Generated with Claude Code


Open with Devin

Extract duplicated concurrency patterns into reusable utilities:
- PromiseGuard: deduplicates concurrent async init (parser, embedding, git-service)
- Debouncer: single-key debounce (HookManager)
- DebouncerMap: keyed debounce with limit enforcement (DaemonServer, handlers)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@siddseethepalli siddseethepalli merged commit a3fe247 into main Feb 22, 2026
@siddseethepalli siddseethepalli deleted the do/extract-shared-utilities branch February 22, 2026 08:26
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

noanflaherty added a commit that referenced this pull request May 12, 2026
Follow-up to the catalog-driven auth refactor (#30411 in this same
branch + #6566 on the web side). The codebase has been using two
words for the same concept:

  - User-facing UI:          'Platform (managed by Vellum)'
  - Auth-type wire value:    'platform'  (AuthType.platform on Swift,
                                          "platform" in TS connection JSON)
  - Internal symbols:        MANAGED_PROVIDER_META, supportsManagedAuth,
                             isManagedCapable, managedCapableProviders,
                             managed-proxy/ directory

This commit aligns the internal symbols with the user-facing 'platform'
terminology so future readers don't have to mentally translate.

Renames
-------
Symbols (word-boundary-safe sed across .ts/.swift/.tsx/.json):

  MANAGED_PROVIDER_META      -> PLATFORM_PROVIDER_META
  supportsManagedAuth        -> supportsPlatformAuth
  isManagedCapable           -> isPlatformCapable
  managedCapableProviders    -> platformCapableProviders

Files / paths:

  assistant/src/providers/managed-proxy/   -> .../platform-proxy/
  assistant/src/__tests__/managed-proxy-context.test.ts
    -> .../platform-proxy-context.test.ts
  assistant/src/__tests__/provider-managed-proxy-integration.test.ts
    -> .../provider-platform-proxy-integration.test.ts
  assistant/src/__tests__/secret-routes-managed-proxy.test.ts
    -> .../secret-routes-platform-proxy.test.ts

Import-path string substitutions inside source files:
  './managed-proxy/...'  -> './platform-proxy/...'

What is NOT renamed (out of scope)
----------------------------------
* User-facing copy 'Platform (managed by Vellum)' — that's the UX
  label disambiguating what 'Platform' means; renaming would degrade
  clarity for end users.
* Runtime routing-source discriminator string 'managed-proxy' — used
  in ProviderRoutingSource union type and several runtime checks.
  Leaving for a separate follow-up if Noa wants it tightened.
* MANAGED_USAGE_LIMIT error code — wire-format contract with the
  macOS/iOS clients; out-of-scope structural rename.
* ManagedProxyCredentials / ManagedProxyContext type names — left
  for a separate follow-up.

Test
----
* bunx tsc --noEmit on assistant/ — clean.
* bun test platform-proxy-context, provider-platform-proxy-integration,
  secret-routes-platform-proxy, llm-catalog-parity, satellite-connection-routing,
  credential-security-invariants — 110 tests pass.
* bun run scripts/sync-llm-catalog.ts --check — clean.
credence-the-bot Bot pushed a commit that referenced this pull request May 13, 2026
Follow-up to the catalog-driven auth refactor (#30411 in this same
branch + #6566 on the web side). The codebase has been using two
words for the same concept:

  - User-facing UI:          'Platform (managed by Vellum)'
  - Auth-type wire value:    'platform'  (AuthType.platform on Swift,
                                          "platform" in TS connection JSON)
  - Internal symbols:        MANAGED_PROVIDER_META, supportsManagedAuth,
                             isManagedCapable, managedCapableProviders,
                             managed-proxy/ directory

This commit aligns the internal symbols with the user-facing 'platform'
terminology so future readers don't have to mentally translate.

Renames
-------
Symbols (word-boundary-safe sed across .ts/.swift/.tsx/.json):

  MANAGED_PROVIDER_META      -> PLATFORM_PROVIDER_META
  supportsManagedAuth        -> supportsPlatformAuth
  isManagedCapable           -> isPlatformCapable
  managedCapableProviders    -> platformCapableProviders

Files / paths:

  assistant/src/providers/managed-proxy/   -> .../platform-proxy/
  assistant/src/__tests__/managed-proxy-context.test.ts
    -> .../platform-proxy-context.test.ts
  assistant/src/__tests__/provider-managed-proxy-integration.test.ts
    -> .../provider-platform-proxy-integration.test.ts
  assistant/src/__tests__/secret-routes-managed-proxy.test.ts
    -> .../secret-routes-platform-proxy.test.ts

Import-path string substitutions inside source files:
  './managed-proxy/...'  -> './platform-proxy/...'

What is NOT renamed (out of scope)
----------------------------------
* User-facing copy 'Platform (managed by Vellum)' — that's the UX
  label disambiguating what 'Platform' means; renaming would degrade
  clarity for end users.
* Runtime routing-source discriminator string 'managed-proxy' — used
  in ProviderRoutingSource union type and several runtime checks.
  Leaving for a separate follow-up if Noa wants it tightened.
* MANAGED_USAGE_LIMIT error code — wire-format contract with the
  macOS/iOS clients; out-of-scope structural rename.
* ManagedProxyCredentials / ManagedProxyContext type names — left
  for a separate follow-up.

Test
----
* bunx tsc --noEmit on assistant/ — clean.
* bun test platform-proxy-context, provider-platform-proxy-integration,
  secret-routes-platform-proxy, llm-catalog-parity, satellite-connection-routing,
  credential-security-invariants — 110 tests pass.
* bun run scripts/sync-llm-catalog.ts --check — clean.
credence-the-bot Bot pushed a commit that referenced this pull request May 13, 2026
Follow-up to the catalog-driven auth refactor (#30411 in this same
branch + #6566 on the web side). The codebase has been using two
words for the same concept:

  - User-facing UI:          'Platform (managed by Vellum)'
  - Auth-type wire value:    'platform'  (AuthType.platform on Swift,
                                          "platform" in TS connection JSON)
  - Internal symbols:        MANAGED_PROVIDER_META, supportsManagedAuth,
                             isManagedCapable, managedCapableProviders,
                             managed-proxy/ directory

This commit aligns the internal symbols with the user-facing 'platform'
terminology so future readers don't have to mentally translate.

Renames
-------
Symbols (word-boundary-safe sed across .ts/.swift/.tsx/.json):

  MANAGED_PROVIDER_META      -> PLATFORM_PROVIDER_META
  supportsManagedAuth        -> supportsPlatformAuth
  isManagedCapable           -> isPlatformCapable
  managedCapableProviders    -> platformCapableProviders

Files / paths:

  assistant/src/providers/managed-proxy/   -> .../platform-proxy/
  assistant/src/__tests__/managed-proxy-context.test.ts
    -> .../platform-proxy-context.test.ts
  assistant/src/__tests__/provider-managed-proxy-integration.test.ts
    -> .../provider-platform-proxy-integration.test.ts
  assistant/src/__tests__/secret-routes-managed-proxy.test.ts
    -> .../secret-routes-platform-proxy.test.ts

Import-path string substitutions inside source files:
  './managed-proxy/...'  -> './platform-proxy/...'

What is NOT renamed (out of scope)
----------------------------------
* User-facing copy 'Platform (managed by Vellum)' — that's the UX
  label disambiguating what 'Platform' means; renaming would degrade
  clarity for end users.
* Runtime routing-source discriminator string 'managed-proxy' — used
  in ProviderRoutingSource union type and several runtime checks.
  Leaving for a separate follow-up if Noa wants it tightened.
* MANAGED_USAGE_LIMIT error code — wire-format contract with the
  macOS/iOS clients; out-of-scope structural rename.
* ManagedProxyCredentials / ManagedProxyContext type names — left
  for a separate follow-up.

Test
----
* bunx tsc --noEmit on assistant/ — clean.
* bun test platform-proxy-context, provider-platform-proxy-integration,
  secret-routes-platform-proxy, llm-catalog-parity, satellite-connection-routing,
  credential-security-invariants — 110 tests pass.
* bun run scripts/sync-llm-catalog.ts --check — clean.
noanflaherty added a commit that referenced this pull request May 13, 2026
…#30432)

* refactor(providers): rename managed→platform for catalog auth symbols

Follow-up to the catalog-driven auth refactor (#30411 in this same
branch + #6566 on the web side). The codebase has been using two
words for the same concept:

  - User-facing UI:          'Platform (managed by Vellum)'
  - Auth-type wire value:    'platform'  (AuthType.platform on Swift,
                                          "platform" in TS connection JSON)
  - Internal symbols:        MANAGED_PROVIDER_META, supportsManagedAuth,
                             isManagedCapable, managedCapableProviders,
                             managed-proxy/ directory

This commit aligns the internal symbols with the user-facing 'platform'
terminology so future readers don't have to mentally translate.

Renames
-------
Symbols (word-boundary-safe sed across .ts/.swift/.tsx/.json):

  MANAGED_PROVIDER_META      -> PLATFORM_PROVIDER_META
  supportsManagedAuth        -> supportsPlatformAuth
  isManagedCapable           -> isPlatformCapable
  managedCapableProviders    -> platformCapableProviders

Files / paths:

  assistant/src/providers/managed-proxy/   -> .../platform-proxy/
  assistant/src/__tests__/managed-proxy-context.test.ts
    -> .../platform-proxy-context.test.ts
  assistant/src/__tests__/provider-managed-proxy-integration.test.ts
    -> .../provider-platform-proxy-integration.test.ts
  assistant/src/__tests__/secret-routes-managed-proxy.test.ts
    -> .../secret-routes-platform-proxy.test.ts

Import-path string substitutions inside source files:
  './managed-proxy/...'  -> './platform-proxy/...'

What is NOT renamed (out of scope)
----------------------------------
* User-facing copy 'Platform (managed by Vellum)' — that's the UX
  label disambiguating what 'Platform' means; renaming would degrade
  clarity for end users.
* Runtime routing-source discriminator string 'managed-proxy' — used
  in ProviderRoutingSource union type and several runtime checks.
  Leaving for a separate follow-up if Noa wants it tightened.
* MANAGED_USAGE_LIMIT error code — wire-format contract with the
  macOS/iOS clients; out-of-scope structural rename.
* ManagedProxyCredentials / ManagedProxyContext type names — left
  for a separate follow-up.

Test
----
* bunx tsc --noEmit on assistant/ — clean.
* bun test platform-proxy-context, provider-platform-proxy-integration,
  secret-routes-platform-proxy, llm-catalog-parity, satellite-connection-routing,
  credential-security-invariants — 110 tests pass.
* bun run scripts/sync-llm-catalog.ts --check — clean.

* style(providers): re-sort imports after managed→platform rename

The rename in the parent commit shifted import path prefixes
(`managed-proxy/*` → `platform-proxy/*`), which puts them later
in the alphabetical order simple-import-sort enforces.

* assistant/src/__tests__/llm-catalog-parity.test.ts: swap
  PROVIDER_CATALOG / PLATFORM_PROVIDER_META order so `model-catalog`
  (m) precedes `platform-proxy/constants` (p).
* assistant/src/providers/registry.ts: move the
  `./platform-proxy/context.js` import block after `./model-intents.js`
  for the same reason.

Test
----
* bunx tsc --noEmit clean.
* No behavior change.

* chore(openapi): regenerate spec to include /v1/skills/import

The skills-import route handler shipped in #29915 but openapi.yaml was
not regenerated as part of that merge. Rebasing #30432 onto main surfaces
the staleness via the OpenAPI Spec Check job. Pure regen — no code
change in this commit.

---------

Co-authored-by: credence-the-bot[bot] <226841098+credence-the-bot[bot]@users.noreply.github.com>
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