Skip to content

feat: add workspace sync export#2859

Open
daryllimyt wants to merge 22 commits into
mainfrom
codex/simpler-git-sync
Open

feat: add workspace sync export#2859
daryllimyt wants to merge 22 commits into
mainfrom
codex/simpler-git-sync

Conversation

@daryllimyt

@daryllimyt daryllimyt commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add workspace sync export/import support for workspace resources, including new workspace sync services, schemas, projection/import logic, API wiring, migration, generated frontend client updates, and focused tests.
  • Update workspace Git sync settings and resource export dialogs to push workspace changes through pull requests instead of exposing a direct-commit delivery option.
  • Keep existing single-workflow publish Git sync behavior unchanged.

Impact

Workspace-level Git sync can now project supported workspace resources into a repository-backed spec and pull supported resources back into a workspace. Workspace push UI now uses a PR-only path for the new workspace sync surfaces, reducing the chance users bypass review from those flows.

Validation

  • pnpm -C frontend exec biome check --write src/components/settings/workspace-sync-settings.tsx src/components/workspace-sync/resource-sync-actions.tsx
  • pnpm -C frontend run typecheck
  • uv run pytest tests/unit/test_workspace_sync_service.py tests/unit/test_workspace_sync_acceptance_contract.py tests/unit/test_workflow_store_service.py tests/unit/test_workflow_sync_service.py -q (blocked locally: PostgreSQL on localhost:5432 was not running; all collected tests errored during DB fixture setup before test logic ran)

Notes

  • Local QA HTML spread generated at qa-reports/workspace-sync-pr-only-qa-2026-06-16.html; qa-reports/ remains untracked as a PR-only/local artifact.

Summary by cubic

Adds workspace-level Git sync with a provider‑neutral service, PR‑only exports, and new preview endpoints for export counts and pull diffs. Updates the push flow with branch targeting, live resource counts, a unified diff viewer, and a toast link to the PR; expands resource coverage.

  • Bug Fixes

    • Persist export commits; skip opening a PR when the branch has no commits ahead of base.
    • Return 404 for missing sync workspaces in API routes.
    • Preserve import fidelity across adapters; keep agent preset slugs stable in edit mode; tighten workspace sync actions; show pull preview message only on failure.
    • Default single‑workflow pulls to preserve schedules unless explicitly enabled.
    • Redact synced variable values.
    • Require a PR branch for resource sync.
    • Preserve IDs and mappings during import: agent catalog IDs, case tag swaps, case field options with per‑field mapping, and table source IDs.
  • Migration

    • Run DB migrations. Adds workspace_sync_resource_mapping with RLS.
    • Workspace-level pushes now require PRs (no direct commits).

Written for commit 92dfbb2. Summary will update on new commits.

Review in cubic

@daryllimyt daryllimyt added ui Improvements or additions to UI/UX api Improvements or additions to the backend API migration Database migration tests Changes to unit and integration tests codex labels Jun 16, 2026
@blacksmith-sh

This comment has been minimized.

@daryllimyt daryllimyt marked this pull request as ready for review June 19, 2026 01:19
@daryllimyt

Copy link
Copy Markdown
Contributor Author

@cubic review

@daryllimyt

Copy link
Copy Markdown
Contributor Author

@codex review

@cubic-dev-ai

cubic-dev-ai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@cubic review

@daryllimyt I have started the AI code review. It will take a few minutes to complete.

@zeropath-ai

zeropath-ai Bot commented Jun 19, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 92dfbb2.

Security Overview
Detected Code Changes

The diff is too large to display a summary of code changes.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 01a64afffa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tracecat/workspace_sync/service.py
Comment thread tracecat/workspace_sync/transport.py Outdated
Comment thread tracecat/workspace_sync/adapters/agent_preset.py
Comment thread tracecat/workspace_sync/adapters/case_dropdown.py Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

21 issues found across 56 files

Confidence score: 2/5

  • The highest-risk issue is in tracecat/workspace_sync/adapters/secret_metadata.py: broad exception handling during import can default failed decryptions to empty values, which can silently overwrite existing secrets and cause data loss. Fail fast on decryption/import errors and abort the write path before merging.
  • tracecat/workspace_sync/adapters/agent_preset.py has state-faithfulness regressions: import currently mutates an existing version row and omits exported execution fields, so historical/pinned versions can change behavior unexpectedly. Restore snapshot-style version creation and map all exported execution fields on import before merge.
  • tracecat/workspace_sync/adapters/case_dropdown.py ignores spec metadata on create and writes hardcoded defaults, which breaks round-trip sync and can silently alter dropdown behavior after pull. Apply the imported metadata fields on create/update so sync remains deterministic.
  • tracecat/workflow/store/router.py now drops explicit 404 handling for missing workspaces, so clients may receive a 500 for a domain not-found case and handle errors incorrectly. Reinstate the 404 mapping (and related test coverage) to de-risk API behavior before merging.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread tracecat/workspace_sync/adapters/secret_metadata.py Outdated
Comment thread tracecat/workspace_sync/adapters/case_dropdown.py Outdated
Comment thread tracecat/workflow/store/router.py
Comment thread tracecat/workspace_sync/adapters/agent_preset.py Outdated
Comment thread tracecat/workspace_sync/adapters/agent_preset.py Outdated
Comment thread frontend/src/components/workspace-sync/resource-sync-actions.tsx Outdated
Comment thread frontend/src/components/workspace-sync/resource-sync-actions.tsx Outdated
Comment thread tracecat/workspace_sync/adapters/table.py
Comment thread frontend/src/components/settings/workspace-sync-settings.tsx Outdated
Comment thread tracecat/workspace_sync/adapters/case_tag.py Outdated
Comment thread tracecat/workspace_sync/adapters/variable.py

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

3 issues found across 20 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread frontend/src/components/workspace-sync/resource-sync-actions.tsx Outdated
Comment thread tracecat/workspace_sync/schemas.py
Comment thread tracecat/workspace_sync/adapters/case_tag.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 76730f150e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tracecat/workspace_sync/adapters/case_field.py
Comment thread tracecat/workspace_sync/adapters/case_field.py Outdated
Comment thread tracecat/workspace_sync/adapters/table.py Outdated

daryllimyt commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: df8385177d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tracecat/workspace_sync/transport.py
Comment on lines +253 to +255
try:
table = await table_service.get_table_by_name(spec.name)
except TracecatNotFoundError:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reuse mapped table IDs before matching by name

If a table already has a sync mapping and the Git spec keeps the same source_id but changes name, this lookup misses the mapped local table, creates a second table, and _upsert_mapping then repoints the existing source mapping to the new table while leaving the old one behind. Pulling a table rename from Git should resolve by WorkspaceSyncResourceMapping.source_id first and call the table rename path instead of creating by name.

Useful? React with 👍 / 👎.

Comment on lines +147 to +149
for skill in skills:
source_id = unique_source_id(skill.name, reserved=reserved)
reserved.add(source_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve skill source IDs after renames

After a skill has been exported once, operations such as restoring a version can change skill.name; recomputing source_id from that mutable name makes the next export miss the existing mapping and insert another row for the same local_id, which violates uq_workspace_sync_mapping_local. Load existing WorkspaceSyncResourceMapping rows by local skill ID here as the agent preset/table adapters do before falling back to unique_source_id.

Useful? React with 👍 / 👎.

- Add POST /workflows/sync/export/preview endpoint and
  preview_export_workspace service that count the resources a push would
  commit via a read-only projection, without mutating sync mappings
- Redesign the push dialog: source -> branch -> pull request flow strip
  with a live resource count, stacked message/branch fields, rebalanced
  footer, and a clickable "View PR" toast action; shorten the title to
  "Push <resource>"
- Resolve agent presets by stable source id on import and guard against
  slug collisions
- Skip opening a pull request when the target branch has no commits ahead
  of the base branch
- Only show the pull preview message on failure; keep the agent preset
  slug stable when editing an existing preset
- Add export-preview unit test and agent preset acceptance-contract
  coverage; regenerate the frontend client
@daryllimyt daryllimyt force-pushed the codex/simpler-git-sync branch from df83851 to 92dfbb2 Compare June 19, 2026 19:22
@blacksmith-sh

blacksmith-sh Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Found 8 test failures on Blacksmith runners:

Failures

Test View Logs
tests/workspace-sync-settings.test.tsx/
allows manual git URLs when app repositories are available
View Logs
tests/workspace-sync-settings.test.tsx/
disables the repository selector while repositories are loading
View Logs
tests/workspace-sync-settings.test.tsx/
falls back to manual entry when repositories cannot load
View Logs
tests/workspace-sync-settings.test.tsx/
keeps cached app repositories when a repository refetch errors
View Logs
tests/workspace-sync-settings.test.tsx/
keeps explicit select mode for an existing custom git URL
View Logs
tests/workspace-sync-settings.test.tsx/
opens in manual mode for an existing custom git URL
View Logs
tests/workspace-sync-settings.test.tsx/
preserves a selected app repository's non-main default branch
View Logs
tests/workspace-sync-settings.test.tsx/
selects an app repository when repository options are available
View Logs

Fix in Cursor

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

Labels

api Improvements or additions to the backend API codex migration Database migration tests Changes to unit and integration tests ui Improvements or additions to UI/UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant