Guess what? Fixed more bugs...

This commit is contained in:
2026-02-12 19:01:28 +01:00
parent abd1dfddd4
commit 2434e554f8
2 changed files with 7 additions and 31 deletions

View File

@@ -60,8 +60,6 @@ struct ChatView: View {
// Input bar
InputBar(
text: $viewModel.inputText,
commandHistory: $viewModel.commandHistory,
historyIndex: $viewModel.historyIndex,
isGenerating: viewModel.isGenerating,
mcpStatus: viewModel.mcpStatus,
onlineMode: viewModel.onlineMode,

View File

@@ -9,8 +9,6 @@ import SwiftUI
struct InputBar: View {
@Binding var text: String
@Binding var commandHistory: [String]
@Binding var historyIndex: Int
let isGenerating: Bool
let mcpStatus: String?
let onlineMode: Bool
@@ -81,44 +79,26 @@ struct InputBar: View {
.onChange(of: text) {
showCommandDropdown = text.hasPrefix("/")
selectedSuggestionIndex = 0
// Reset history index when user types
historyIndex = commandHistory.count
}
#if os(macOS)
.onKeyPress(.upArrow) {
// If command dropdown is showing, navigate dropdown
if showCommandDropdown {
if selectedSuggestionIndex > 0 {
selectedSuggestionIndex -= 1
}
// Navigate command dropdown
if showCommandDropdown && selectedSuggestionIndex > 0 {
selectedSuggestionIndex -= 1
return .handled
}
// Otherwise, navigate command history
if historyIndex > 0 {
historyIndex -= 1
text = commandHistory[historyIndex]
}
return .handled
return .ignored
}
.onKeyPress(.downArrow) {
// If command dropdown is showing, navigate dropdown
// Navigate command dropdown
if showCommandDropdown {
let count = CommandSuggestionsView.filteredCommands(for: text).count
if selectedSuggestionIndex < count - 1 {
selectedSuggestionIndex += 1
return .handled
}
return .handled
}
// Otherwise, navigate command history
if historyIndex < commandHistory.count - 1 {
historyIndex += 1
text = commandHistory[historyIndex]
} else if historyIndex == commandHistory.count - 1 {
// At the end of history, clear text and move to "new" position
historyIndex = commandHistory.count
text = ""
}
return .handled
return .ignored
}
.onKeyPress(.escape) {
// If command dropdown is showing, close it
@@ -352,8 +332,6 @@ struct CommandSuggestionsView: View {
Spacer()
InputBar(
text: .constant(""),
commandHistory: .constant([]),
historyIndex: .constant(0),
isGenerating: false,
mcpStatus: "📁 Files",
onlineMode: true,