[feat]: Per-project Linear account (support multiple Linear workspaces)
Feature Summary
Allow more than one Linear account to be connected at once, and let each project pick which one it uses, the same way #2235 / #2398 did for GitHub. Today only one Linear credential can exist, so anyone working across several Linear workspaces has to keep swapping the API key.
Problem or Use Case
A Linear API key is scoped to a single workspace. I work in three workspaces (personal projects plus work), so I hold three keys. Emdash only stores one Linear credential, and the issue picker for every project reads that one credential. To pull issues for a work project I have to disconnect Linear, paste the work key, and later swap back. With several projects open at the same time there is no key that works for all of them.
The same limitation applies to every other issue tracker integration (Jira, GitLab, Plane, ...), but Linear is the one I hit daily.
What the GitHub work did (the model to follow)
#2398 "feat: support for multiple GitHub accounts" resolved #2235. The pieces that matter here:
- Account registry. GitHub accounts became rows in the
provider_accountstable (one per provider + account id, with anis_defaultflag). A management RPC was added to the GitHub contract:listAccounts,setDefaultAccount,removeAccount,importCliAccounts. - Accounts UI. The settings integrations area lists connected accounts, marks the default, and lets you connect another one. Connecting an already-connected account shows a toast instead of duplicating. Removing an account that projects still pin warns first (
countProjectsUsingGithubAccount). - Per-project setting. Project git settings gained
githubAccount: { kind: 'account', accountId } | { kind: 'none' }, with "absent = infer". It is exposed in the project settings form and in the add-project modal. - Resolver.
createProjectGitHubAccountResolverinsrc/core/features/github/api/node/services/project-github-account-resolver.tsturns a project id into the account its API calls run as, with provenance (set/inferred/unresolvable). A dangling pin fails closed rather than silently using another identity. - Consumers. PR sync, issue listing, and automation flows take the resolved account instead of a global token, and account errors are surfaced in the PR and issue surfaces.
- Migration. A run-once step backfilled the legacy single token into the registry.
Where Linear stands today
The storage layer is already shared with GitHub, so a good part of the groundwork exists:
- Integration credentials live in the same
provider_accountsregistry viaIntegrationCredentialStore(src/core/features/integrations/node/integration-credential-store.ts). The store already supportsgetAccount(integrationId, accountId), per-accountdelete, and upsert by account id. IntegrationConnectionService.connectalready derives the account id fromverify()'saccountfield when a plugin returns one, and falls back to the'default'id otherwise.
What is missing:
- Linear's
verify()returns noaccountidentity (packages/plugins/src/integrations/impl/linear/client.tsreturns onlydisplayName/displayDetail), so every connect writes to the'default'account id and a second workspace overwrites the first. - Disconnect is all-or-nothing. The
integrationswire contract only haslist/connect/disconnect(integrationId), anddisconnectremoves every account for the integration. There is nolistAccounts/removeAccount/setDefaultAccountequivalent. - Issue fetching ignores projects.
createPluginIssueProvider(src/core/features/integrations/api/node/plugin-issue-provider.ts) callsgetIntegrationCredentialStore().get(provider)with no account id, so it always uses the default account. Theissuescontract (listIssues/searchIssues/getIssueContext) takes aproviderbut noprojectId, so nothing could be resolved per project even if the store held several accounts. - No per-project setting. Project settings have
githubAccountbut no equivalent for issue-tracker integrations. - Settings UI is single-account. The integrations card / detail sidebar shows one connection per integration.
Proposed Solution
Mirror the GitHub design, generalised to integrations rather than Linear-specific where it is cheap to do so:
- Plugin identity. Make Linear's
verify()returnaccount: { id: organization.id, login: organization.urlKey }anddisplayDetail: organization.name, so the account id becomeslinear:<orgId>. Other trackers can opt in the same way; anything that keeps returning noaccountstays single-account with the'default'id. - Account management RPC. Extend the
integrationscontract withlistAccounts(integrationId),setDefaultAccount(integrationId, accountId), andremoveAccount(integrationId, accountId). Keepdisconnectfor the single-account path or make it callremoveAccounton the default. - Settings UI. In the integration detail sidebar, list connected accounts (display name + workspace name), mark the default, add a "Connect another workspace" action, and warn before removing an account that projects still pin.
- Per-project setting. Add
issueTrackerAccounts?: Record<integrationId, { kind: 'account', accountId } | { kind: 'none' }>(or a Linear-onlylinearAccountif that is judged simpler) to stored project settings, editable in project settings, absent = use the integration's default account. Include it incountProjectsUsing...for the removal warning. - Resolution. Add a small resolver alongside
project-github-account-resolver.tsthat maps(projectId, integrationId)to an account id: explicit pin if set and still present, otherwise the default account,unresolvableif the pin dangles. - Plumb it through. Add an optional
projectIdto theissuescontract inputs and to the issue provider options, and havecreatePluginIssueProviderresolve the account before calling the plugin. The task-creation issue picker already knows the project, so it passes it along.
Alternatives Considered
- Swapping the API key by hand every time I switch context. That is what I do today; it is error-prone and impossible with several projects open.
- One Linear account with access to all workspaces. Not possible across separate personal and employer workspaces.
- A single "active Linear workspace" toggle. Better than nothing, but still a global switch with the same problem #2235 called out for
gh auth switch.
Additional Context
- #2235 (per-project GitHub account) and #2398 (the implementing PR) are the precedent.
- #104 ("Account management", closed) asked for Linear account management in broad terms but only led to the settings reorganisation.
- Related: #1930 (sync linked issue status) would also need per-project account resolution once it lands.
hi, thank you for opening the issue and the pr! while I was looking into it, I decided to add multi account support for all integrations, not just linear and also consolidated a lot of things. this is in the current v1.2.5 release! will therefore close your pr