Guess what? Fixed more bugs...
This commit is contained in:
@@ -60,8 +60,6 @@ struct ChatView: View {
|
|||||||
// Input bar
|
// Input bar
|
||||||
InputBar(
|
InputBar(
|
||||||
text: $viewModel.inputText,
|
text: $viewModel.inputText,
|
||||||
commandHistory: $viewModel.commandHistory,
|
|
||||||
historyIndex: $viewModel.historyIndex,
|
|
||||||
isGenerating: viewModel.isGenerating,
|
isGenerating: viewModel.isGenerating,
|
||||||
mcpStatus: viewModel.mcpStatus,
|
mcpStatus: viewModel.mcpStatus,
|
||||||
onlineMode: viewModel.onlineMode,
|
onlineMode: viewModel.onlineMode,
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import SwiftUI
|
|||||||
|
|
||||||
struct InputBar: View {
|
struct InputBar: View {
|
||||||
@Binding var text: String
|
@Binding var text: String
|
||||||
@Binding var commandHistory: [String]
|
|
||||||
@Binding var historyIndex: Int
|
|
||||||
let isGenerating: Bool
|
let isGenerating: Bool
|
||||||
let mcpStatus: String?
|
let mcpStatus: String?
|
||||||
let onlineMode: Bool
|
let onlineMode: Bool
|
||||||
@@ -81,44 +79,26 @@ struct InputBar: View {
|
|||||||
.onChange(of: text) {
|
.onChange(of: text) {
|
||||||
showCommandDropdown = text.hasPrefix("/")
|
showCommandDropdown = text.hasPrefix("/")
|
||||||
selectedSuggestionIndex = 0
|
selectedSuggestionIndex = 0
|
||||||
// Reset history index when user types
|
|
||||||
historyIndex = commandHistory.count
|
|
||||||
}
|
}
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
.onKeyPress(.upArrow) {
|
.onKeyPress(.upArrow) {
|
||||||
// If command dropdown is showing, navigate dropdown
|
// Navigate command dropdown
|
||||||
if showCommandDropdown {
|
if showCommandDropdown && selectedSuggestionIndex > 0 {
|
||||||
if selectedSuggestionIndex > 0 {
|
selectedSuggestionIndex -= 1
|
||||||
selectedSuggestionIndex -= 1
|
|
||||||
}
|
|
||||||
return .handled
|
return .handled
|
||||||
}
|
}
|
||||||
// Otherwise, navigate command history
|
return .ignored
|
||||||
if historyIndex > 0 {
|
|
||||||
historyIndex -= 1
|
|
||||||
text = commandHistory[historyIndex]
|
|
||||||
}
|
|
||||||
return .handled
|
|
||||||
}
|
}
|
||||||
.onKeyPress(.downArrow) {
|
.onKeyPress(.downArrow) {
|
||||||
// If command dropdown is showing, navigate dropdown
|
// Navigate command dropdown
|
||||||
if showCommandDropdown {
|
if showCommandDropdown {
|
||||||
let count = CommandSuggestionsView.filteredCommands(for: text).count
|
let count = CommandSuggestionsView.filteredCommands(for: text).count
|
||||||
if selectedSuggestionIndex < count - 1 {
|
if selectedSuggestionIndex < count - 1 {
|
||||||
selectedSuggestionIndex += 1
|
selectedSuggestionIndex += 1
|
||||||
|
return .handled
|
||||||
}
|
}
|
||||||
return .handled
|
|
||||||
}
|
}
|
||||||
// Otherwise, navigate command history
|
return .ignored
|
||||||
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
|
|
||||||
}
|
}
|
||||||
.onKeyPress(.escape) {
|
.onKeyPress(.escape) {
|
||||||
// If command dropdown is showing, close it
|
// If command dropdown is showing, close it
|
||||||
@@ -352,8 +332,6 @@ struct CommandSuggestionsView: View {
|
|||||||
Spacer()
|
Spacer()
|
||||||
InputBar(
|
InputBar(
|
||||||
text: .constant(""),
|
text: .constant(""),
|
||||||
commandHistory: .constant([]),
|
|
||||||
historyIndex: .constant(0),
|
|
||||||
isGenerating: false,
|
isGenerating: false,
|
||||||
mcpStatus: "📁 Files",
|
mcpStatus: "📁 Files",
|
||||||
onlineMode: true,
|
onlineMode: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user