fix(#135): guard goBack() against empty back stack (#157)

goBack() now uses ChatScreen as a fallback when the stack has
only one item, preventing the Settings back-button crash.

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
M57andM57 authored and GitHub committed 2026-06-20 13:29:19 +03:00
1 parent 62b1115924
commit c6d7a45905
2 files changed
+16 -6

No files matched your search

+5 -4
View File
@@ -110,11 +110,12 @@ git push -u origin HEAD
gh pr create --title "fix(#N): description" --body "Closes #N"
```
### Commit Conventions
### Commit Conventions — STRICT
- **NO co-author trailer.** No `Co-Authored-By`, no `Generated with ...`. Ever.
- **Short commits:** subject line + max 2 lines of body. Split into atomic commits
rather than writing long bodies.
**🚫 NEVER add yourself as author or co-author.** The agent must never appear in any commit metadata field — not as author, not as `Co-Authored-By`, not in `Generated with`, not anywhere.
- **No `--author` override.** Use the default git config. Always.
- **Short commits:** subject line + max 2 lines of body. Split into atomic commits rather than writing long bodies.
- **Conventional Commits** types: `feat`, `fix`, `refactor`, `docs`, `test`, `ci`, `chore`.
- Bug fixes annotated inline: `// B7 (Jun 18 2026, kanban t_xxx): description`.
@@ -53,8 +53,17 @@ object NavigationController {
backStack?.add(key)
}
fun goBack() {
/**
* Navigate back one step, or fall back to [fallback] when the stack has only one item.
* Never leaves the stack empty.
*/
fun goBack(fallback: NavKey = ChatScreen) {
val stack = backStack ?: return
if (stack.size > 1) stack.removeLastOrNull()
if (stack.size > 1) {
stack.removeLastOrNull()
} else if (stack.size == 1) {
stack.clear()
stack.add(fallback)
}
}
}