Skip to content

[codex] fix: sync provider environment rows#3524

Open
StiensWout wants to merge 9 commits into
pingdotgg:mainfrom
StiensWout:staging/stale-provider-env-rows
Open

[codex] fix: sync provider environment rows#3524
StiensWout wants to merge 9 commits into
pingdotgg:mainfrom
StiensWout:staging/stale-provider-env-rows

Conversation

@StiensWout

@StiensWout StiensWout commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Sync provider environment draft rows when persisted environment content changes while the settings card stays mounted.
  • Add focused unit coverage for the persisted environment content key.

Root cause

  • ProviderEnvironmentSection initialized local rows from props once and did not reconcile them when refreshed or reset provider environment props changed underneath the mounted card.
  • Array identity alone is not a safe signal because callers may pass fresh empty arrays on unrelated renders.

Impact

  • Provider environment rows now refresh after external settings reset or refresh without wiping local draft rows on unrelated renders.
  • The existing publish behavior is preserved: invalid non-empty rows block publish, and blank default rows are skipped.

Validation

  • PATH="$HOME/.vite-plus/bin:$PATH" vp test run apps/web/src/components/settings/ProviderInstanceCard.test.ts --project unit reports no configured project named unit in this checkout before running tests.
  • PATH="$HOME/.vite-plus/bin:$PATH" vp test run apps/web/src/components/settings/ProviderInstanceCard.test.ts passes: 1 file, 5 tests.
  • PATH="$HOME/.vite-plus/bin:$PATH" vp check passes with existing warnings outside this change.
  • PATH="$HOME/.vite-plus/bin:$PATH" vp run typecheck passes.

Note

Medium Risk
Non-trivial client state around sensitive environment variables; regressions could drop edits, resurrect deleted rows, or mishandle redacted secret UX, though server persistence is unchanged.

Overview
Fixes provider environment variable rows going stale when persisted settings refresh or reset while the settings card stays mounted, without treating new array references as real data changes.

ProviderEnvironmentSection now keys sync off getProviderEnvironmentContentKey (serialized name/value/sensitive/redaction) and runs mergeEnvironmentDraftRowsForPersistedUpdate in a useEffect so incoming persisted snapshots merge with local drafts instead of replacing them blindly.

The merge keeps in-progress edits and blank “add” rows, honors local deletions (including stale server echoes via a locally-deleted map), handles reordering, and treats redacted sensitive save echoes as acknowledged when they match what was just published. Edits clear redaction on value change; deletes record removed variables before publish.

Adds broad unit coverage for the content key and merge edge cases in ProviderInstanceCard.test.ts.

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

Note

Fix provider environment variable sync to preserve local edits across persisted updates

  • Adds mergeEnvironmentDraftRowsForPersistedUpdate in ProviderInstanceCard.tsx to merge incoming persisted environment updates with local draft rows, preserving in-progress edits, unpublished adds, and local deletions.
  • Handles sensitive variable acknowledgement: when the server echoes a redacted empty value, the UI recognizes the save as confirmed rather than overwriting local state.
  • Tracks locally deleted variables so stale server echoes or conflicting re-adds don't resurrect removed rows.
  • Adds getProviderEnvironmentContentKey to detect when the persisted environment has actually changed content, gating the merge effect.
  • Extends the test suite in ProviderInstanceCard.test.ts with coverage for key stability, redaction semantics, reordering, and conflict resolution.

Macroscope summarized 1d42fee.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d643adcc-fa7b-4bb4-b9e1-943031f43619

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Jun 23, 2026

@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: ff7bac007e

ℹ️ 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 apps/web/src/components/settings/ProviderInstanceCard.tsx Outdated
Comment thread apps/web/src/components/settings/ProviderInstanceCard.tsx
@macroscopeapp

macroscopeapp Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

Introduces substantial new state synchronization logic (~245 lines) for merging local environment variable drafts with server-persisted data. The complex state management with multiple edge cases warrants human review despite comprehensive test coverage.

You can customize Macroscope's approvability policy. Learn more.

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Jun 23, 2026
Comment thread apps/web/src/components/settings/ProviderInstanceCard.tsx

@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: e6298d9fb9

ℹ️ 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 apps/web/src/components/settings/ProviderInstanceCard.tsx
Comment thread apps/web/src/components/settings/ProviderInstanceCard.tsx Outdated
Comment thread apps/web/src/components/settings/ProviderInstanceCard.tsx
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Jun 23, 2026
Comment thread apps/web/src/components/settings/ProviderInstanceCard.tsx
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 23, 2026
@macroscopeapp macroscopeapp Bot dismissed their stale review June 23, 2026 07:50

Dismissing prior approval to re-evaluate 9787cea

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 23, 2026

@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: 9787cea601

ℹ️ 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 apps/web/src/components/settings/ProviderInstanceCard.tsx Outdated
Comment thread apps/web/src/components/settings/ProviderInstanceCard.tsx Outdated
@macroscopeapp macroscopeapp Bot dismissed their stale review June 23, 2026 09:47

Dismissing prior approval to re-evaluate 72c7478

@StiensWout StiensWout force-pushed the staging/stale-provider-env-rows branch from 72c7478 to f6f464b Compare June 23, 2026 19:45
Comment thread apps/web/src/components/settings/ProviderInstanceCard.tsx
Comment thread apps/web/src/components/settings/ProviderInstanceCard.tsx
Comment thread apps/web/src/components/settings/ProviderInstanceCard.tsx Outdated
StiensWout and others added 8 commits June 23, 2026 20:12
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
@StiensWout StiensWout force-pushed the staging/stale-provider-env-rows branch from 3642597 to 8f7b869 Compare June 23, 2026 20:17

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 8f7b869. Configure here.

Comment thread apps/web/src/components/settings/ProviderInstanceCard.tsx
Comment thread apps/web/src/components/settings/ProviderInstanceCard.tsx
Co-authored-by: Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant