Skip to content

fix(cron): heartbeat merge inferred false | AgentEntry and broke type-check#30048

Closed
xinhuagu wants to merge 0 commit intoopenclaw:mainfrom
xinhuagu:fix/cron-agententry-typecheck
Closed

fix(cron): heartbeat merge inferred false | AgentEntry and broke type-check#30048
xinhuagu wants to merge 0 commit intoopenclaw:mainfrom
xinhuagu:fix/cron-agententry-typecheck

Conversation

@xinhuagu
Copy link
Contributor

@xinhuagu xinhuagu commented Feb 28, 2026

Summary

  • fix typing regression in server-cron heartbeat config merge
  • keep agentEntry as AgentEntry | undefined (not false | AgentEntry)
  • preserve existing runtime behavior

Change

  • replace && assignment with ternary returning undefined when agents.list is not an array

Validation

  • local format/lint for touched file passed
  • full pnpm check is currently blocked in this environment by unrelated missing diagnostics-otel optional modules

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 28, 2026

Greptile Summary

This PR fixes a TypeScript type regression in src/gateway/server-cron.ts where the agentEntry variable was being inferred as false | AgentEntry | undefined instead of AgentEntry | undefined, causing a type-check failure.

  • Root cause: The original && short-circuit expression (Array.isArray(...) && list.find(...)) propagates the boolean false to the result type when the left-hand side is falsy, yielding a union type that includes false.
  • Fix: Replacing with a ternary expression (condition ? list.find(...) : undefined) ensures agentEntry is always typed as AgentEntry | undefined.
  • Runtime behavior: Unchanged — both false?.heartbeat and undefined?.heartbeat produce undefined, and spreading either is a no-op, so no behavioral difference exists at runtime.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, correct fix with no runtime behavioral change.
  • The change is a one-for-one semantic equivalent swap of && for a ternary, resolving a known TypeScript type-inference quirk. Runtime behavior is demonstrably identical (both false?.heartbeat and undefined?.heartbeat evaluate to undefined; spreading either is a no-op). No other logic is touched.
  • No files require special attention.

Last reviewed commit: 3781b94

Copy link

@nikolasdehor nikolasdehor left a comment

Choose a reason for hiding this comment

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

This is the cleanest approach among the competing PRs (#30048, #30060, #30063, #30021, #30010) for the agentEntry type issue. The ternary eliminates false from the union type at the source, so downstream optional chaining remains valid. This should be merged first — the others should rebase. LGTM.

@xinhuagu xinhuagu closed this Feb 28, 2026
@xinhuagu xinhuagu force-pushed the fix/cron-agententry-typecheck branch from 3781b94 to e904297 Compare February 28, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants