Skip to content

Edit-mode replace affordance for broken singular linksTo#4992

Merged
habdelra merged 24 commits into
mainfrom
worktree-cs-11227-edit-mode-broken-linksto
May 27, 2026
Merged

Edit-mode replace affordance for broken singular linksTo#4992
habdelra merged 24 commits into
mainfrom
worktree-cs-11227-edit-mode-broken-linksto

Conversation

@habdelra
Copy link
Copy Markdown
Contributor

@habdelra habdelra commented May 27, 2026

What

In edit mode, a broken singular linksTo now offers a replace affordance: a "Link [type]" button rendered alongside the broken-link placeholder and the remove control. Clicking it opens the card chooser and swaps the broken reference for a working one directly, without first removing the link to fall back to the empty state.

The broken state stays visually distinct from the never-set state:

  • Never set — the bare "Link [type]" button only.
  • Broken (error / not-found) — the placeholder with the URL surfaced, a remove (X) control, and the "Link [type]" replace control.

Both write controls are hidden when the editor is read-only; the placeholder and its URL still render so the broken target stays visible.

Preview

Singular linksTo (with the new replace button) and plural linksToMany (broken slot keeps its drag handle + remove among present cards) in edit mode:

Edit-mode broken linksTo / linksToMany preview

Where

  • packages/base/links-to-editor.gts — the broken branch of LinksToEditor gains the replace button, stacked with remove in the trailing controls column.

Tests

packages/host/tests/integration/components/linksto-broken-link-placeholder-test.gts:

  • broken edit view shows the placeholder, URL, remove, and the labelled replace control;
  • removing reverts the slot to the empty "Link" affordance;
  • a read-only broken link shows the placeholder with neither control.

Plural linksToMany edit-mode handling (per-slot placeholder + remove) is carried by #4983, which this PR is stacked on.

CS-11227

habdelra and others added 19 commits May 27, 2026 10:42
The plural `linksToMany` view path and both link editors (standard +
compact) now read `getRelationship` once per render and dispatch
`BrokenLinkTemplate` for each slot whose relationship is `error` or
`not-found`; present, not-loaded, and not-set slots keep their existing
per-item render. Each placeholder occupies its own item container, so one
broken element no longer breaks the surrounding list.

Stability is preserved by leaving the iteration keying untouched — the
view path still keys on the stable per-child component identity and the
editors on their index / box identity. The broken-link state only feeds an
inner branch, and the relationship read is pure (it never retriggers the
lazy loader) and returns a fresh array that is never used as an each key.
This keeps per-slot identity stable when state hasn't changed, so a sibling
field staying focused mid-edit is never torn down by a broken neighbor.

In edit format a broken element shows the placeholder plus the existing
remove affordance, so a dead reference is visible and clearable rather than
rendering as a broken card.

`BrokenLinkTemplate` now accepts splattributes so callers can attach
per-element hooks/attributes to the placeholder root.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…n-link-placeholder-per-element-in-linkstomany
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
In edit mode a broken singular linksTo now surfaces, alongside the
placeholder and remove control, a "Link [type]" button that opens the
card chooser to swap the broken reference for a working one in a single
step instead of first reverting to the empty state.

The broken state stays distinct from the never-set state: a never-set
link shows only the bare "Link" button, while a broken link shows the
URL plus remove and replace controls. Both affordances are hidden when
the editor is read-only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a “replace” affordance for broken singular linksTo fields in edit mode, allowing users to swap a broken reference for a valid one via the card chooser without first clearing the field. This aligns singular linksTo broken-state UX more closely with the existing plural handling and clarifies the distinction between “never set” vs “broken”.

Changes:

  • Render a “Link [type]” replace button alongside the broken-link placeholder and remove control (writeable only).
  • Stack broken-state controls in the trailing column next to the placeholder.
  • Expand integration coverage to assert broken edit-mode controls, remove→empty transition, and read-only behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/base/links-to-editor.gts Adds replace button to broken-link edit state and stacks remove/replace controls; includes styling.
packages/host/tests/integration/components/linksto-broken-link-placeholder-test.gts Adds/updates tests verifying broken edit UI shows placeholder+URL+remove+replace, removal returns to empty “Link” state, and read-only hides controls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/base/links-to-editor.gts Outdated
habdelra and others added 5 commits May 27, 2026 13:41
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The preview stays visible in the PR comment via the commit-pinned raw URL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The preview stays visible in the PR description via the commit-pinned raw URL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Preview deployments

Host Test Results

    1 files      1 suites   1h 47m 53s ⏱️
2 815 tests 2 800 ✅ 15 💤 0 ❌
2 834 runs  2 819 ✅ 15 💤 0 ❌

Results for commit db32d6c.

Realm Server Test Results

    1 files      1 suites   10m 58s ⏱️
1 502 tests 1 501 ✅ 0 💤 1 ❌
3 186 runs  3 185 ✅ 0 💤 1 ❌

Results for commit db32d6c.

For more details on these errors, see this check.

@habdelra habdelra requested a review from a team May 27, 2026 19:00
Copy link
Copy Markdown
Contributor

@lukemelia lukemelia left a comment

Choose a reason for hiding this comment

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

It would be good to review this with design team after it lands.

@habdelra habdelra changed the base branch from cs-11226-render-broken-link-placeholder-per-element-in-linkstomany to main May 27, 2026 20:32
@habdelra habdelra merged commit d060ee7 into main May 27, 2026
99 of 102 checks passed
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.

3 participants