Skip to content

Add document sources from connected accounts - #1068

Open
zlareb1 wants to merge 33 commits into
mainfrom
feat/connected-account-source-ui
Open

zlareb1 wants to merge 33 commits into
mainfrom
feat/connected-account-source-ui

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Changelog category

  • New Feature

Changelog entry

Add and edit document sources from a connected Drive, Notion or Linear account in the Library and repository views. Preview pasted links, check access, manage the connection and recover from an interrupted save without losing the link draft.

Why

A signed-in writer with a connected account needs to select content without entering a shared credential. Source controls also need canonical ownership from the server so an alternate token subject cannot hide the owner's actions or expose another user's controls.

Scope and risk

Settings displays account and consent-configuration state. The source form previews each selected link, requires a current access check and invalidates that result when the account, caller, destination or selection changes. Refresh account always invalidates it; a re-read on window focus does so only when the account entry differs or the read fails, and a dropped check says to check again. Source rows show sync state and document counts. Item edits use the existing incremental update operation; an unconfirmed save requires a fresh source read and another review before the next write. Pending saves and adds cannot be dismissed. Closing an editor refreshes its items before mutation actions return and restores focus to the source list. Manual refresh retains the rows and keyboard focus, announces the read as busy and ignores repeated presses until it settles. The phone Add action keeps its full accessible name with a shorter visible label. Account-page navigation keeps the provider and strips unrelated query parameters. Retirement confirmation uses stored access: mirrored copies always queue retirement, namespace copies keep the explicit opt-in, and unavailable access policy makes no retention or count promise.

The server projects connection availability and source ownership through existing account and authorization checks. The frontend discards cached ownership when the caller changes. A namespace admin can check, sync and retire another person's connected source, as the server allows; editing its items and managing its connection stay with the owner. The server replaces a connection on reconnect and retires the sources that use it with their imported copies, so Reconnect asks first and the credential tip says to add the source again. An admin's check of another person's source says only the connection was checked, and its sync state reads as not available to them, since the server shows it only to a verified owner. Push notifications show only on a shared-credential source with namespace access. A failed add or save is reported once, inline. Provider permissions and ingestion results remain server decisions. Account errors preserve input and offer an explicit recovery action.

Compatibility, rollout and rollback

  • connection.list entries add boolean connect_available, defaulting to true, so an SDK reading an older server still parses the entry.
  • knowledge.source.list entries add optional owned_by_caller (default false) on the existing KnowledgeSourceEntry. It answers whether the caller is the connected source's canonical owner; sync, check and retire also need writer on the namespace. Private details stay gated on the full standing check, and a connected source with no items in the answer reads as withheld. No type is renamed.
  • The dashboard uses existing knowledge.source.parse_links, knowledge.source.add and knowledge.source.update operations. Their request contracts and access-mode rules do not change.
  • knowledge.source.inspect adds owned_by_caller the same way.
  • During a rolling upgrade, a new dashboard served by an older replica gets no owned_by_caller. A writer who owns a connected source then gets no row actions until the rollout finishes; an admin keeps check, sync and retire. This fails closed.
  • Operator steps: deploy the server and dashboard together. Existing provider registration and consent configuration are required for live connections. This change adds no setting, migration or backfill.
  • Rollback: revert the server, dashboard and generated outputs together. No new stored data format is introduced.

Tests

Local runs on the current head:

  • vitest over src/flows, src/views, src/lib and src/api: 3188 cases, with one failure in Runs.paging.test.tsx. That test is not touched here and fails the same way on main's tree locally.
  • tsc, Biome and make lint (every SDK, reference and reach-manifest generator check) pass.
  • The unit tests in test_connected_account_availability.py and test_op_reach_census.py pass.
  • The production build and the bundle budget pass. The boot chunk is 122,864 bytes against a 122,880-byte budget, because canCallOwnConnections moved out of it into lib/ownConnections, which only lazy views import. Main's boot chunk is exactly at the budget.

Browser (Playwright) and integration suites run in hosted CI. A genuine signed-in provider flow needs registered OAuth clients and is not part of this change.

AI assistance in the code

  • AI-generated: Codex wrote most of the diff. The source review checked authorization and canonical ownership, stale account/check invalidation, ordered link previews, interrupted-save recovery and generated contracts. Selected regressions and the production build were verified separately.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Full format, lint, typecheck, unit and applicable integration gates pass in hosted CI; only selected local checks have run.
  • Applicable SDK, reference and dashboard-reach outputs are regenerated and reviewed.
  • No migration or plugin-shipped file changes.
  • Hosted frontend build, unit-test and browser jobs report success; live-provider qualification remains separate.
  • The description names wire changes, deployment order and validation limits.
  • Public text contains no deployment identifiers or private evidence paths.
  • Commits are signed off.

Note

Medium Risk
Changes writer-level source registration, OAuth-connected credentials, and ownership projection—authorization-sensitive, but aligned with existing ops and fail-closed rollout behavior described in the PR.

Overview
Writers can register and manage document sources using their own Google Drive, Notion, or Linear connected account (not only namespace admins with shared credentials). The dashboard adds a connected-account path in Library and repository source flows: paste links, preview resolution, Check access, pick My connected account vs shared credential, and Manage connection / Edit items for owners—with Rotate credential and push controls limited to shared-credential sources.

Authorization and API projection shift several knowledge.source.* operations from admin to writer, with connected sources gated on canonical ownership (owned_by_caller on list/inspect). Namespace admins keep check, sync, and retire on others’ connected sources but do not see private item/sync detail. connection.list gains connect_available; disconnect/reconnect confirmations now state that linked sources stop and imported copies are retired.

Docs are updated across architecture, dashboard, and operations reference. Playwright coverage adds a full connected-source writer flow and tightens repository/connected-account expectations; the frontend API types and provider labels support the new UI.

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

@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 1, 2026 11:03pm UTC
loom-telemetry Ready Ready Preview Dec 1, 2026 11:03pm UTC

Request Review

Use the signed-in account to check and add selected document links. Keep shared credentials limited to administrators and show provider configuration requirements.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Refresh source items before another edit after an uncertain save and return focus to the source list. Keep the phone action label compact and cover connected-account permissions at both entrypoints.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Use stored access policy for retirement confirmation and count reporting. Keep the source return marker during account-page navigation and align browser fixtures with the connected-account default.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 force-pushed the feat/connected-account-source-ui branch from fdfc80b to e8ceb7d Compare November 20, 2026 21:09
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Add a source and Rotate credential follow knowledge.source.list's
self_service flag as main's switch does; a connected source still offers
no rotation. Edit items and Manage connection stay, since update and the
connection page answer with self-service off. The reach manifest is
regenerated: the dashboard now calls parse_links and update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

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

Stale Bugbot comment from a previous run.

zlareb1 and others added 3 commits December 1, 2026 15:43
…udget

- Refresh account still renews the account stamp; a re-read on window
  focus renews it only when the entry differs or the read fails, so
  switching windows no longer discards a Check that still holds. A
  dropped Check says to check again.
- canCallOwnConnections moves to api/connections, beside the ops it
  gates: only lazy views call it, so the boot chunk no longer carries it
  and stays within its budget.
- The accounts page drops its from=source hint; the tab that opens the
  link already says to return.
- owned_by_caller joins KnowledgeSourceEntry, with no new list-entry
  type, so no SDK type is renamed. Rust and Go SDKs are regenerated.
- One actorScope helper, one provider-name map and one item-label map
  replace their copies. Plurals, the https wording, the Edit items icon,
  the empty-state text and the list's comments are corrected. Tests cover
  a writer with self-service off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
… source

- The Add dialog cannot be dismissed while Add is running, so its answer
  always reports the stored source.
- A failed focus re-read keeps the account's entry for its link text,
  disables Add, and says to refresh the account before checking again.
- A namespace admin gets Sync now and Retire on another person's
  connected source, as the server allows; check, edits and the
  connection stay with the owner.
- The add form and the item editor share one link check, which also
  refuses an https link with no host.
- The sources region is named after its place, so two lists never share
  a landmark name. The connection hint clears on the next read. A
  connected source's credential tip comes from syncBadge. Provider names
  live in lib/connections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…eck them

The server replaces a connection on reconnect and retires the sources
that use it, so the dashboard says so: Reconnect asks first, and the
credential tip and the connection hint tell the owner to add the source
again afterwards instead of checking it.

- A namespace admin can also check another person's connected source.
- Push notifications show only on a shared-credential namespace source,
  the one kind the server serves them for.
- A save the server refuses keeps the review and needs no reload; only
  an unknown outcome asks for one.
- connect_available defaults to true, so an SDK reading an older server
  still parses connection.list.
- The dashboard page points to the sources table for who may do what.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

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

Stale Bugbot comment from a previous run.

// The namespace's admin may check, sync or retire another person's connected source; only
// its owner edits its items or manages its connection.
if (s.credential_mode === "connected" && !(connectedManageable && owned))
return manageable ? disable(closed ? [check, retire] : [check, sync, retire]) : [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Admin check shows empty item count

Medium Severity

A namespace admin checking another person's connected source now opens the same Check dialog used for owners. That server response is source-level standing only and omits item counts, so the dialog still reports access checked for 0 items and never shows that the credential was accepted.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9273553. Configure here.

zlareb1 and others added 3 commits December 1, 2026 16:33
… as private

- Reconnect and Disconnect say they retire the imported copies of the
  sources they stop; the credential tip and the connection hint say so
  too.
- An admin's check of another person's connected source says only the
  connection was checked, instead of reporting zero items.
- Another person's connected source shows its sync state as private to
  its owner, not as never synced.
- Push notifications show only for a shared-credential source with
  namespace access, as the server serves them.
- A failed add or item save is reported once, inline; only a write that
  committed with lists behind shows a toast.
- The knowledge page describes the account choice, pasted links, Edit
  items, the writer's verbs and what Reconnect does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…d source

- The private sync line reads "not available to you", which also holds
  for an owner the server cannot verify.
- The reconnect tip says every source using the connection is retired.
- The mirrored Retire text says retirement waits for sync only when sync
  is off.
- Push notifications follow Sync now in the menu, as on main.
- The add and item-save dialogs drop a publication-pending branch these
  writes never reach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
- knowledge.source.inspect answers owned_by_caller like the list, and the
  details dialog shows Added by, Last sync and the documents as not
  available to a caller who is not the verified owner.
- The knowledge page's table gives the ops' writer role and says what a
  shared or connected source also needs; Check's order is described as
  it runs.
- connection.list treats any provider refusal as unavailable; the test
  of an unreachable branch goes, and the authorization test names the
  error each case raises.
- The item editor's identity guard says why it stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

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

Stale Bugbot comment from a previous run.

zlareb1 and others added 5 commits December 1, 2026 17:55
…pure module

- The details dialog shows no document count for a connected source the
  caller may not see.
- canCallOwnConnections moves to lib/ownConnections: a pure check, kept
  out of the boot chunk and out of the API module.
- The gdrive item cap is one named constant, matching the server's.
- The knowledge page says only a connected source's owner edits its
  items, and its paragraphs are rewrapped.
- A unit test covers inspect's owned_by_caller.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
… the new copy

- The dashboard page's Library row stays short: the page's table is one
  translation unit, and the longer text pushed it past 16 KiB.
- The connected-accounts spec reads the Disconnect text that names the
  retired copies.
- An org-wide admin can edit a shared source's items; the owner check
  applies only to connected sources.
- A one-item Check says "1 item", and a removal-only edit names no
  links.
- owned_by_caller reads the same in both models; the item editor's
  request ref is named for what it holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The item editor renders the link preview only when links were pasted,
and the knowledge page says any caller who can add a source sees the
list's read error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…are withheld

owned_by_caller now answers ownership alone (the canonical-owner match
the server's own sync and retire check uses), and the private details
stay gated on the full standing check. An owner whose account standing
the server cannot confirm keeps Check, Sync now, Retire and Manage
connection; Edit items and the details need the details. A connected
source with no items answered reads as withheld.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
One _Caller resolves the caller's canonical owner at most once per
request inside private work, and _source_access answers both ownership
and details from it. The e2e owner fixture gets the items a verified
owner is answered, and the details dialog says Reads is not available
when the server withholds the selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…ts bound

Main's dashboard page and wire changes are taken as they are, the
Library and Repositories rows carry this PR's wording, and the SDKs and
reach manifest are regenerated. A test checks that the caller is read
inside private work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

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

Stale Bugbot comment from a previous run.

zlareb1 and others added 2 commits December 1, 2026 19:40
The add form takes a name, a kind and the account, then pasted links or
ids for every kind but recording; the recording-provider clauses are
gone. The item editor drops an identity guard its only parent already
provides by remounting, and a test title names Google Drive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
… saves

- After Reload current items, focus moves to the links field rather
  than staying on the button that unmounts.
- A list refresh marks the rows busy instead of flashing a status line.
- Every source kind is named by its store, as the add form names it.
- Selecting every item with no link to add says to retire the source,
  as the server refuses that edit.
- The knowledge.source models and handlers say who may call each op:
  a writer, with the namespace's admin for a shared source and the
  owner for a connected one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

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

Stale Bugbot comment from a previous run.

zlareb1 and others added 2 commits December 1, 2026 20:32
…ote open

- The add dialog's destination note holds for the repository card too.
- The connection note's link takes focus when it appears; the item
  editor's reload hands focus to the links field through a ref, with
  tests for both.
- The knowledge.source models say who added a source and that a
  connected add stores no credential; the module says an admin may also
  check, sync and remove a connected source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The source views key on the caller's identity only, so a session that
ends mid-form no longer remounts the list and drops a draft; new
actions wait for sign-in, and a 401 keeps the list it showed. Picking
Manage connection again moves the focus again. The docs name Manage
connection and the details an admin sees of a connected source, the
remove and update docstrings are reflowed, and owned_by_caller sits
after credential_mode in both source models.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

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

Stale Bugbot comment from a previous run.

else if (e instanceof ApiError && e.status === 403) setState({ kind: "refused" });
// An ended session keeps the list it showed; signing in again lets a retry read it.
else if (e instanceof ApiError && e.status === 401)
setState((prior) => (prior.kind === "ready" ? prior : { kind: "error", error: e }));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sources section stuck after re-login

Medium Severity

A 401 before the sources list reaches ready now stores error and, in Library section mode, hides the whole section from anyone who cannot add. actorScope no longer changes when the session ends or when the same person signs back in, so the list does not remount or refetch. Retry lives inside that hidden section, so a reader who signed in again still never sees Sources until they leave the page.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 957b050. Configure here.

zlareb1 and others added 8 commits December 1, 2026 21:09
The account field and the check note say the session ended instead of
asking for a personal account. Tests pin that a 401 re-read keeps the
list it showed and that each Manage connection pick moves the focus;
the redundant pick counter goes. A test name now says what it checks,
and three paragraphs are rewrapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
An item editor closed without a confirmed save keeps Edit items off
until a source read succeeds, so a 401 re-read cannot leave it on the
items from before the save. The ended-session copy in the add dialog
has a test, an unreachable recording form rule is removed, and the
module docstring is rewrapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The held Edit items keeps keyboard focus and says to refresh the
sources, and the comment says it is set whenever an editor closes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A held Edit items names sign-in while the session has ended, since
Refresh sources is off until then. The menu-reason docs cover a passing
state as well as a role, and the namespace retire text no longer says
a connected source had a stored credential.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
While the session has ended each row action carries a sign-in reason
and stays focusable; a running read still disables them. Edit items
says the current items are loading while that read runs, and the
menu-reason comments are rewrapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
While a read runs after an item editor closed, including a manual
refresh after a failed one, Edit items says the current items are
loading; a test pins the reason, and the row-action comment says when
items are disabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The 401 re-read test keeps the following Refresh pending and checks that
Edit items says the items are loading, and the row-action comment names
what disables the items.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The note to return to the tab shows only while the account can still
be connected and is not yet, and Edit items' loading reason rests on the
stale items and a running read alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

There are 3 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d72af17. Configure here.

)}
{account.entry?.connect_available !== false && !account.entry?.connected && (
<p className="text-xs text-text-muted">After connecting, return to this tab. Your source details stay here.</p>
)}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Return tip flashes on account refresh

Low Severity

The return-to-tab hint treats a missing entry as disconnected via !account.entry?.connected. A non-quiet read (initial load or Refresh account) clears entry while reading is true, so a connected writer briefly sees “After connecting, return to this tab” until the account comes back.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d72af17. Configure here.

This branch has not been deployed

No deployments
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