Skip to content

Conversation

@benceruleanlu
Copy link
Member

@benceruleanlu benceruleanlu commented Jan 24, 2026

Reconcile asset selection and anchor state with visible assets.

Summary

Track selection anchor by asset id and prune selection when assets are hidden or reordered so list/gallery actions stay aligned.

Changes

Review Focus

  • Selection anchor updates on prune/reorder.
  • Queue overlay selection updates now also set anchor id.

Screenshots (if applicable)

N/A

┆Issue is synchronized with this Notion page by Unito

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • backport

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.

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


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.

@github-actions
Copy link

github-actions bot commented Jan 24, 2026

🎨 Storybook Build Status

Build completed successfully!

⏰ Completed at: 01/24/2026, 04:04:42 PM UTC

🔗 Links


🎉 Your Storybook is ready for review!

@github-actions
Copy link

github-actions bot commented Jan 24, 2026

🎭 Playwright Tests: ⚠️ Passed with flaky tests

Results: 505 passed, 0 failed, 1 flaky, 8 skipped (Total: 514)

❌ Failed Tests

📊 Browser Reports
  • chromium: View Report (✅ 493 / ❌ 0 / ⚠️ 1 / ⏭️ 8)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 9 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

@benceruleanlu benceruleanlu marked this pull request as ready for review January 24, 2026 16:09
@benceruleanlu benceruleanlu requested a review from a team as a code owner January 24, 2026 16:09
Copilot AI review requested due to automatic review settings January 24, 2026 16:09
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jan 24, 2026
Copy link
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

Tracks asset selection anchor by asset id and introduces reconciliation logic intended to keep selection/anchor aligned with the currently visible asset list (plus a small queue overlay alignment update).

Changes:

  • Add lastSelectedAssetId to the asset selection Pinia store and clear it with selection resets.
  • Add anchor-by-id helpers and reconcileSelection(assets) to prune selection and resync anchor index.
  • Add Vitest coverage for prune/reorder/anchor-clear scenarios; update queue overlay to set anchor id when focusing an asset.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/platform/assets/composables/useAssetSelectionStore.ts Adds lastSelectedAssetId state + setter and resets it on clearSelection().
src/platform/assets/composables/useAssetSelection.ts Adds anchor-by-id tracking and reconcileSelection() API for pruning/resyncing selection/anchor.
src/platform/assets/composables/useAssetSelection.test.ts Adds tests covering pruning, reorder anchor resync, and anchor clearing.
src/components/queue/QueueProgressOverlay.vue Ensures queue “focus asset” selection also sets lastSelectedAssetId.

Comment on lines 266 to 268
assetSelectionStore.setSelection([assetId])
assetSelectionStore.setLastSelectedAssetId(assetId)
}
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

focusAssetInSidebar sets setSelection([assetId]) and now sets lastSelectedAssetId, but it leaves lastSelectedIndex unchanged. Since shift-range selection is keyed off lastSelectedIndex, this can produce an incorrect range anchored to a stale index after selecting from the queue overlay. Consider also resetting lastSelectedIndex (or setting it to the focused asset’s index when available) to keep the anchor state consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +25
const assets: AssetItem[] = [
{ id: 'a', name: 'a.png', tags: [] },
{ id: 'b', name: 'b.png', tags: [] }
]
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The test fixtures typed as AssetItem only provide { id, name, tags }, but AssetItem (from assetSchema) includes other required fields (e.g. asset_hash, mime_type, etc.). If the repo runs TypeScript typechecking in CI, this test file will fail to compile. Suggest using an existing AssetItem factory (or a local helper) that populates the required fields, or loosening the fixture typing (e.g. Partial<AssetItem> where appropriate).

Copilot uses AI. Check for mistakes.
Comment on lines +111 to +114
function reconcileSelection(assets: AssetItem[]) {
if (selectionStore.selectedAssetIds.size === 0) {
return
}
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

reconcileSelection is implemented and returned from the composable, but it isn’t called anywhere in the codebase (search shows only this file + its new test). Without wiring it to changes in the visible asset list (e.g., a watcher where displayAssets is derived), selection won’t actually be pruned/re-anchored at runtime as described in the PR summary.

Copilot uses AI. Check for mistakes.
Copy link
Member

@viva-jinyi viva-jinyi left a comment

Choose a reason for hiding this comment

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

LGTM

@benceruleanlu
Copy link
Member Author

Replaced by #8283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants