Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(devex): [MSW v2 split 1/4] App/logic fixes (independent of the upgrade) (#61616)

Georges-Antoine Assie7318c3fecf1
diff --git a/frontend/src/lib/components/ActivityLog/activityLogLogic.tsx b/frontend/src/lib/components/ActivityLog/activityLogLogic.tsx
index f1b6f874e0f4..7a218faaa1d5 100644
--- a/frontend/src/lib/components/ActivityLog/activityLogLogic.tsx
+++ b/frontend/src/lib/components/ActivityLog/activityLogLogic.tsx
@@ -198,6 +198,8 @@ export type ActivityLogLogicProps = {
scope: ActivityScope | ActivityScope[]
// if no id is provided, the list is not scoped by id and shows all activity ordered by time
id?: number | string
+ // page to load on mount (callers that deep-link into a paginated activity feed)
+ startingPage?: number
}
export const activityLogLogic = kea<activityLogLogicType>([
@@ -220,9 +222,9 @@ export const activityLogLogic = kea<activityLogLogicType>([
},
],
})),
- reducers(() => ({
+ reducers(({ props }) => ({
page: [
- 1,
+ props.startingPage ?? 1,
{
setPage: (_, { page }) => page,
},
diff --git a/frontend/src/scenes/cohorts/cohortEditLogic.ts b/frontend/src/scenes/cohorts/cohortEditLogic.ts
index 82159483dc3e..2308ae895449 100644
--- a/frontend/src/scenes/cohorts/cohortEditLogic.ts
+++ b/frontend/src/scenes/cohorts/cohortEditLogic.ts
@@ -1,4 +1,17 @@
-import { actions, afterMount, beforeUnmount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import {
+ actions,
+ afterMount,
+ beforeUnmount,
+ connect,
+ isBreakpoint,
+ kea,
+ key,
+ listeners,
+ path,
+ props,
+ reducers,
+ selectors,
+} from 'kea'
import { forms } from 'kea-forms'
import { loaders } from 'kea-loaders'
import { actionToUrl, router, urlToAction } from 'kea-router'
@@ -637,9 +650,19 @@ export const cohortEditLogic = kea<cohortEditLogicType>([
if (isCalculatingOrPending) {
actions.setPollTimeout(
window.setTimeout(async () => {
- const newCohort = await api.cohorts.get(cohort.id)
- breakpoint()
- actions.checkIfFinishedCalculating(newCohort)
+ try {
+ const newCohort = await api.cohorts.get(cohort.id)
+ // breakpoint() throws to abort once the logic unmounts. Because this runs
+ // in a detached setTimeout callback (not the listener body), that throw
+ // would otherwise surface as an unhandled rejection — keep it contained.
+ breakpoint()
+ actions.checkIfFinishedCalculating(newCohort)
+ } catch (e: any) {
+ if (!isBreakpoint(e)) {
+ throw e
+ }
+ // Poll superseded or logic unmounted — stop quietly.
+ }
}, 1000)
)
} else {
diff --git a/products/ai_observability/frontend/playground/llmPlaygroundModelLogic.ts b/products/ai_observability/frontend/playground/llmPlaygroundModelLogic.ts
index 9f2942b74288..bff5359c7e6a 100644
--- a/products/ai_observability/frontend/playground/llmPlaygroundModelLogic.ts
+++ b/products/ai_observability/frontend/playground/llmPlaygroundModelLogic.ts
@@ -191,6 +191,33 @@ export const llmPlaygroundModelLogic = kea<llmPlaygroundModelLogicType>([
actions.clearPendingTargetModel()
}
+ // Resolve a pending target model once provider keys, BYOK models, and trial models have
+ // all settled — whichever of those loads last drives the resolution. Previously this only
+ // ran from the trial/BYOK success handlers, so a pending model was silently dropped when
+ // trial models loaded before provider keys settled and there were no BYOK keys to fire
+ // loadByokModelsSuccess (the resolution would bail on the settled-gate and never retry).
+ const resolvePendingTarget = (): void => {
+ const pendingTargetModel = values.pendingTargetModel
+ if (!pendingTargetModel) {
+ return
+ }
+ if (!values.providerKeysSettled || !values.byokModelsSettled || !values.trialModelsSettled) {
+ return
+ }
+ if (values.pendingTargetIsTrace) {
+ applyPendingTraceSelection(pendingTargetModel)
+ return
+ }
+ const normalizedPromptsWithTarget = normalizePromptsToAvailableModels(
+ values.promptConfigs,
+ pendingTargetModel,
+ values.effectiveModelOptions,
+ values.providerKeys
+ )
+ actions.setPromptConfigs(normalizedPromptsWithTarget)
+ actions.clearPendingTargetModel()
+ }
+
return {
loadEvaluationConfigSuccess: ({
evaluationConfig,
@@ -231,30 +258,16 @@ export const llmPlaygroundModelLogic = kea<llmPlaygroundModelLogicType>([
actions.setPromptConfigs(normalizedPrompts)
}
- // Handle pending target model
- if (!pendingTargetModel) {
- return
- }
-
- if (!values.providerKeysSettled || !values.byokModelsSettled) {
- return
- }
-
- if (values.pendingTargetIsTrace) {
- applyPendingTraceSelection(pendingTargetModel)
- return
- }
-
- const normalizedPromptsWithTarget = normalizePromptsToAvailableModels(
- values.promptConfigs,
- pendingTargetModel,
- values.effectiveModelOptions,
- values.providerKeys
- )
-
- actions.setPromptConfigs(normalizedPromptsWithTarget)
- actions.clearPendingTargetModel()
+ resolvePendingTarget()
+ },
+ loadProviderKeysSuccess: () => {
+ // If trial models loaded before provider keys settled, the trial handler couldn't
+ // resolve the pending target yet. Retry now that keys (and the BYOK-settled flag) are in.
+ resolvePendingTarget()
},
+ loadProviderKeysFailure: () => resolvePendingTarget(),
+ loadTrialModelsFailure: () => resolvePendingTarget(),
+ loadByokModelsFailure: () => resolvePendingTarget(),
loadByokModelsSuccess: ({ byokModels }: { byokModels: ModelOption[] }) => {
if (byokModels.length === 0) {
return