Skip to content

feat: rename adapter.client to adapter.octokit / adapter.linearClient / adapter.webClient#478

Merged
bensabic merged 11 commits into
mainfrom
feat/rename-adapter-client-getters
May 12, 2026
Merged

feat: rename adapter.client to adapter.octokit / adapter.linearClient / adapter.webClient#478
bensabic merged 11 commits into
mainfrom
feat/rename-adapter-client-getters

Conversation

@bensabic
Copy link
Copy Markdown
Contributor

@bensabic bensabic commented May 10, 2026

Summary

Rename the public native client getter on the GitHub, Linear, and Slack adapters so it matches the underlying SDK class instead of the generic .client. The previous .client getter is preserved as a @deprecated alias on all three adapters, so existing code keeps working without changes.

  • bot.getAdapter("github").client is now bot.getAdapter("github").octokit (returns Octokit)
  • bot.getAdapter("linear").client is now bot.getAdapter("linear").linearClient (returns LinearClient from @linear/sdk)
  • bot.getAdapter("slack").client is now bot.getAdapter("slack").webClient (returns WebClient from @slack/web-api)

Each new getter has TSDoc covering single- vs multi-tenant resolution rules and when calling outside a webhook handler throws. Focused unit tests assert that the new getter returns the underlying SDK instance, that single-tenant calls return the same instance, that the deprecated .client alias points at the new getter, that multi-tenant mode without webhook context throws on both getters, and that inside a webhook context the getter resolves to the per-tenant client.

Commits are split for review:

  1. feat(adapter-github): rename adapter.client to adapter.octokit
  2. feat(adapter-linear): rename adapter.client to adapter.linearClient
  3. docs: use .octokit / .linearClient in chat-sdk.dev examples
  4. chore: changeset for adapter native client getter rename
  5. fix: hoist regex literals in new client-getter tests to module scope
  6. feat(adapter-slack): rename adapter.client to adapter.webClient
  7. docs: include slack .webClient in chat-sdk.dev examples
  8. chore: include adapter-slack in native client getter rename changeset
  9. test(adapter-github,adapter-linear): cover with-context resolution on the new client getters

bensabic added 5 commits May 10, 2026 14:15
Rename the public native client getter on `GitHubAdapter` from `.client`
to `.octokit` so it matches the underlying SDK class name. The previous
`.client` getter is preserved as a `@deprecated` alias that delegates to
`.octokit`, so existing code keeps working without changes.

Internal refactor:
- The colliding private field `octokit` is renamed to `defaultOctokit`
  (mirroring Linear's `defaultClient`), and the single internal use of
  `this.client` in `fetchSubject` is updated to `this.octokit`.
- TSDoc is added to both getters covering single- vs multi-tenant
  resolution and when calling outside a webhook handler throws.

Tests:
- Existing `fetchSubject` tests that reflectively assigned to the
  private octokit field are updated to use `defaultOctokit`.
- A new `octokit getter` describe block asserts: PAT-mode returns the
  underlying `Octokit`, single-tenant calls return the same instance,
  the deprecated `.client` alias points at `.octokit`, and multi-tenant
  mode without webhook context throws on both getters.
Rename the public native client getter on `LinearAdapter` from `.client`
to `.linearClient` so it matches the underlying SDK class name from
`@linear/sdk`. The previous `.client` getter is preserved as a
`@deprecated` alias that delegates to `.linearClient`, so existing code
keeps working without changes.

TSDoc is added to both getters covering single-tenant (apiKey,
accessToken, client credentials) vs multi-tenant OAuth resolution and
when calling outside a webhook handler throws.

A new `linearClient getter` describe block asserts: apiKey mode returns
the underlying `LinearClient`, single-tenant calls return the same
instance, the deprecated `.client` alias points at `.linearClient`, and
multi-tenant OAuth without webhook context throws on both getters.
Update chat-sdk.dev pages that referenced `bot.getAdapter(...).client`
to use the new SDK-named getters (`.octokit` for GitHub,
`.linearClient` for Linear), and note that the previous `.client`
getter remains as a deprecated alias.

Touches the usage, API reference, subject, and adapters pages.
Minor bump for `@chat-adapter/github` and `@chat-adapter/linear`
covering the rename of `adapter.client` to `adapter.octokit` /
`adapter.linearClient`, with the `.client` alias kept as deprecated.
Move the inline `/installation/i` and `/No Linear access token available/`
regex literals used by the new `octokit getter` and `linearClient
getter` `expect.toThrow` assertions into top-level `const`s, satisfying
ultracite's `lint/performance/useTopLevelRegex` rule.
@bensabic bensabic requested a review from a team as a code owner May 10, 2026 04:25
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat-sdk-nextjs-chat Ready Ready Preview, Comment May 12, 2026 9:20am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
chat Ignored Ignored May 12, 2026 9:20am

visyat
visyat previously approved these changes May 11, 2026
…lient-getters

# Conflicts:
#	packages/adapter-github/src/index.ts
#	packages/adapter-linear/src/index.ts
visyat
visyat previously approved these changes May 11, 2026
bensabic added 5 commits May 12, 2026 19:05
…lient-getters

# Conflicts:
#	apps/docs/content/docs/api/chat.mdx
#	apps/docs/content/docs/usage.mdx
Rename the public native client getter on `SlackAdapter` from `.client`
to `.webClient` so it matches the underlying SDK class name (`WebClient`
from `@slack/web-api`). The previous `.client` getter is preserved as a
`@deprecated` alias that delegates to `.webClient`, so existing code
keeps working without changes.

This brings Slack in line with the same SDK-named convention this PR
applies to the GitHub (`.octokit`) and Linear (`.linearClient`)
adapters.

TSDoc on the new getter covers single-workspace vs multi-workspace
token resolution, the `withBotToken` escape hatch, and when calling
outside a webhook handler throws.

A new `webClient getter` describe block asserts: the new getter returns
a `WebClient` bound to the static `botToken`, repeated calls return the
same instance, the deprecated `.client` alias points at `.webClient`,
multi-workspace mode without context throws on both getters, and the
context token from `withBotToken` flows through `.webClient`. The
existing `direct WebClient access via adapter.client` block is kept
as-is to verify the deprecated alias retains its full behavior.
Update chat-sdk.dev pages so the native client examples use the
SDK-named getters across all three adapters (`.webClient` for Slack,
`.linearClient` for Linear, `.octokit` for GitHub):

- `docs/api/chat.mdx`: rewrite the "Direct client access" section to
  introduce the SDK-named getter for each adapter, mention that the
  `.client` alias is deprecated on all three, and update the
  `withBotToken` callout to reference `.webClient`.
- `docs/usage.mdx`: switch the Slack snippet to `.webClient`.
- `docs/adapters.mdx`: rename the "Native client" capability row to
  link to all three SDK-named getters and mark Slack as supported.
- Per-adapter pages: switch the official Slack/Linear/GitHub adapter
  reference pages to use the SDK-named getter and add a deprecation
  note. The Slack adapter page didn't previously document
  `.client` — add a "Direct API client" section to it now.
Extend the existing rename changeset to also cover `@chat-adapter/slack`
now that this PR adds the matching `.webClient` getter (with `.client`
preserved as a deprecated alias) to the Slack adapter.
… the new client getters

Add the symmetric "with webhook context" tests for the new `.octokit`
and `.linearClient` getters that were previously only covered
implicitly by webhook-driven tests. Each test wires the adapter's
private `requestContext` `AsyncLocalStorage` directly and asserts:

- inside the context, the public getter resolves to the per-tenant
  client (per-installation `Octokit` for GitHub, per-org `LinearClient`
  for Linear);
- repeated reads inside the same context return the same instance and
  the deprecated `.client` alias matches;
- on GitHub, a different installation context resolves to a different
  cached client;
- exiting the context throws again — the per-call context isn't
  sticky.

This brings GitHub and Linear up to parity with the equivalent
`webClient` test on Slack (`uses the request context token under
withBotToken via webClient`).
@bensabic bensabic changed the title feat: rename adapter.client to adapter.octokit / adapter.linearClient feat: rename adapter.client to adapter.octokit / adapter.linearClient / adapter.webClient May 12, 2026
@bensabic bensabic merged commit 2f108bd into main May 12, 2026
17 checks passed
@bensabic bensabic deleted the feat/rename-adapter-client-getters branch May 12, 2026 22:35
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.

2 participants