Bug gixes, features added, GUI updates and more

This commit is contained in:
2026-02-12 14:29:35 +01:00
parent 52447b5e17
commit 7265d22438
21 changed files with 2187 additions and 123 deletions

View File

@@ -9,6 +9,8 @@ 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
@@ -22,7 +24,7 @@ struct InputBar: View {
/// Commands that execute immediately without additional arguments
private static let immediateCommands: Set<String> = [
"/help", "/model", "/clear", "/retry", "/stats", "/config",
"/help", "/history", "/model", "/clear", "/retry", "/stats", "/config",
"/settings", "/credits", "/list", "/load",
"/memory on", "/memory off", "/online on", "/online off",
"/mcp on", "/mcp off", "/mcp status", "/mcp list",
@@ -79,28 +81,56 @@ 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) {
guard showCommandDropdown else { return .ignored }
if selectedSuggestionIndex > 0 {
selectedSuggestionIndex -= 1
// If command dropdown is showing, navigate dropdown
if showCommandDropdown {
if selectedSuggestionIndex > 0 {
selectedSuggestionIndex -= 1
}
return .handled
}
// Otherwise, navigate command history
if historyIndex > 0 {
historyIndex -= 1
text = commandHistory[historyIndex]
}
return .handled
}
.onKeyPress(.downArrow) {
guard showCommandDropdown else { return .ignored }
let count = CommandSuggestionsView.filteredCommands(for: text).count
if selectedSuggestionIndex < count - 1 {
selectedSuggestionIndex += 1
// If command dropdown is showing, navigate dropdown
if showCommandDropdown {
let count = CommandSuggestionsView.filteredCommands(for: text).count
if selectedSuggestionIndex < count - 1 {
selectedSuggestionIndex += 1
}
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
}
.onKeyPress(.escape) {
// If command dropdown is showing, close it
if showCommandDropdown {
showCommandDropdown = false
return .handled
}
// If model is generating, cancel it
if isGenerating {
onCancel()
return .handled
}
return .ignored
}
.onKeyPress(.return) {
@@ -227,6 +257,7 @@ struct CommandSuggestionsView: View {
static let allCommands: [(command: String, description: String)] = [
("/help", "Show help and available commands"),
("/history", "View command history"),
("/model", "Select AI model"),
("/clear", "Clear chat history"),
("/retry", "Retry last message"),
@@ -316,6 +347,8 @@ struct CommandSuggestionsView: View {
Spacer()
InputBar(
text: .constant(""),
commandHistory: .constant([]),
historyIndex: .constant(0),
isGenerating: false,
mcpStatus: "📁 Files",
onlineMode: true,