diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/App.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/App.kt index 857eb33..e73839a 100644 --- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/App.kt +++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/App.kt @@ -207,6 +207,9 @@ private fun OpenClawRoot(appState: OpenClawAppState) { appState.retryMessage(activeSession.id, messageId) } }, + onCopyAttachmentName = { fileName -> + appState.feedbackMessage = "已复制文件名:$fileName" + }, ) appState.selectedTab == MainTab.Sessions -> SessionListScreen( diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt index 5c13ba7..8eaee15 100644 --- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt +++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt @@ -55,6 +55,7 @@ fun ChatScreen( onSendAttachmentStub: () -> Unit, onRetryAttachment: (String) -> Unit, onRetryMessage: (String) -> Unit, + onCopyAttachmentName: (String) -> Unit, ) { var input by remember { mutableStateOf("") } val listState = rememberLazyListState() @@ -181,6 +182,7 @@ fun ChatScreen( linkedToolName = linkedTool?.toolName, onRetryAttachment = onRetryAttachment, onRetryMessage = onRetryMessage, + onCopyAttachmentName = onCopyAttachmentName, ) } } @@ -241,6 +243,7 @@ private fun MessageBubble( linkedToolName: String? = null, onRetryAttachment: (String) -> Unit, onRetryMessage: (String) -> Unit, + onCopyAttachmentName: (String) -> Unit, ) { val alignment = when (message.role) { MessageRole.User -> Alignment.CenterEnd @@ -268,6 +271,7 @@ private fun MessageBubble( } var visibleChars by remember(message.id) { mutableIntStateOf(if (animateText) 0 else message.text.length) } var expanded by remember(message.id) { mutableStateOf(false) } + var attachmentDetailsExpanded by remember(message.id) { mutableStateOf(false) } LaunchedEffect(message.id, animateText) { if (animateText) { @@ -371,9 +375,32 @@ private fun MessageBubble( color = MaterialTheme.colorScheme.onSurfaceVariant, ) } - if (message.retryable && message.status == "upload-failed") { - TextButton(onClick = { onRetryAttachment(message.id) }) { - Text("重试上传") + Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) { + TextButton(onClick = { onCopyAttachmentName(message.text) }) { + Text("复制文件名") + } + TextButton(onClick = { attachmentDetailsExpanded = !attachmentDetailsExpanded }) { + Text(if (attachmentDetailsExpanded) "收起详情" else "查看详情") + } + if (message.retryable && message.status == "upload-failed") { + TextButton(onClick = { onRetryAttachment(message.id) }) { + Text("重试上传") + } + } + } + if (attachmentDetailsExpanded) { + Column( + modifier = Modifier + .fillMaxWidth() + .clip(androidx.compose.foundation.shape.RoundedCornerShape(12.dp)) + .background(MaterialTheme.colorScheme.surface.copy(alpha = 0.4f)) + .padding(10.dp), + verticalArrangement = Arrangement.spacedBy(4.dp), + ) { + Text("文件名:${message.text}", style = MaterialTheme.typography.bodySmall) + Text("类型:${message.contentType ?: "unknown"}", style = MaterialTheme.typography.bodySmall) + Text("大小:${message.sizeBytes?.let(::formatBytes) ?: "unknown"}", style = MaterialTheme.typography.bodySmall) + Text("状态:${displayStatus ?: "unknown"}", style = MaterialTheme.typography.bodySmall) } } } diff --git a/docs/MVP_PROGRESS.md b/docs/MVP_PROGRESS.md index 3ad9501..5d6040e 100644 --- a/docs/MVP_PROGRESS.md +++ b/docs/MVP_PROGRESS.md @@ -189,12 +189,12 @@ Android/iOS App ### 4.3 附件交互动作 -目前还没有: +目前: -- 点击附件打开 -- 下载附件 -- 复制文件名 -- 查看附件详情 +- [x] 复制文件名 +- [x] 查看附件详情 +- [ ] 点击附件打开 +- [ ] 下载附件 ### 4.4 iOS / Web 文件选择器