Skip to content

fix(console): stop related row request loop and correct load order#2962

Merged
HarshMN2345 merged 1 commit intomainfrom
fix/edit-related-request-loop
Apr 8, 2026
Merged

fix(console): stop related row request loop and correct load order#2962
HarshMN2345 merged 1 commit intomainfrom
fix/edit-related-request-loop

Conversation

@HarshMN2345
Copy link
Copy Markdown
Member

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

@HarshMN2345 HarshMN2345 requested review from abnegate and eldadfux April 8, 2026 06:03
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 8, 2026

Greptile Summary

This PR fixes two bugs in the related-row editing side sheet for the tablesDB feature: a request loop caused by a reactive $effect re-triggering on every rows/tableId change, and an incorrect load order where buildWildcardColumnsQuery(relatedTable) was called before relatedTable was fetched. It also extracts the repeated column-rendering markup into a new relatedRowColumns.svelte component.

Key changes:

  • +layout.svelte: Added an {#if} guard so <EditRelatedRow> is only mounted when show, tableId, and rows are all valid — this means onMount fires fresh on each sheet open, replacing the loop-prone $effect.
  • editRelated.svelte: Replaced the reactive $effect(() => { loadRelatedRow() }) with onMount, eliminating the re-triggering loop; swapped load order so relatedTable (schema) is fetched before getRow uses it in buildWildcardColumnsQuery; replaced getStore() (which returned a plain-object snapshot) with direct workData.get() (returns the live Writable), enabling true reactivity in the form.
  • relatedRowColumns.svelte: New presentational component that accepts a Writable<Models.Row> and renders ColumnItem for each field using $workStore for reactive subscription.

Confidence Score: 5/5

Safe to merge — all three changes are targeted, correct fixes with no regressions.

The PR fixes two real bugs (request loop and wrong load order) with straightforward, well-scoped changes. The {#if} guard + onMount pattern is the idiomatic way to scope side-effects to mount lifetime in Svelte 5, replacing the loop-prone $effect. The load order fix (schema before row fetch) is clearly correct. The new RelatedRowColumns component is a clean extraction with no logic changes. No P0 or P1 findings remain.

No files require special attention.

Vulnerabilities

No security concerns identified.

Important Files Changed

Filename Overview
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.svelte Adds an {#if} guard around EditRelatedRow so it only mounts when the sheet is open with valid props — correctly prevents stale mounts and stops the onMount/load cycle from firing with empty data.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/editRelated.svelte Replaces loop-causing $effect with onMount, fixes schema-before-row load order, and switches from snapshot getStore() to live Writable via workData.get() for correct form reactivity.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/relatedRowColumns.svelte New presentational component encapsulating column rendering; correctly uses $workStore subscription for reactivity and accepts a gap prop for layout flexibility.

Reviews (1): Last reviewed commit: "fix(console): stop related row request l..." | Re-trigger Greptile

@HarshMN2345 HarshMN2345 merged commit 3e29e58 into main Apr 8, 2026
3 of 4 checks passed
@HarshMN2345 HarshMN2345 deleted the fix/edit-related-request-loop branch April 8, 2026 06:18
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