Skip to content

feat(task-input): preselect server-side team/user default model#3421

Draft
VojtechBartos wants to merge 1 commit into
mainfrom
vojtab/server-model-defaults
Draft

feat(task-input): preselect server-side team/user default model#3421
VojtechBartos wants to merge 1 commit into
mainfrom
vojtab/server-model-defaults

Conversation

@VojtechBartos

Copy link
Copy Markdown
Member

Problem

PostHog now supports team-level and per-user default AI run preferences for task runs, resolved server-side (PostHog/posthog#70671, UI in PostHog/posthog#70683). PostHog Code ignores them: the task input picker preselects the device-local lastUsedModel, so a project-wide default never reaches runs started from the desktop app, and preferences don't follow the user across devices.

Changes

  • PostHogAPIClient.getTaskRunDefaults() fetches GET /api/projects/:id/tasks/my_config/ and returns the resolved_ai_run_defaults triple (user preference over project default). Returns null on any failure, missing endpoint (older servers), or when nothing is configured - defaults are a nicety and must never block task creation.
  • usePreviewConfig fetches the defaults alongside the gateway options. Preselection order for the model picker is now: server default (when it targets the current adapter and the gateway still offers the model) > device-local last-used model > gateway default. The default's reasoning effort is applied with it when the model supports it. Changing the picker still affects only the current composition, so a one-off pick never overrides the server-side preference.

Not in this PR (follow-ups): passing the server default through the one-click inbox flows (resolveDefaultModel / ReportModelResolver), and omitting the triple from cloud-run creation so the backend resolves it at run time (the saga currently must send runtime_adapter for initial_permission_mode; with this PR the picker already carries the server default into the run explicitly, and the backend applies defaults for any caller that omits them).

How did you test this?

  • vitest packages/api-client/src/posthog-client.test.ts - 70 passed, including 3 new cases for getTaskRunDefaults (snake_case → client shape mapping, null on 404 from older servers, null when no default is configured).
  • turbo test --filter=@posthog/api-client --filter=@posthog/ui and turbo typecheck for both packages - green.
  • Not manually tested against a backend running the new endpoint yet.

Automatic notifications

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

Fetch the resolved AI run defaults (the user's per-project preference over
the project default, resolved by the tasks backend) and preselect them in
the task input picker ahead of the device-local last-used model. Changing
the picker still affects only the current composition. Older servers
without the endpoint, fetch failures, and defaults targeting the other
runtime adapter all fall back to the existing behavior.
@VojtechBartos VojtechBartos self-assigned this Jul 14, 2026
@trunk-io

trunk-io Bot commented Jul 14, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 21ef863.

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