Skip to content

Let projects choose the Linear team for agent tickets - #533

Merged
arseniycodes merged 2 commits into
mainfrom
ash/linear-default-team-setting
Oct 15, 2026
Merged

arseniycodes merged 2 commits into
mainfrom
ash/linear-default-team-setting

Conversation

@arseniycodes

@arseniycodes arseniycodes commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

The worker already reads project_automation_settings.linear_default_team_id when 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/teams lists 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/automation accepts linearDefaultTeamId. null or 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.
  • The File Linear ticket step in Settings gets a Default team picker, scoped to the project being edited. The first option is "Workspace's first team", which is the current fallback.
  • listLinearTeams follows pageInfo cursors (250 per page), so large workspaces get a full list. Order is unchanged, so the fallback team is the same.
  • Ticket delivery falls back to the workspace's first team when the configured team is confirmed missing, for example a deleted team or a project reconnected to another workspace. Other create failures still propagate. The normal path makes no extra teams call.

Testing

  • Unit tests for parsing, the workspace check, and the conflict-update shape (automation-settings-update.test.ts).
  • Tests for team pagination (linear-agent.test.ts) and the stale-team fallback (linear-delivery.test.ts).
  • api, web, worker, and db typecheck. Smoke-tested the teams route and PATCH validation against a local stack.

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.
@arseniycodes

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T08:53:23.242895Z 86b2dda Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/web/src/Settings.tsx Outdated
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread packages/db/src/linear.ts Outdated
const data = await linearGraphql<{ teams: { nodes: LinearTeam[] } }>(
accessToken,
"query { teams(first: 50) { nodes { id key name } } }",
"query { teams(first: 250) { nodes { id key name } } }",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread apps/web/src/Settings.tsx
Comment on lines +3798 to +3800
// 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> });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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.
@arseniycodes

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 86b2dda1ee

ℹ️ 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".

@arseniycodes
arseniycodes merged commit 2fdc51d into main Oct 15, 2026
7 checks passed
@arseniycodes
arseniycodes deleted the ash/linear-default-team-setting branch October 15, 2026 13:29
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