Skip to content

refactor(mobile): reuse the cloud task engine#3624

Open
richardsolomou wants to merge 4 commits into
posthog-code/share-cloud-task-policiesfrom
posthog-code/share-cloud-task-engine
Open

refactor(mobile): reuse the cloud task engine#3624
richardsolomou wants to merge 4 commits into
posthog-code/share-cloud-task-policiesfrom
posthog-code/share-cloud-task-engine

Conversation

@richardsolomou

@richardsolomou richardsolomou commented Jul 21, 2026

Copy link
Copy Markdown
Member

Problem

Desktop and mobile independently implemented cloud-task streaming, hydration, retry, and deduplication behavior. Keeping both implementations makes parity fixes surface-specific.

Depends on #3623
Refs #2416

Changes

I extracted the existing desktop cloud-task implementation into a host-neutral engine and kept the desktop service as a thin wrapper. Mobile supplies host adapters to the same engine. Terminal runs retain the archived S3 log fallback when persisted session logs are empty.

Follow-up: #3608

How did you test this?

  • Ran the full core and mobile suites, including archived-log fallback coverage.
  • Ran the monorepo typecheck.
  • Ran repo-wide Biome and the host-boundary check.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 5e38056.

@richardsolomou richardsolomou changed the title refactor(cloud): share portable task engine refactor(cloud): share task engine and session orchestration Jul 21, 2026
@richardsolomou
richardsolomou force-pushed the posthog-code/share-cloud-task-policies branch from c05b44e to dc82fa7 Compare July 21, 2026 13:38
@richardsolomou
richardsolomou force-pushed the posthog-code/share-cloud-task-engine branch from 2dafbcd to 1b48f46 Compare July 21, 2026 13:46
@richardsolomou
richardsolomou force-pushed the posthog-code/share-cloud-task-policies branch from 9e39cdd to 7936c58 Compare July 23, 2026 12:47
@richardsolomou
richardsolomou force-pushed the posthog-code/share-cloud-task-engine branch from 32895be to 54e687e Compare July 23, 2026 12:55
@richardsolomou richardsolomou changed the title refactor(cloud): share task engine and session orchestration refactor(mobile): reuse the cloud task engine Jul 23, 2026
@richardsolomou
richardsolomou force-pushed the posthog-code/share-cloud-task-policies branch from 7936c58 to ac8c23a Compare July 23, 2026 13:35
@richardsolomou
richardsolomou force-pushed the posthog-code/share-cloud-task-engine branch from 54e687e to 25563d8 Compare July 23, 2026 13:35
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
packages/core/src/cloud-task/cloud-task-engine.ts:2165
**Archived fetch can hang hydration**

When a terminal run has no persisted session-log rows and its archive request stalls, this unbounded fetch never emits a snapshot or retryable error, leaving the mobile task session loading indefinitely.

### Issue 2 of 2
packages/core/src/cloud-task/cloud-task-engine.ts:2169-2170
**Malformed line discards entire archive**

When an archived NDJSON log contains one malformed line, parsing the complete array throws and returns `null`, causing hydration to reject every otherwise valid entry; the previous mobile parser skipped malformed lines and retained the remaining task history.

Reviews (1): Last reviewed commit: "fix(core): restore archived cloud task l..." | Re-trigger Greptile

Comment thread packages/core/src/cloud-task/cloud-task-engine.ts Outdated
Comment thread packages/core/src/cloud-task/cloud-task-engine.ts
Comment thread packages/core/src/cloud-task/cloud-task-engine.ts Outdated
@veria-ai

veria-ai Bot commented Jul 23, 2026

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

richardsolomou and others added 3 commits July 23, 2026 20:19
Generated-By: PostHog Code
Task-Id: 40c57a59-b4e1-4760-8e56-ecd03e9c2f0f
Generated-By: PostHog Code
Task-Id: c1bbe3cf-742b-4b24-bf96-d11a18b4cf22
Generated-By: PostHog Code
Task-Id: c1bbe3cf-742b-4b24-bf96-d11a18b4cf22
Generated-By: PostHog Code
Task-Id: c1bbe3cf-742b-4b24-bf96-d11a18b4cf22
@richardsolomou
richardsolomou force-pushed the posthog-code/share-cloud-task-policies branch from 1155a8c to afb4875 Compare July 23, 2026 17:28
@richardsolomou
richardsolomou force-pushed the posthog-code/share-cloud-task-engine branch from bdfa389 to 5e38056 Compare July 23, 2026 17:28
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