You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(aio): apply simplify-pass cleanups to telemetry and session state
Findings from a 4-angle simplify pass (reuse / simplification /
efficiency / altitude), no behavior change except where noted:
- Extract resolveEffectiveCloudStatus: the 9-line terminal-wins status
precedence chain was duplicated byte-for-byte in deriveCloudRunState
and deriveSessionViewState; three review angles flagged it
independently. One exported helper in cloudRunState.ts now owns the
policy.
- isTaskDetailNotFoundError uses requestErrorStatus(error) === 404
instead of string-matching "[404]" in the message - the fetcher keeps
that message format only as legacy, and the substring check could
false-positive on a non-404 error quoting an upstream body. Behavior
tightened accordingly (plain Errors mentioning [404] no longer read as
404s).
- taskDetailQuery no longer retries 404s: the detail fetch is now
always-on, and optimistic/cloud-pending tasks 404 by design, so
react-query's default 3 retries turned every mount of a fresh task
into 4 requests.
- pickFreshestTask is binary (all six call sites were), which also
deletes the logically dead ?? fallbacks at the two hook call sites.
- sessionService: merge the duplicated optimistic-clear blocks and
skip-apply early returns in performCloudTaskSessionHydration; shrink
finalizeTerminalCloudTask to the (taskRunId, status) both call sites
use; clearTerminalCloudPromptState derives taskId from the session
(removing the dual-key lookup hazard) and now also serves the
pre-existing inline terminal cleanup in handleCloudTaskUpdate, so the
composer-settling invariant lives in one place; staleness is computed
once per update in handleCloudTaskUpdate.
- OTel modules: normalizeMethod (the safety-relevant __posthog/
double-prefix rule), asString, and the batch flush-interval constant
move to otel-attributes.ts instead of being duplicated across
otel-telemetry.ts and otel-trace-builder.ts.
Generated-By: PostHog Code
Task-Id: 0c511836-2180-455a-9b58-45df2a0661ec
0 commit comments