Repository navigation
Let projects choose the Linear team for agent tickets - #533
Conversation
The worker already reads project_automation_settings.linear_default_team_id when filing agent tickets, but nothing could write it, so every workspace got its first team. - GET /api/projects/:projectId/linear/teams lists the connected workspace's teams. - PATCH /api/projects/:projectId/automation accepts linearDefaultTeamId (null or blank clears it) and rejects ids that aren't in the workspace, skipping the check when Linear can't be reached. - Settings > File Linear ticket gets a Default team picker. - The teams query pages 250 instead of 50 so larger workspaces list fully.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6b85493b9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const linearNeedsReauth = linear.data?.installed === true && linear.data.needsReauth; | ||
| const githubConnected = github.data?.installed === true; | ||
| const branches = useGithubBranches(projectId, githubConnected); | ||
| const linearTeams = useLinearTeams(projectId, linearConnected); |
There was a problem hiding this comment.
Scope Linear connectivity to the selected project
When Settings is opened for a projectId other than the user's active project, linearConnected still comes from /api/linear/installation, which resolves the active project, while this query targets the project selected in Settings. Consequently, an active project without Linear prevents the team picker from loading for a connected selected project, while an active connected project causes requests and misleading errors for a disconnected selected project. Determine connectivity from the project-scoped teams endpoint or make the installation query project-scoped.
Useful? React with 👍 / 👎.
| const data = await linearGraphql<{ teams: { nodes: LinearTeam[] } }>( | ||
| accessToken, | ||
| "query { teams(first: 50) { nodes { id key name } } }", | ||
| "query { teams(first: 250) { nodes { id key name } } }", |
There was a problem hiding this comment.
Paginate through all Linear teams
For workspaces with more than 250 teams, this returns only the first page, so later teams are absent from the picker and are also rejected by PATCH validation because both paths consume this truncated result. Linear documents that all list responses are paginated and require following pageInfo.hasNextPage with after, so increasing first alone does not produce a complete list (Linear pagination documentation).
Useful? React with 👍 / 👎.
| // Keep a saved team visible even if it's no longer in the workspace list. | ||
| if (value && !teams.some((team) => team.id === value) && !loading && !loadError) { | ||
| options.push({ value, searchText: value, label: <span className="font-mono">{value}</span> }); |
There was a problem hiding this comment.
Fall back when the saved Linear team no longer exists
When the selected team is deleted or the project is reconnected to a different Linear workspace, this branch confirms the saved ID is absent but deliberately retains it as the current selection. The worker uses every non-null linearDefaultTeamId directly in createLinearIssue and only lists the workspace's first team when the value is null, so all subsequent agent ticket deliveries fail until a manager happens to revisit Settings and changes the selection. A confirmed-missing saved team should be cleared/fallback automatically, or delivery should validate it before creating the issue.
Useful? React with 👍 / 👎.
…llback
- The teams endpoint returns { installed: false } for a project without
Linear, and the picker queries the selected project directly instead of
gating on the active project's installation.
- listLinearTeams follows pageInfo cursors instead of reading one page.
- Ticket delivery falls back to the workspace's first team when the
configured team is confirmed missing (deleted, or the project was
reconnected to another workspace). Other create failures still propagate,
and the happy path makes no extra teams call.
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The worker already reads
project_automation_settings.linear_default_team_idwhen it files agent tickets, but no API or UI could write it. Every project fell back to the first team in its Linear workspace.Changes
GET /api/projects/:projectId/linear/teamslists the teams in the project's connected Linear workspace. Returns{ installed: false, teams: [] }when the project has no Linear connection and 502 when Linear can't be reached.PATCH /api/projects/:projectId/automationacceptslinearDefaultTeamId.nullor a blank string clears it. A changed id that isn't in the workspace is rejected with 400. The check is skipped when Linear can't be reached, the same way the PR target branch check works.listLinearTeamsfollowspageInfocursors (250 per page), so large workspaces get a full list. Order is unchanged, so the fallback team is the same.Testing
automation-settings-update.test.ts).linear-agent.test.ts) and the stale-team fallback (linear-delivery.test.ts).api,web,worker, anddbtypecheck. Smoke-tested the teams route and PATCH validation against a local stack.