Compare commits
2 commits
44ff82a66d
...
b2df7e9330
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2df7e9330 | ||
|
|
8f72afd714 |
3 changed files with 38 additions and 10 deletions
|
|
@ -447,6 +447,7 @@ fun MessageRow(
|
||||||
onCopy: (String) -> Unit = {},
|
onCopy: (String) -> Unit = {},
|
||||||
onDelete: ((String) -> Unit)? = null,
|
onDelete: ((String) -> Unit)? = null,
|
||||||
onRegenerate: ((String) -> Unit)? = null,
|
onRegenerate: ((String) -> Unit)? = null,
|
||||||
|
onEdit: ((String, String) -> Unit)? = null,
|
||||||
onReadAloud: ((String) -> Unit)? = null,
|
onReadAloud: ((String) -> Unit)? = null,
|
||||||
isPlayingTts: Boolean = false,
|
isPlayingTts: Boolean = false,
|
||||||
) {
|
) {
|
||||||
|
|
@ -530,11 +531,11 @@ fun MessageRow(
|
||||||
if (!message.streaming) {
|
if (!message.streaming) {
|
||||||
Row(
|
Row(
|
||||||
Modifier.padding(top = 6.dp, end = 4.dp),
|
Modifier.padding(top = 6.dp, end = 4.dp),
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
horizontalArrangement = Arrangement.spacedBy(2.dp),
|
||||||
) {
|
) {
|
||||||
MessageActionButton(
|
MessageActionButton(
|
||||||
icon = if (copied) KaizenIcons.Check else KaizenIcons.Copy,
|
icon = if (copied) KaizenIcons.Check else KaizenIcons.ClipboardCopy,
|
||||||
tint = if (copied) Color(0xFF10B981) else cs.onSurfaceVariant.copy(alpha = 0.50f),
|
tint = if (copied) Color(0xFF10B981) else cs.onSurfaceVariant.copy(alpha = 0.55f),
|
||||||
) {
|
) {
|
||||||
haptics.tick()
|
haptics.tick()
|
||||||
copied = true
|
copied = true
|
||||||
|
|
@ -544,6 +545,13 @@ fun MessageRow(
|
||||||
copied = false
|
copied = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (message.content.isNotBlank()) {
|
||||||
|
onEdit?.let { edit ->
|
||||||
|
MessageActionButton(KaizenIcons.SquarePen, cs.onSurfaceVariant.copy(alpha = 0.55f)) {
|
||||||
|
haptics.tick(); edit(message.wireId, message.content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
onDelete?.let { del ->
|
onDelete?.let { del ->
|
||||||
MessageActionButton(KaizenIcons.Trash, Color(0xFFEF4444).copy(alpha = 0.70f)) {
|
MessageActionButton(KaizenIcons.Trash, Color(0xFFEF4444).copy(alpha = 0.70f)) {
|
||||||
haptics.tick(); del(message.wireId)
|
haptics.tick(); del(message.wireId)
|
||||||
|
|
@ -583,11 +591,11 @@ fun MessageRow(
|
||||||
if (!message.streaming && !message.thinking && message.content.isNotBlank()) {
|
if (!message.streaming && !message.thinking && message.content.isNotBlank()) {
|
||||||
Row(
|
Row(
|
||||||
Modifier.padding(start = 38.dp, top = 6.dp),
|
Modifier.padding(start = 38.dp, top = 6.dp),
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
horizontalArrangement = Arrangement.spacedBy(2.dp),
|
||||||
) {
|
) {
|
||||||
MessageActionButton(
|
MessageActionButton(
|
||||||
icon = if (copied) KaizenIcons.Check else KaizenIcons.Copy,
|
icon = if (copied) KaizenIcons.Check else KaizenIcons.ClipboardCopy,
|
||||||
tint = if (copied) Color(0xFF10B981) else cs.onSurfaceVariant.copy(alpha = 0.50f),
|
tint = if (copied) Color(0xFF10B981) else cs.onSurfaceVariant.copy(alpha = 0.55f),
|
||||||
) {
|
) {
|
||||||
haptics.tick()
|
haptics.tick()
|
||||||
copied = true
|
copied = true
|
||||||
|
|
@ -600,13 +608,13 @@ fun MessageRow(
|
||||||
onReadAloud?.let { readAloud ->
|
onReadAloud?.let { readAloud ->
|
||||||
MessageActionButton(
|
MessageActionButton(
|
||||||
icon = KaizenIcons.Volume2,
|
icon = KaizenIcons.Volume2,
|
||||||
tint = if (isPlayingTts) accent.primary else cs.onSurfaceVariant.copy(alpha = 0.50f),
|
tint = if (isPlayingTts) accent.primary else cs.onSurfaceVariant.copy(alpha = 0.55f),
|
||||||
) {
|
) {
|
||||||
haptics.tick(); readAloud(message.content)
|
haptics.tick(); readAloud(message.content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onRegenerate?.let { regen ->
|
onRegenerate?.let { regen ->
|
||||||
MessageActionButton(KaizenIcons.RefreshCw, cs.onSurfaceVariant.copy(alpha = 0.50f)) {
|
MessageActionButton(KaizenIcons.RotateCcw, cs.onSurfaceVariant.copy(alpha = 0.55f)) {
|
||||||
haptics.tick(); regen(message.wireId)
|
haptics.tick(); regen(message.wireId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -672,12 +680,12 @@ private fun VoiceWaveform(amplitude: Float) {
|
||||||
private fun MessageActionButton(icon: ImageVector, tint: Color, onClick: () -> Unit) {
|
private fun MessageActionButton(icon: ImageVector, tint: Color, onClick: () -> Unit) {
|
||||||
Box(
|
Box(
|
||||||
Modifier
|
Modifier
|
||||||
.size(32.dp)
|
.size(36.dp)
|
||||||
.clip(KaizenShapes.circle)
|
.clip(KaizenShapes.circle)
|
||||||
.clickable(onClick = onClick),
|
.clickable(onClick = onClick),
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
) {
|
) {
|
||||||
Icon(icon, null, tint = tint, modifier = Modifier.size(18.dp))
|
Icon(icon, null, tint = tint, modifier = Modifier.size(20.dp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -883,6 +883,22 @@ fun ChatScreen(
|
||||||
send(userContent)
|
send(userContent)
|
||||||
}
|
}
|
||||||
} else null,
|
} else null,
|
||||||
|
onEdit = if (message.role == Role.User && !isStreaming) { wireId, content ->
|
||||||
|
val idx = messages.indexOfFirst { it.wireId == wireId }
|
||||||
|
if (idx >= 0) {
|
||||||
|
val cfg = session.config ?: return@MessageRow
|
||||||
|
val toRemove = messages.subList(idx, messages.size).map { it.wireId }
|
||||||
|
messages.removeAll { it.wireId in toRemove }
|
||||||
|
if (conversationId != null) {
|
||||||
|
scope.launch {
|
||||||
|
toRemove.forEach { id ->
|
||||||
|
KaizenApi.deleteMessage(cfg.baseUrl, cfg.token, conversationId!!, id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
input = content
|
||||||
|
}
|
||||||
|
} else null,
|
||||||
onReadAloud = if (message.role == Role.Assistant && !message.streaming && message.content.isNotBlank()) { content ->
|
onReadAloud = if (message.role == Role.Assistant && !message.streaming && message.content.isNotBlank()) { content ->
|
||||||
readAloud(content, message.id, message.wireId)
|
readAloud(content, message.id, message.wireId)
|
||||||
} else null,
|
} else null,
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,17 @@ object KaizenIcons {
|
||||||
|
|
||||||
// ── Conversation management ─────────────────────────────────────────────
|
// ── Conversation management ─────────────────────────────────────────────
|
||||||
val Check: ImageVector get() = Lucide.Check
|
val Check: ImageVector get() = Lucide.Check
|
||||||
|
val ClipboardCopy: ImageVector get() = Lucide.ClipboardCopy
|
||||||
val Copy: ImageVector get() = Lucide.Copy
|
val Copy: ImageVector get() = Lucide.Copy
|
||||||
val Lock: ImageVector get() = Lucide.Lock
|
val Lock: ImageVector get() = Lucide.Lock
|
||||||
val LockOpen: ImageVector get() = Lucide.LockOpen
|
val LockOpen: ImageVector get() = Lucide.LockOpen
|
||||||
val Pencil: ImageVector get() = Lucide.Pencil
|
val Pencil: ImageVector get() = Lucide.Pencil
|
||||||
|
val PenLine: ImageVector get() = Lucide.PenLine
|
||||||
val Pin: ImageVector get() = Lucide.Pin
|
val Pin: ImageVector get() = Lucide.Pin
|
||||||
val PinOff: ImageVector get() = Lucide.PinOff
|
val PinOff: ImageVector get() = Lucide.PinOff
|
||||||
val RefreshCw: ImageVector get() = Lucide.RefreshCw
|
val RefreshCw: ImageVector get() = Lucide.RefreshCw
|
||||||
|
val RotateCcw: ImageVector get() = Lucide.RotateCcw
|
||||||
|
val SquarePen: ImageVector get() = Lucide.SquarePen
|
||||||
val Star: ImageVector get() = Lucide.Star
|
val Star: ImageVector get() = Lucide.Star
|
||||||
val StarOff: ImageVector get() = Lucide.StarOff
|
val StarOff: ImageVector get() = Lucide.StarOff
|
||||||
val Trash: ImageVector get() = Lucide.Trash2
|
val Trash: ImageVector get() = Lucide.Trash2
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue