Skip to content

CS 312: when a page is renamed, update the link text on the pages that link to it - #163

Closed
ringger wants to merge 1 commit into
mainfrom
fix/rename-refreshes-link-text
Closed

ringger wants to merge 1 commit into
mainfrom
fix/rename-refreshes-link-text

Conversation

@ringger

@ringger ringger commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

In mdxcanvas, one page can link to another with <course-link type="page" id="..."/>. When the tag has no text of its own, the link shows the target page's title, which mdxcanvas fills in when it sends the linking page to Canvas.

Update the link text on other pages when a page is renamed

Why: When we rename a page in the course, the links to it on other pages need to show the new title. We observed that the link titles remained stale while previewing CS 312 page updates on the test course. The renamed page showed its new title, and the four pages linking to it kept the old one. mdxcanvas re-sends a linking page only when its own source changes or when the page it links to is newly created, and a rename is neither.

What: A rename now re-sends every resource whose links show the renamed resource's title or point to its address. Those resources are sent after the renamed one, so they pick up the new title. mdxcanvas detects a rename by comparing the new title with the title it recorded from Canvas the last time it sent that resource. If either title is unknown, it treats the update as a rename. An edit that keeps the title re-sends nothing extra, because re-sending a quiz that has submissions makes an instructor open it and save it again by hand.

You may see a better way to fix this, and I'm open to suggestions.

This changes the same lines of planner.py as PR #160. Whichever lands second, I'll resolve the overlap. The changelog entry is under Unreleased, so the version number is yours to pick.

Three new planner tests cover a rename, an edit that keeps the title, and two renamed pages that link to each other. Taking out each part of the fix makes one of them fail, and a dry run of CS 312 plans the same changes with and without it.

A course-link with no text stores a placeholder for its target's title, filled
in when the linking resource is sent. The linking resource's checksum covers
the placeholder, not the title, and the planner reapplied consumers only when
their producer was a replacement create. A rename is an update, so every link
to a renamed page kept the old title on Canvas.

An update now counts as a rename when its title differs from the title in the
ledger, or when either is unknown. A rename reapplies the consumers that read
a field other than the Canvas id, and they wait for it, so they read the new
title and uri. An update that keeps its title reapplies nothing: re-sending a
quiz that has submissions asks an instructor to save it again by hand. Two
renamed resources that read each other cannot both go second, so ordering
edges between renames inside a cycle are dropped.

Tests: a rename reapplies its linker after it and not a consumer that reads
only the id; a body edit reapplies nothing; two renamed pages that link to
each other plan without a cycle. Four mutants (every update counts as a
rename; renames reapply nothing; no ordering after a rename; mutual renames
keep their cycle) each fail one of them. A dry run of CS 312 against its test
course plans the same 280 changes with and without this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ringger
ringger requested a review from byubean November 20, 2026 16:38
@byubean byubean mentioned this pull request Nov 20, 2026
@ringger

ringger commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #164, which fixes this in 0.8.15.

@ringger ringger closed this Nov 20, 2026
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