Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
63af3b4
Merge tag '0.27.0' into develop
intitni Nov 9, 2023
651b639
Support retrieval in context aware prompt to code
intitni Nov 16, 2023
ba79efd
Update
intitni Nov 16, 2023
221a034
Merge tag '0.27.1' into develop
intitni Nov 18, 2023
6e0895c
Rename FocusCodeFinder to FocusCodeFinderType
intitni Nov 16, 2023
9c47de5
Simplify interface of focused code finder
intitni Nov 16, 2023
1d89fcc
Remove tree sitter for Swift
intitni Nov 25, 2023
6b040e3
Update syntax tree dump
intitni Nov 25, 2023
71bc6e7
Fix code finder tests
intitni Nov 26, 2023
2b027e9
Update focused code finder
intitni Nov 26, 2023
3516f57
Fix imports
intitni Nov 26, 2023
f9c5301
Add ObjectiveCFocusedCodeFinder
intitni Nov 26, 2023
3e807b0
Update
intitni Nov 26, 2023
975a1df
Fix SwiftFocusedCodeFinderTests
intitni Nov 26, 2023
72035e7
Fix parseSignatureBeforeBody
intitni Nov 26, 2023
7dcd116
Simplify contextContainingNode
intitni Nov 26, 2023
3a0b5e5
Fix super class and protocol conformance parsing
intitni Nov 27, 2023
b17d282
Add parseDeclarationInterfaceNode to parse all declaration contexts
intitni Nov 27, 2023
2749e2e
Fix parsing includes and imports
intitni Nov 27, 2023
f4ea0f6
Fix focused code
intitni Nov 27, 2023
e8c3ba4
Update
intitni Nov 27, 2023
ecfdfc0
Merge branch 'feature/objective-c-code-finder' into develop
intitni Nov 27, 2023
6d22d48
Add AutoresizingCustomTextEditor
intitni Nov 28, 2023
1305c72
Rename SuggestionProvider to CodeSuggestionProvider
intitni Nov 28, 2023
02900cb
Update
intitni Nov 28, 2023
e5967e0
Merge branch 'feature/informative-suggestion-wip' into develop
intitni Nov 30, 2023
03882d7
Update the context system prompt to use role user
intitni Nov 30, 2023
bc39122
Adjust the prompt in chat
intitni Nov 30, 2023
a1c1043
Rename ChatMessage in chat panel to DisplayedChatMessage
intitni Nov 30, 2023
9b22c29
Add references to chat message
intitni Nov 30, 2023
94aaade
Change the definition of a memory
intitni Nov 30, 2023
68ea73b
Update RetrievedContent in ChatContext
intitni Nov 30, 2023
ba592c2
Support displaying references in chat panel
intitni Dec 1, 2023
aac293e
Break ChatPanel.swift into multiple files
intitni Dec 1, 2023
be2376a
Update to stream references to message
intitni Dec 1, 2023
1925397
Support opening references in Xcode
intitni Dec 1, 2023
774216b
Support jump to specific line of reference file
intitni Dec 1, 2023
5d57f90
Fix the UI of reference list
intitni Dec 1, 2023
01bcaad
Fix opening reference
intitni Dec 1, 2023
353c686
Fix cancellation
intitni Dec 2, 2023
9c3840d
Update
intitni Dec 2, 2023
46da74c
Support providing history compose logic from other types
intitni Dec 2, 2023
67221f4
Update
intitni Dec 2, 2023
2b317fd
Update prompt of prompt to code
intitni Dec 2, 2023
b3ae4ec
Fix that context retriever was incorrect when the context is too long
intitni Dec 2, 2023
6c129d7
Fix that multiple function result was added to history
intitni Dec 2, 2023
d117fb1
Fix unit tests
intitni Dec 2, 2023
f4130c9
Merge branch 'feature/prompt-improvements-28' into develop
intitni Dec 2, 2023
966f654
Add SubSection
intitni Dec 2, 2023
ed339b6
Replace wrappers with SubSection
intitni Dec 2, 2023
3aba060
Update style
intitni Dec 2, 2023
b11f49e
Add scope settings to prompt to code
intitni Dec 2, 2023
bc0eb57
Update
intitni Dec 2, 2023
5b3051d
Merge branch 'feature/improve-scope-settings' into develop
intitni Dec 2, 2023
4f1a60b
Add instructions to chat model settings
intitni Dec 2, 2023
c0e8aa0
Handle errors from azure openai
intitni Dec 2, 2023
9f528c6
Update
intitni Dec 2, 2023
81051ab
Add git ignore checker
intitni Dec 3, 2023
a916e14
Update to not generate suggestion if a file is git ignored
intitni Dec 3, 2023
6c4fc82
Update ActiveDocumentChatContextCollector to only include selected co…
intitni Dec 3, 2023
f6ee5b7
Update
intitni Dec 3, 2023
e9dfeb1
Update
intitni Dec 3, 2023
5ca3bf0
Merge branch 'feature/keyword-base-retrieval' into develop
intitni Dec 3, 2023
a00c478
Fix gitignore check
intitni Dec 3, 2023
e43902a
Limit to 15 references
intitni Dec 3, 2023
28ac89c
Limit references token usage
intitni Dec 3, 2023
de6fa08
Update
intitni Dec 4, 2023
c1404c4
Bump version to 0.28.0
intitni Dec 4, 2023
0c55c5d
Merge branch 'main' into release/0.28.0
intitni Dec 4, 2023
0b54d7c
Update README.md
intitni Dec 4, 2023
66a3494
Use fallback solution when it can't find xcode
intitni Dec 4, 2023
ed2a203
Remove a fatalError
intitni Dec 4, 2023
c452fae
Update
intitni Dec 4, 2023
2312248
Adjust UI
intitni Dec 4, 2023
8ccb85f
Update appcast.xml
intitni Dec 4, 2023
28cf55b
Merge tag '0.28.0' into develop
intitni Dec 4, 2023
bd0f17d
Merge branch 'release/0.28.0'
intitni Dec 4, 2023
143c966
Update
intitni Dec 4, 2023
ea61843
Disable git ignore check by default
intitni Dec 4, 2023
c5dd90e
Bump version to 0.28.1
intitni Dec 4, 2023
de2b382
Update appcast.xml
intitni Dec 4, 2023
d426013
Merge tag '0.28.1' into develop
intitni Dec 4, 2023
b3a73bc
Merge branch 'hotfix/0.28.1'
intitni Dec 4, 2023
b5b6019
Fix git ignore check
intitni Dec 4, 2023
95ba0c3
Bump version 0.28.2
intitni Dec 4, 2023
d0e41d2
Update appcast.xml
intitni Dec 4, 2023
8613f35
Merge branch 'release/0.28.2'
intitni Dec 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ let package = Package(
.product(name: "OpenAIService", package: "Tool"),
.product(name: "Logger", package: "Tool"),
.product(name: "ChatTab", package: "Tool"),
.product(name: "Terminal", package: "Tool"),
.product(name: "MarkdownUI", package: "swift-markdown-ui"),
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
]
Expand Down
79 changes: 69 additions & 10 deletions Core/Sources/ChatGPTChatTab/Chat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,54 @@ import ComposableArchitecture
import Foundation
import OpenAIService
import Preferences
import Terminal

public struct ChatMessage: Equatable {
public enum Role {
public struct DisplayedChatMessage: Equatable {
public enum Role: Equatable {
case user
case assistant
case function
case ignored
}

public struct Reference: Equatable {
public var title: String
public var subtitle: String
public var uri: String
public var startLine: Int?

public init(title: String, subtitle: String, uri: String, startLine: Int?) {
self.title = title
self.subtitle = subtitle
self.uri = uri
self.startLine = startLine
}
}

public var id: String
public var role: Role
public var text: String
public var references: [Reference] = []

public init(id: String, role: Role, text: String) {
public init(id: String, role: Role, text: String, references: [Reference]) {
self.id = id
self.role = role
self.text = text
self.references = references
}
}

private var isPreview: Bool {
ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
}

struct Chat: ReducerProtocol {
public typealias MessageID = String

struct State: Equatable {
var title: String = "Chat"
@BindingState var typedMessage = ""
var history: [ChatMessage] = []
var history: [DisplayedChatMessage] = []
@BindingState var isReceivingMessage = false
var chatMenu = ChatMenu.State()
@BindingState var focusedField: Field?
Expand All @@ -51,6 +72,7 @@ struct Chat: ReducerProtocol {
case resendMessageButtonTapped(MessageID)
case setAsExtraPromptButtonTapped(MessageID)
case focusOnTextField
case referenceClicked(DisplayedChatMessage.Reference)

case observeChatService
case observeHistoryChange
Expand All @@ -77,8 +99,11 @@ struct Chat: ReducerProtocol {
case observeSystemPromptChange(UUID)
case observeExtraSystemPromptChange(UUID)
case observeDefaultScopesChange(UUID)
case sendMessage(UUID)
}

@Dependency(\.openURL) var openURL

var body: some ReducerProtocol<State, Action> {
BindingReducer()

Expand All @@ -90,6 +115,7 @@ struct Chat: ReducerProtocol {
switch action {
case .appear:
return .run { send in
if isPreview { return }
await send(.observeChatService)
await send(.historyChanged)
await send(.isReceivingMessageChanged)
Expand All @@ -104,16 +130,19 @@ struct Chat: ReducerProtocol {
state.typedMessage = ""
return .run { _ in
try await service.send(content: message)
}
}.cancellable(id: CancelID.sendMessage(id))

case .returnButtonTapped:
state.typedMessage += "\n"
return .none

case .stopRespondingButtonTapped:
return .run { _ in
await service.stopReceivingMessage()
}
return .merge(
.run { _ in
await service.stopReceivingMessage()
},
.cancel(id: CancelID.sendMessage(id))
)

case .clearButtonTap:
return .run { _ in
Expand All @@ -134,7 +163,29 @@ struct Chat: ReducerProtocol {
return .run { _ in
await service.setMessageAsExtraPrompt(id: id)
}


case let .referenceClicked(reference):
let fileURL = URL(fileURLWithPath: reference.uri)
return .run { _ in
if FileManager.default.fileExists(atPath: fileURL.path) {
let terminal = Terminal()
do {
_ = try await terminal.runCommand(
"/bin/bash",
arguments: [
"-c",
"xed -l \(reference.startLine ?? 0) \"\(reference.uri)\"",
],
environment: [:]
)
} catch {
print(error)
}
} else if let url = URL(string: reference.uri), url.scheme != nil {
await openURL(url)
}
}

case .focusOnTextField:
state.focusedField = .textField
return .none
Expand Down Expand Up @@ -247,7 +298,15 @@ struct Chat: ReducerProtocol {
case .function: return .function
}
}(),
text: message.summary ?? message.content ?? ""
text: message.summary ?? message.content ?? "",
references: message.references.map {
.init(
title: $0.title,
subtitle: $0.subTitle,
uri: $0.uri,
startLine: $0.startLine
)
}
)
}

Expand Down
Loading