Skip to content

feat: configurable Drive corpora org setting (TKAI-49)#53

Merged
yourbuddyconner merged 3 commits into
mainfrom
conner/tkai-49-drive-corpora-setting
May 11, 2026
Merged

feat: configurable Drive corpora org setting (TKAI-49)#53
yourbuddyconner merged 3 commits into
mainfrom
conner/tkai-49-drive-corpora-setting

Conversation

@yourbuddyconner
Copy link
Copy Markdown
Owner

Summary

  • Adds a driveCorpora org setting (user | domain | allDrives) that controls the Google Drive API corpora parameter on all files.list calls
  • Flows through the existing guardConfig pipeline: org settings DB -> SessionAgentDO (60s cache) -> ActionContext -> plugin
  • Default is user (no behavior change without admin action)
  • Admin UI: renamed "Drive Labels Guard" section to "Google Drive", added a "File discovery scope" dropdown above the existing labels guard controls

Resolves TKAI-49

Changes

Layer File What
Migration 0009_add_drive_domain_corpora.sql drive_corpora TEXT NOT NULL DEFAULT 'user'
Schema lib/schema/org.ts Drizzle field
Types shared/types/index.ts driveCorpora on OrgSettings
DB lib/db/org.ts Row mapper, defaults, update
DO session-agent.ts Pass through guardConfig
API routes/admin.ts Accept + validate in PUT body
Plugin drive-actions.ts resolveCorpora(ctx) helper, all 6 files.list calls
Tests resolve-corpora.test.ts 7 tests for the helper
UI admin.tsx Dropdown in Google Drive settings section

Test plan

  • Verify default behavior unchanged: new org with no setting change should use corpora=user
  • Set to domain in admin UI, confirm Drive list/search actions return org-shared docs
  • Set to allDrives, confirm shared drive files appear
  • Set back to user, confirm scoped down again
  • Verify single-file operations (get_document_info, download_file, etc.) are unaffected
  • Run pnpm typecheck (passes)
  • Run plugin tests: cd packages/plugin-google-workspace && pnpm test (7/7 resolveCorpora tests pass)

…hread

Child session idle/completion events were delivered to the orchestrator's
main thread instead of the thread that spawned the child. The root cause
was that parentThreadId was only stored in the child DO's transient SQL
state, which is lost if the DO is re-initialized.

- Persist parent_thread_id in D1 sessions table as durable fallback
- Fall back to D1 value in notifyParentEvent when DO state is empty
- Add hydration to handleSystemMessage's direct dispatch path so thread
  channels resolve the correct OpenCode session (was missing, unlike
  handlePrompt and sendNextQueuedPrompt which already hydrate)
- Extract ensureThreadOcSessionHydrated helper to deduplicate the
  hydration pattern across dispatch paths
- Add diagnostic logging at spawn, notify, and receive points
Drive files.list calls default corpora to 'user', hiding org-shared docs.
Add a driveCorpora org setting (user/domain/allDrives) that flows through
guardConfig to the Google Workspace plugin, letting admins control file
discovery scope from the admin UI.
@yourbuddyconner yourbuddyconner merged commit bb83032 into main May 11, 2026
1 check passed
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