Skip to content

Fix page dedup cache, redirect title icon lookup, and missing isRedirect#93

Open
cicalese wants to merge 1 commit intofix-redirectfrom
fix-coderabbit-suggestions
Open

Fix page dedup cache, redirect title icon lookup, and missing isRedirect#93
cicalese wants to merge 1 commit intofix-redirectfrom
fix-coderabbit-suggestions

Conversation

@cicalese
Copy link
Collaborator

@cicalese cicalese commented Feb 26, 2026

Fix issues found by CodeRabbit in #92

  • Assign concat result back to _addedPages so the dedup cache actually grows across addConnections calls
  • Build a redirect map from the API response and use it to resolve title icon lookups for redirected pages
  • Add isRedirect: false to outgoing and external link page entries for consistency with central page and incoming link entries

Summary by CodeRabbit

  • Bug Fixes

    • Fixed page tracking so newly discovered pages are properly stored and shown
  • Refactor

    • Improved redirect handling when resolving page connections
    • Made page entries consistent across incoming, outgoing, and external links
    • Refined display title resolution and icon selection for redirected pages

@cicalese cicalese marked this pull request as ready for review February 26, 2026 00:22
@cicalese
Copy link
Collaborator Author

The CI failure appears to be unrelated.

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e331ff7 and 1e982d9.

📒 Files selected for processing (2)
  • resources/js/ApiConnectionsBuilder.js
  • resources/js/ApiPageConnectionRepo.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • resources/js/ApiPageConnectionRepo.js
  • resources/js/ApiConnectionsBuilder.js

📝 Walkthrough

Walkthrough

Adds explicit isRedirect: false to page objects in ApiConnectionsBuilder.js and introduces redirect mapping plus redirect-aware display/title/icon resolution in ApiPageConnectionRepo.js, including a new _buildRedirectMap() helper and proper _addedPages reassignment.

Changes

Cohort / File(s) Summary
ApiConnections builder changes
resources/js/ApiConnectionsBuilder.js
All created page object literals (central, outgoing, incoming, external) now include an explicit isRedirect: false property for consistent shape.
Redirect handling and repo fixes
resources/js/ApiPageConnectionRepo.js
Adds _buildRedirectMap(pageInfoResponse); derives redirectMap and uses it to resolve display titles and icon lookup keys; sets page.isRedirect when a redirect is present; fixes _addedPages reassignment to actually update state.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the three main changes: fixing page dedup cache, redirect title icon lookup, and adding missing isRedirect property.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-coderabbit-suggestions

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
resources/js/ApiPageConnectionRepo.js (1)

28-33: ⚠️ Potential issue | 🟠 Major

Delay _addedPages mutation until successful fetch.

Line 28 marks pages as added before _queryLinks succeeds. If the API call fails, later addConnections calls will skip those pages, preventing retry.

💡 Proposed fix
-	return new Promise(
-		function(resolve) {
+	return new Promise(
+		function(resolve, reject) {
 			let pagesToAdd = pageNames.filter(page => !this._addedPages.includes(page));

 			if (pagesToAdd.length === 0) {
 				resolve({pages: [], links: []});
 			} else {
-				this._addedPages = this._addedPages.concat(pagesToAdd);
-
-				this._queryLinks(pagesToAdd).done(
-					function(apiResponse) {
-						this._apiResponseToPagesAndLinks(apiResponse).then(connections => resolve(connections))
-					}.bind(this)
-				);
+				this._queryLinks(pagesToAdd)
+					.done(function(apiResponse) {
+						this._apiResponseToPagesAndLinks(apiResponse).then(function(connections) {
+							this._addedPages = this._addedPages.concat(pagesToAdd);
+							resolve(connections);
+						}.bind(this));
+					}.bind(this))
+					.fail(function(err) {
+						reject(err);
+					});
 			}
 		}.bind(this)
 	);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@resources/js/ApiPageConnectionRepo.js` around lines 28 - 33, The code mutates
this._addedPages before the API call succeeds, causing failed _queryLinks calls
to still mark pages as added and block retries; change addConnections flow so
you only update this._addedPages after _queryLinks and
_apiResponseToPagesAndLinks succeed: call
this._queryLinks(pagesToAdd).done(...).then or use the returned promise to run
this._apiResponseToPagesAndLinks and on successful resolution concat pagesToAdd
into this._addedPages (or set it) and then resolve with connections; on error do
not modify this._addedPages and propagate/reject the error so retries remain
possible (identify and update the logic in addConnections that currently mutates
_addedPages, and adjust the success handler around _queryLinks and
_apiResponseToPagesAndLinks accordingly).
🧹 Nitpick comments (1)
resources/js/ApiPageConnectionRepo.js (1)

65-67: Use resolvedTitle as fallback for displayTitle.

On Line 66, fallback to page.title can re-show the redirect source even after resolution. Prefer resolvedTitle for consistency.

💡 Proposed fix
-										page.displayTitle = displayTitles[resolvedTitle] || page.title;
+										page.displayTitle = displayTitles[resolvedTitle] || resolvedTitle;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@resources/js/ApiPageConnectionRepo.js` around lines 65 - 67, When setting
page.displayTitle, use the resolvedTitle as the fallback instead of page.title
to avoid showing the original redirect source; change the assignment that reads
page.displayTitle = displayTitles[resolvedTitle] || page.title to use
resolvedTitle (i.e., page.displayTitle = displayTitles[resolvedTitle] ||
resolvedTitle) so displayTitles lookups fall back to the resolved value
consistently (affects the block where resolvedTitle, displayTitles and
page.displayTitle are used).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@resources/js/ApiPageConnectionRepo.js`:
- Around line 28-33: The code mutates this._addedPages before the API call
succeeds, causing failed _queryLinks calls to still mark pages as added and
block retries; change addConnections flow so you only update this._addedPages
after _queryLinks and _apiResponseToPagesAndLinks succeed: call
this._queryLinks(pagesToAdd).done(...).then or use the returned promise to run
this._apiResponseToPagesAndLinks and on successful resolution concat pagesToAdd
into this._addedPages (or set it) and then resolve with connections; on error do
not modify this._addedPages and propagate/reject the error so retries remain
possible (identify and update the logic in addConnections that currently mutates
_addedPages, and adjust the success handler around _queryLinks and
_apiResponseToPagesAndLinks accordingly).

---

Nitpick comments:
In `@resources/js/ApiPageConnectionRepo.js`:
- Around line 65-67: When setting page.displayTitle, use the resolvedTitle as
the fallback instead of page.title to avoid showing the original redirect
source; change the assignment that reads page.displayTitle =
displayTitles[resolvedTitle] || page.title to use resolvedTitle (i.e.,
page.displayTitle = displayTitles[resolvedTitle] || resolvedTitle) so
displayTitles lookups fall back to the resolved value consistently (affects the
block where resolvedTitle, displayTitles and page.displayTitle are used).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4ca5b1 and e331ff7.

📒 Files selected for processing (2)
  • resources/js/ApiConnectionsBuilder.js
  • resources/js/ApiPageConnectionRepo.js

Fix issues found by CodeRabbit in #92

- Assign concat result back to _addedPages so the dedup cache
  actually grows across addConnections calls
- Build a redirect map from the API response and use it to resolve
  title icon lookups for redirected pages
- Add isRedirect: false to outgoing and external link page entries
  for consistency with central page and incoming link entries
@cicalese cicalese force-pushed the fix-coderabbit-suggestions branch from e331ff7 to 1e982d9 Compare February 26, 2026 00:29
@cicalese cicalese changed the base branch from master to fix-redirect February 26, 2026 01:46
@cicalese
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cicalese
Copy link
Collaborator Author

@JeroenDeDauw This should be ready to merge pending your review.

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