Skip to content

feat: highlight new pairings, dashboard sorted by filename - #1377

Open
giannatan wants to merge 4 commits into
developfrom
gianna/highlight-sort-file-pairings
Open

feat: highlight new pairings, dashboard sorted by filename#1377
giannatan wants to merge 4 commits into
developfrom
gianna/highlight-sort-file-pairings

Conversation

@giannatan

@giannatan giannatan commented Jul 23, 2026

Copy link
Copy Markdown

ref: issue #1316

Summary by CodeRabbit

  • New Features

    • Newly uploaded documents are highlighted briefly with a visual pulse, making them easier to identify.
    • Uploaded file names are displayed more clearly after a successful upload.
  • Improvements

    • Dashboard entries are sorted consistently when folders are refreshed.
    • Upload processing provides clearer results for successfully added documents.
    • Overlapping upload attempts are prevented, and upload state resets reliably after completion or errors.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds dashboard highlighting for newly uploaded documents. Upload results now include entry IDs and names. The upload flow prevents overlapping batches, records successful IDs before refresh, and resets pending state after completion. Dashboard rendering sorts the current folder and applies animated highlighting to matching tiles.

Changes

Dashboard upload highlight flow

Layer / File(s) Summary
Upload result and completion flow
src/Dashboard/UploadTools.ts, src/Dashboard/UploadArea.ts
Upload helpers return { id, name } for successful uploads. The upload flow tracks pending batches, records successful IDs, displays uploaded names, and resets state after success or error handling.
Sorted render and tile highlight
src/Dashboard/Dashboard.ts, src/Dashboard/FileSystem/FileSystemTools.ts, deployment/server/css/dashboard.css
sortFolder is exposed for dashboard use. Dashboard state tracks newly uploaded IDs, sorts the current folder before rendering, and adds the new-upload class to matching tiles. CSS defines the pulse animation and highlighted tile style.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant UploadArea
  participant UploadTools
  participant Dashboard
  UploadArea->>UploadTools: handleUploadAllDocuments(currentFolder)
  UploadTools-->>UploadArea: fulfilled values with { id, name }
  UploadArea->>Dashboard: markNewlyUploaded(successfulFiles.map(id))
  UploadArea->>Dashboard: updateDashboard()
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: highlighting new pairings and sorting the dashboard by filename.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch gianna/highlight-sort-file-pairings

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

deployment/server/css/dashboard.css

Parsing error: Declaration expected.


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.

@zih-syuan zih-syuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please rebase this branch onto the latest develop. Thank you!!

Comment thread src/Dashboard/UploadArea.ts Outdated
if (successfulFiles.length > 0) {
const infoBadge = document.getElementById('info-badge');
infoBadge.textContent = `Uploaded files: ${successfulFiles.join(
infoBadge.textContent = `Uplaoded files: ${successfulFiles.join(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this a typo? Should be Uploaded files

Comment thread src/Dashboard/UploadArea.ts Outdated
.map((result) => result.value);

setTimeout(async () => {
if (successfulFiles.length > 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If batch A succeeds and the next batch has no successful uploads, this guard skips markNewlyUploaded(), so batch A remains highlighted. Could we call it unconditionally so an empty result clears the previous highlight?

Comment thread src/Dashboard/Dashboard.ts Outdated
container.classList.add('document-entry');
container.setAttribute('draggable', 'true'); // make file or folder draggable

if (newlyUploadedNames.has(entry.name)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Different folders can contain entries with the same filename. Since this set persists across folder navigation and createTile() checks only entry.name, an entry in another folder could be highlighted incorrectly. Could this be scoped to the upload folder or track entry IDs?

Comment thread .gitignore Outdated
/cypress/downloads

.idea
.nvmrc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is ignoring .nvmrc related to this feature? If it is only a local file, could this unrelated change be removed from the PR?

@giannatan
giannatan force-pushed the gianna/highlight-sort-file-pairings branch from 3b71837 to 2db961d Compare August 5, 2026 13:13

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Dashboard/UploadArea.ts`:
- Around line 24-26: Update the upload flow around handleUploadAllDocuments and
the delayed markNewlyUploaded callback so overlapping batches cannot replace
highlights from a newer batch. Either disable the upload action until the
pending batch and its callback complete, or track a monotonically increasing
batch token and ignore callbacks from older batches while preserving the current
updateDashboard behavior.
- Around line 20-22: Update the successfulFiles filtering in
handleUploadAllDocuments() to use an explicit type predicate for fulfilled
results, narrowing the result value to a non-null, non-undefined upload value
before mapping. Preserve the existing exclusion of rejected results and empty
optional values.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8d4c7d82-c7c0-4e39-ba2a-10513496f661

📥 Commits

Reviewing files that changed from the base of the PR and between 9c36b02 and 3b71837.

📒 Files selected for processing (5)
  • deployment/server/css/dashboard.css
  • src/Dashboard/Dashboard.ts
  • src/Dashboard/FileSystem/FileSystemTools.ts
  • src/Dashboard/UploadArea.ts
  • src/Dashboard/UploadTools.ts

Comment thread src/Dashboard/UploadArea.ts
Comment thread src/Dashboard/UploadArea.ts Outdated
modalWindow: ModalWindow,
currentFolder: IFolder,
) {
if (isUploadPending) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we reset isUploadPending in a finally block in both paths? If updateDashboard() throws, the current reset line will not be reached, so all subsequent upload attempts will remain blocked until the page is reloaded.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Dashboard/UploadArea.ts`:
- Around line 49-79: Update both delayed async callbacks in the upload success
and error paths to handle updateDashboard() rejections within the setTimeout
callback. Move spinner removal and modalWindow.hideModalWindow() into each
callback’s finally block, alongside resetting isUploadPending, so cleanup always
runs; preserve the existing success-only info-badge behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a479e0c-0188-48a1-b8b7-1a75e0fa41d4

📥 Commits

Reviewing files that changed from the base of the PR and between 3b71837 and 6575361.

📒 Files selected for processing (3)
  • deployment/server/css/dashboard.css
  • src/Dashboard/UploadArea.ts
  • src/Dashboard/UploadTools.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • deployment/server/css/dashboard.css
  • src/Dashboard/UploadTools.ts

Comment on lines +49 to 79
setTimeout(async () => {
try {
markNewlyUploaded(successfulFiles.map((file) => file.id));
await updateDashboard();
spinner.classList.remove('visible');
modalWindow.hideModalWindow();

if (successfulFiles.length > 0) {
const infoBadge = document.getElementById('info-badge');
infoBadge.textContent = `Uploaded files: ${successfulFiles.join(
', ',
)}`;
infoBadge.style.display = 'block';
infoBadge.style.background = '#9DB2BF';
if (successfulFiles.length > 0) {
const infoBadge = document.getElementById('info-badge');
infoBadge.textContent = `Uploaded files: ${successfulFiles
.map((file) => file.name)
.join(', ')}`;
infoBadge.style.display = 'block';
infoBadge.style.background = '#9DB2BF';
}
} finally {
isUploadPending = false;
}
}, 2000);
})
.catch((error) => {
console.log('One or more uploads rejected: ', error);
setTimeout(async () => {
await updateDashboard();
spinner.classList.remove('visible');
modalWindow.hideModalWindow();
try {
await updateDashboard();
spinner.classList.remove('visible');
modalWindow.hideModalWindow();
} finally {
isUploadPending = false;
}
}, 2000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Handle failures inside the delayed callbacks.

Line 49 and Line 71 create async callbacks that setTimeout() does not await. If updateDashboard() rejects, the outer .catch() cannot handle that rejection. The spinner and modal can remain visible because their cleanup lines do not run.

Catch errors inside each delayed callback. Move spinner and modal cleanup into finally.

Proposed fix
-setTimeout(async () => {
+setTimeout(() => {
+  void (async () => {
     try {
       markNewlyUploaded(successfulFiles.map((file) => file.id));
       await updateDashboard();
-      spinner.classList.remove('visible');
-      modalWindow.hideModalWindow();
-
       if (successfulFiles.length > 0) {
         // ...
       }
+    } catch (error) {
+      console.error('Could not refresh dashboard after upload:', error);
     } finally {
+      spinner.classList.remove('visible');
+      modalWindow.hideModalWindow();
       isUploadPending = false;
     }
-}, 2000);
+  })();
+}, 2000);

Apply the same pattern to the error-path callback.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Dashboard/UploadArea.ts` around lines 49 - 79, Update both delayed async
callbacks in the upload success and error paths to handle updateDashboard()
rejections within the setTimeout callback. Move spinner removal and
modalWindow.hideModalWindow() into each callback’s finally block, alongside
resetting isUploadPending, so cleanup always runs; preserve the existing
success-only info-badge behavior.

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.

When you upload a new pairing, the color/highlight is different from the surrounding items initially

2 participants