From 5b8ddf0a20065b960751d6936b4841a7e7b81201 Mon Sep 17 00:00:00 2001 From: nrobi144 Date: Fri, 17 Apr 2026 13:47:17 +0300 Subject: [PATCH] fix(desktop): review fixes for navigation overhaul - Fix right-click detection: use isSecondaryPressed (not button.index==2) - Fix parseColumnType missing drafts/highlights/editor/article cases - Fix param extraction for Editor.draftSlug and Article.addressTag - Fix deleteWorkspace index correction logic Co-Authored-By: Claude Opus 4.6 (1M context) --- .../amethyst/desktop/ui/deck/AppDrawer.kt | 6 ++++-- .../amethyst/desktop/ui/deck/DeckState.kt | 6 ++++++ .../desktop/ui/deck/WorkspaceManager.kt | 17 ++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/AppDrawer.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/AppDrawer.kt index eabbf78d4..7f74a8e60 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/AppDrawer.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/AppDrawer.kt @@ -78,6 +78,7 @@ import androidx.compose.ui.input.key.key import androidx.compose.ui.input.key.onPreviewKeyEvent import androidx.compose.ui.input.key.type import androidx.compose.ui.input.pointer.PointerEventType +import androidx.compose.ui.input.pointer.isSecondaryPressed import androidx.compose.ui.input.pointer.onPointerEvent import androidx.compose.ui.unit.dp import kotlinx.coroutines.delay @@ -405,8 +406,9 @@ private fun DrawerScreenCard( .clickable(onClick = onClick) .onPointerEvent(PointerEventType.Enter) { onHover() } .onPointerEvent(PointerEventType.Press) { event -> - // Right-click opens context menu - if (event.changes.any { it.pressed && event.button?.index == 2 }) { + if (event.buttons.isSecondaryPressed && + event.changes.any { it.pressed && !it.previousPressed } + ) { showMenu = true } }, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckState.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckState.kt index 6c033deaf..cd66cd024 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckState.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckState.kt @@ -226,6 +226,8 @@ class DeckState( is DeckColumnType.Profile -> col.type.pubKeyHex is DeckColumnType.Thread -> col.type.noteId is DeckColumnType.Hashtag -> col.type.tag + is DeckColumnType.Editor -> col.type.draftSlug + is DeckColumnType.Article -> col.type.addressTag else -> null }, ) @@ -299,6 +301,10 @@ class DeckState( "my_profile" -> DeckColumnType.MyProfile "chess" -> DeckColumnType.Chess "settings" -> DeckColumnType.Settings + "drafts" -> DeckColumnType.Drafts + "highlights" -> DeckColumnType.MyHighlights + "editor" -> DeckColumnType.Editor(param) + "article" -> param?.let { DeckColumnType.Article(it) } "profile" -> param?.let { DeckColumnType.Profile(it) } "thread" -> param?.let { DeckColumnType.Thread(it) } "hashtag" -> param?.let { DeckColumnType.Hashtag(it) } diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/WorkspaceManager.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/WorkspaceManager.kt index 4317f10ca..f8ebd1e8e 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/WorkspaceManager.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/WorkspaceManager.kt @@ -68,6 +68,8 @@ class WorkspaceManager( is DeckColumnType.Profile -> col.type.pubKeyHex is DeckColumnType.Thread -> col.type.noteId is DeckColumnType.Hashtag -> col.type.tag + is DeckColumnType.Editor -> col.type.draftSlug + is DeckColumnType.Article -> col.type.addressTag else -> null }, width = col.width, @@ -97,14 +99,15 @@ class WorkspaceManager( fun deleteWorkspace(id: String) { if (_workspaces.value.size <= 1) return - val idx = _workspaces.value.indexOfFirst { it.id == id } + val deletedIdx = _workspaces.value.indexOfFirst { it.id == id } + if (deletedIdx < 0) return _workspaces.update { it.filter { ws -> ws.id != id } } - if (_activeIndex.value >= _workspaces.value.size) { - _activeIndex.value = _workspaces.value.size - 1 - } - if (idx == _activeIndex.value || _activeIndex.value >= _workspaces.value.size) { - _activeIndex.value = 0 - } + _activeIndex.value = + when { + deletedIdx < _activeIndex.value -> _activeIndex.value - 1 + deletedIdx == _activeIndex.value -> 0 + else -> _activeIndex.value + }.coerceIn(_workspaces.value.indices) scheduleSave() }