Skip to content

Commit a9efdcc

Browse files
JSKittyclaude
andcommitted
feat: differentiate audio files from voice messages in player UI
Show filename above waveform for uploaded audio files, hide transcription button for non-voice audio, and constrain player width to prevent long filenames from overflowing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2e06104 commit a9efdcc

2 files changed

Lines changed: 39 additions & 4 deletions

File tree

src/js/voice.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,9 @@ function handleAudioAttachment(cAttachment, pMessage, msg) {
13571357
playBtn.classList.add('audio-play-btn');
13581358
playBtn.innerHTML = '<span class="icon icon-play"></span>';
13591359

1360+
// Detect voice messages vs uploaded audio files
1361+
const isVoiceMessage = !cAttachment.name;
1362+
13601363
// Disable playback for pending (uploading) messages
13611364
const isPending = msg.mine && msg.pending;
13621365
if (isPending) {
@@ -1496,7 +1499,19 @@ function handleAudioAttachment(cAttachment, pMessage, msg) {
14961499

14971500
// Assemble custom player
14981501
customPlayer.appendChild(playBtn);
1499-
customPlayer.appendChild(waveform);
1502+
if (!isVoiceMessage && cAttachment.name) {
1503+
const waveformWrapper = document.createElement('div');
1504+
waveformWrapper.classList.add('audio-waveform-wrapper');
1505+
const filenameLabel = document.createElement('div');
1506+
filenameLabel.classList.add('audio-filename', 'cutoff');
1507+
filenameLabel.textContent = cAttachment.name;
1508+
filenameLabel.title = cAttachment.name;
1509+
waveformWrapper.appendChild(filenameLabel);
1510+
waveformWrapper.appendChild(waveform);
1511+
customPlayer.appendChild(waveformWrapper);
1512+
} else {
1513+
customPlayer.appendChild(waveform);
1514+
}
15001515
customPlayer.appendChild(timeDisplay);
15011516

15021517
audioContainer.appendChild(customPlayer);
@@ -1724,8 +1739,8 @@ function handleAudioAttachment(cAttachment, pMessage, msg) {
17241739

17251740
}
17261741

1727-
// Only add transcription UI for supported formats and platforms
1728-
if (platformFeatures.transcription && ['wav', 'mp3', 'flac'].includes(cAttachment.extension)) {
1742+
// Only add transcription UI for voice messages with supported formats
1743+
if (isVoiceMessage && platformFeatures.transcription && ['wav', 'mp3', 'flac'].includes(cAttachment.extension)) {
17291744
// Display the Transcribe button
17301745
customPlayer.appendChild(transcribeBtn);
17311746

src/styles.css

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4971,7 +4971,8 @@ select:disabled:hover {
49714971
border-radius: 12px;
49724972
position: relative;
49734973
overflow: hidden;
4974-
min-width: 280px;
4974+
width: min(500px, calc(100vw - 100px));
4975+
box-sizing: border-box;
49754976
transition: all 0.3s ease;
49764977
}
49774978

@@ -5080,6 +5081,25 @@ select:disabled:hover {
50805081
cursor: pointer;
50815082
}
50825083

5084+
.audio-waveform-wrapper {
5085+
display: flex;
5086+
flex-direction: column;
5087+
flex: 1;
5088+
width: 0;
5089+
gap: 2px;
5090+
margin: 0 8px;
5091+
}
5092+
5093+
.audio-waveform-wrapper .audio-waveform {
5094+
margin: 0;
5095+
}
5096+
5097+
.audio-filename {
5098+
font-size: 12px;
5099+
color: rgba(255, 255, 255, 0.8);
5100+
line-height: 1;
5101+
}
5102+
50835103
/* Visual feedback on hover */
50845104
.audio-waveform:hover {
50855105
opacity: 1;

0 commit comments

Comments
 (0)