Skip to content

fix: extract filename from path in S3 widget preview#1587

Merged
gugu merged 2 commits into
mainfrom
fix/s3-widget-filename-display
Feb 10, 2026
Merged

fix: extract filename from path in S3 widget preview#1587
gugu merged 2 commits into
mainfrom
fix/s3-widget-filename-display

Conversation

@gugu

@gugu gugu commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Previously used slice:-30 which blindly cut the last 30 characters, showing broken paths like "etana/Desktop/X2TQS.txt" instead of the actual filename.

Previously used slice:-30 which blindly cut the last 30 characters,
showing broken paths like "etana/Desktop/X2TQS.txt" instead of the
actual filename.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 10, 2026 12:25
@gugu gugu enabled auto-merge (squash) February 10, 2026 12:28

Copilot AI 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.

Pull request overview

This PR fixes the S3 record-edit widget’s preview label to display the actual filename extracted from an S3 key/path instead of blindly slicing the last 30 characters (which could show broken partial paths).

Changes:

  • Add a displayFilename computed signal that extracts the last path segment and truncates long filenames with an ellipsis.
  • Update the S3 widget preview template to use displayFilename() instead of the slice:-30 pipe.

Reviewed changes

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

File Description
frontend/src/app/components/ui-components/record-edit-fields/s3/s3.component.ts Adds computed logic to extract and truncate the displayed filename from the stored S3 key/path.
frontend/src/app/components/ui-components/record-edit-fields/s3/s3.component.html Switches the preview filename rendering to use the new computed value.

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

Comment on lines +72 to +77
readonly displayFilename = computed(() => {
const val = this.internalValue() || this.value();
if (!val) return '';
const name = val.split('/').pop() || val;
return name.length > 40 ? '...' + name.slice(-37) : name;
});

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

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

Add/adjust unit tests for the new displayFilename computed behavior. There are existing component/spec tests, but they currently only assert that the filename element exists; they should now assert that a path-like key (e.g., uploads/document.pdf) renders just document.pdf, and that long filenames are truncated according to the new 40-char/ellipsis logic.

Copilot uses AI. Check for mistakes.
Comment on lines +75 to +76
const name = val.split('/').pop() || val;
return name.length > 40 ? '...' + name.slice(-37) : name;

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

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

displayFilename uses magic numbers (40 and 37) to implement truncation. Consider extracting these into named constants (e.g., maxDisplayLength / tailLength) so the intent is clearer and future changes don’t risk off-by-one mistakes.

Copilot uses AI. Check for mistakes.
@gugu gugu merged commit 4ced7d4 into main Feb 10, 2026
14 checks passed
@gugu gugu deleted the fix/s3-widget-filename-display branch February 10, 2026 12:31
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.

2 participants