Skip to content

feat(linear): import Linear issues into new thread drafts - #7065

Closed
maslinedwin wants to merge 8 commits into
pingdotgg:mainfrom
maslinedwin:feat/linear-import-v2
Closed

maslinedwin wants to merge 8 commits into
pingdotgg:mainfrom
maslinedwin:feat/linear-import-v2

Conversation

@maslinedwin

@maslinedwin maslinedwin commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Redo of #3711 for current main, scoped to the original request (discussion #6752).

@juliusmarminge you asked to port this after #2829. This version does not touch orchestration at all, so it does not need to wait on V2 and will not need another rebase when V2 lands.

Why this is different from #3711

#3711 was a 3.6k-line two-way integration wired into V1 decider/projector/reactors (LinearSyncReactor, migration 033, 14 RPCs, mobile, fork app.config). You closed it because those files are going away — not because the product is unwanted.

This PR is read-only import only:

  • Connect a Linear personal API key (Settings → Linear). Token lives in ServerSecretStore with a T3CODE_LINEAR_API_TOKEN env fallback. Never returned to the client.
  • Command palette Import from Linear → search (empty query = recently updated) → multi-select → combine or subtasks → new draft thread with the issue text prefilled. The user reviews/edits before sending.
  • 5 RPCs: linear.authStatus, linear.searchIssues, linear.fetchIssues, linear.setToken, linear.clearToken. Reads are read-scope; token writes are operate-scope.
  • Prompt formatter wraps Linear-authored text in an untrusted <linear_issue> block and defangs delimiter collisions.

Intentionally not in this PR (follow-ups if you want them): status write-back, thread↔issue persistence, /linear bulk browser, mobile, OAuth.

Architecture

LinearApi follows BitbucketApi: Effect Context.Service, HttpClient GraphQL, tagged errors. Import uses the existing useNewThreadHandler + composerDraftStore.setPrompt path, so it does not depend on V1 or V2 internals.

Review lessons from #3711 baked in from the start:

  • Effect.catchTags for known recoveries
  • outages are not reported as “Not connected”
  • token set/clear are serial per environment
  • disconnect checks the command result
  • import addresses the returned draft id instead of re-looking-up a reused dirty draft

Testing

  • tsgo --noEmit clean in contracts, client-runtime, server, web
  • client-runtime: 605 passed (includes formatLinearIssues + injection defusal)
  • web unit: 254 passed (includes settings search catalog)
  • server: 2514 passed / 7 skipped (includes RpcAuthorization coverage of the new methods)

Screenshots

I can add a short screen recording of Settings connect + palette import on request.

Related: complementary to #4115 (composer chips). This one creates a new thread from selected issues, matching Conductor’s “create from Linear” flow.


Note

Medium Risk
Stores and uses Linear API tokens server-side and adds new authenticated RPC surface area; prompt formatting mitigates injection but imported issue text still flows into the model context.

Overview
Adds read-only Linear import: connect a personal API key on the server, search/fetch issues over GraphQL, and prefill a new draft thread from the command palette—no orchestration or write-back.

Server & contracts: New LinearApi service (token in ServerSecretStore, optional T3CODE_LINEAR_API_TOKEN env), five WS RPCs with read vs operate auth, shared schemas/errors in contracts, and unit tests for auth edge cases and partial fetches.

Web: Settings → Linear for connect/disconnect; Import from Linear in the command palette opens a dialog (search, multi-select up to 20, combine vs subtasks, target folder). useLinearImport fetches details and sets the composer via formatLinearIssues, which wraps issue text in an untrusted <linear_issue> block and defangs delimiter injection.

Reviewed by Cursor Bugbot for commit b7b3703. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add Linear issue import into new thread drafts via search dialog and settings panel

  • Adds a full Linear integration: users can authenticate with a personal API key, search and select issues, and import them into a new thread composer as formatted prompt content.
  • Introduces LinearApi service on the server with probeAuth, searchIssues, fetchIssues, setToken, and clearToken operations, exposed as WebSocket RPCs with read/operate scope enforcement.
  • Adds a LinearImportDialog (accessible via command palette) to search, select, and configure issue import mode (combine or subtasks), and a LinearSettingsPanel at /settings/linear for token management.
  • Adds formatLinearIssues in linearFormat.ts to render issue content as delimiter-safe prompt text before writing it into the composer draft store.
  • New contracts in packages/contracts/src/linear.ts define schemas and error types (LinearAuthError, LinearRequestError, LinearTokenStoreError) for all Linear operations.

Macroscope summarized b7b3703.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants