Skip to content

Commit

Permalink
Merge branch 'release/0.35.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
intitni committed Nov 28, 2024
2 parents 8430303 + 685c6e0 commit 2ab65a5
Show file tree
Hide file tree
Showing 28 changed files with 817 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,19 @@ struct ChatSettingsGeneralSectionView: View {
Text("7 Messages").tag(7)
Text("9 Messages").tag(9)
Text("11 Messages").tag(11)
Text("21 Messages").tag(21)
Text("31 Messages").tag(31)
Text("41 Messages").tag(41)
Text("51 Messages").tag(51)
Text("71 Messages").tag(71)
Text("91 Messages").tag(91)
Text("111 Messages").tag(111)
Text("151 Messages").tag(151)
Text("201 Messages").tag(201)
}

VStack(alignment: .leading, spacing: 4) {
Text("Default system prompt")
Text("Additional system prompt")
EditableText(text: $settings.defaultChatSystemPrompt)
.lineLimit(6)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public struct PromptToCodePanel {
case cancelButtonTapped
case acceptButtonTapped
case acceptAndContinueButtonTapped
case statusUpdated([String])
case snippetPanel(IdentifiedActionOf<PromptToCodeSnippetPanel>)
}

Expand Down Expand Up @@ -128,7 +129,9 @@ public struct PromptToCodePanel {

return .run { send in
do {
let context = await contextInputController.resolveContext()
let context = await contextInputController.resolveContext(onStatusChange: {
await send(.statusUpdated($0))
})
let agentFactory = context.agent ?? { SimpleModificationAgent() }
_ = try await withThrowingTaskGroup(of: Void.self) { group in
for (index, snippet) in snippets.enumerated() {
Expand Down Expand Up @@ -216,11 +219,13 @@ public struct PromptToCodePanel {

case .stopRespondingButtonTapped:
state.promptToCodeState.isGenerating = false
state.promptToCodeState.status = []
return .cancel(id: CancellationKey.modifyCode(state.id))

case .modifyCodeFinished:
state.contextInputController.instruction = .init("")
state.promptToCodeState.isGenerating = false
state.promptToCodeState.status = []

if state.promptToCodeState.snippets.allSatisfy({ snippet in
snippet.modifiedCode.isEmpty && snippet.description.isEmpty && snippet
Expand Down Expand Up @@ -252,6 +257,10 @@ public struct PromptToCodePanel {
await commandHandler.acceptModification()
activateThisApp()
}

case let .statusUpdated(status):
state.promptToCodeState.status = status
return .none
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ struct PromptToCodePanelView: View {
TopBar(store: store)

Content(store: store)
.overlay(alignment: .bottom) {
ActionBar(store: store)
}
.safeAreaInset(edge: .bottom) {
if let inputField = customizedViews.contextInputField {
inputField
} else {
Toolbar(store: store)
VStack {
StatusBar(store: store)

ActionBar(store: store)

if let inputField = customizedViews.contextInputField {
inputField
} else {
Toolbar(store: store)
}
}
}
}
Expand Down Expand Up @@ -143,6 +146,70 @@ extension PromptToCodePanelView {
}
}

struct StatusBar: View {
let store: StoreOf<PromptToCodePanel>
@State var isAllStatusesPresented = false
var body: some View {
WithPerceptionTracking {
if store.promptToCodeState.isGenerating, !store.promptToCodeState.status.isEmpty {
if let firstStatus = store.promptToCodeState.status.first {
let count = store.promptToCodeState.status.count
Button(action: {
isAllStatusesPresented = true
}) {
HStack {
Text(firstStatus)
.lineLimit(1)
.font(.caption)

Text("\(count)")
.lineLimit(1)
.font(.caption)
.background(
Circle()
.fill(Color.secondary.opacity(0.3))
.frame(width: 12, height: 12)
)
}
.padding(8)
.background(
.regularMaterial,
in: RoundedRectangle(cornerRadius: 6, style: .continuous)
)
.overlay {
RoundedRectangle(cornerRadius: 6, style: .continuous)
.stroke(Color(nsColor: .separatorColor), lineWidth: 1)
}
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.frame(maxWidth: 400)
.popover(isPresented: $isAllStatusesPresented, arrowEdge: .top) {
WithPerceptionTracking {
VStack(alignment: .leading, spacing: 16) {
ForEach(store.promptToCodeState.status, id: \.self) { status in
HStack {
ProgressView()
.progressViewStyle(CircularProgressViewStyle())
.controlSize(.small)
Text(status)
}
}
}
.padding()
}
}
.onChange(of: store.promptToCodeState.isGenerating) { isGenerating in
if !isGenerating {
isAllStatusesPresented = false
}
}
}
}
}
}
}

struct ActionBar: View {
let store: StoreOf<PromptToCodePanel>

Expand Down Expand Up @@ -433,7 +500,7 @@ extension PromptToCodePanelView {
}
}
}

Spacer(minLength: 56)
}
}
Expand Down Expand Up @@ -575,7 +642,7 @@ extension PromptToCodePanelView {
presentAllContent: !isGenerating
)
} else {
ScrollView(.horizontal) {
MinScrollView {
CodeBlockInContent(
store: store,
language: language,
Expand Down Expand Up @@ -607,6 +674,37 @@ extension PromptToCodePanelView {
}
}

struct MinWidthPreferenceKey: PreferenceKey {
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
value = nextValue()
}

static var defaultValue: CGFloat = 0
}

struct MinScrollView<Content: View>: View {
@ViewBuilder let content: Content
@State var minWidth: CGFloat = 0

var body: some View {
ScrollView(.horizontal) {
content
.frame(minWidth: minWidth)
}
.overlay {
GeometryReader { proxy in
Color.clear.preference(
key: MinWidthPreferenceKey.self,
value: proxy.size.width
)
}
}
.onPreferenceChange(MinWidthPreferenceKey.self) {
minWidth = $0
}
}
}

struct CodeBlockInContent: View {
let store: StoreOf<PromptToCodeSnippetPanel>
let language: CodeLanguage
Expand Down Expand Up @@ -857,3 +955,59 @@ extension PromptToCodePanelView {
.frame(width: 500, height: 500, alignment: .center)
}

#Preview("Generating") {
PromptToCodePanelView(store: .init(initialState: .init(
promptToCodeState: Shared(ModificationState(
source: .init(
language: CodeLanguage.builtIn(.swift),
documentURL: URL(
fileURLWithPath: "path/to/file-name-is-super-long-what-should-we-do-with-it-hah.txt"
),
projectRootURL: URL(fileURLWithPath: "path/to/file.txt"),
content: "",
lines: []
),
snippets: [
.init(
startLineIndex: 8,
originalCode: "print(foo)",
modifiedCode: "print(bar)",
description: "",
error: "Error",
attachedRange: CursorRange(
start: .init(line: 8, character: 0),
end: .init(line: 12, character: 2)
)
),
.init(
startLineIndex: 13,
originalCode: """
struct Bar {
var foo: Int
}
""",
modifiedCode: """
struct Bar {
var foo: String
}
""",
description: "Cool",
error: nil,
attachedRange: CursorRange(
start: .init(line: 13, character: 0),
end: .init(line: 12, character: 2)
)
),
],
extraSystemPrompt: "",
isAttachedToTarget: true,
isGenerating: true,
status: ["Status 1", "Status 2"]
)),
instruction: nil,
commandName: "Generate Code"
), reducer: { PromptToCodePanel() }))
.frame(maxWidth: 450, maxHeight: Style.panelHeight)
.fixedSize(horizontal: false, vertical: true)
.frame(width: 500, height: 500, alignment: .center)
}
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ public final class WidgetWindows {
@MainActor
lazy var toastWindow = {
let it = WidgetWindow(
contentRect: .zero,
contentRect: .init(x: 0, y: 0, width: Style.panelWidth, height: Style.panelHeight),
styleMask: [.borderless],
backing: .buffered,
defer: false
Expand Down
2 changes: 2 additions & 0 deletions ExtensionService/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import FileChangeChecker
import LaunchAgentManager
import Logger
import Perception
import Preferences
import Service
import ServiceManagement
Expand Down Expand Up @@ -29,6 +30,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
)

func applicationDidFinishLaunching(_: Notification) {
// isPerceptionCheckingEnabled = false
if ProcessInfo.processInfo.environment["IS_UNIT_TEST"] == "YES" { return }
_ = XcodeInspector.shared
updateChecker.updateCheckerDelegate = self
Expand Down
Binary file modified Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions Tool/Sources/AIModel/ChatModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public struct ChatModel: Codable, Equatable, Identifiable {
public var maxTokens: Int
@FallbackDecoding<EmptyBool>
public var supportsFunctionCalling: Bool
@FallbackDecoding<EmptyBool>
public var supportsImage: Bool
@FallbackDecoding<EmptyBool>
public var supportsAudio: Bool
@FallbackDecoding<EmptyString>
public var modelName: String

Expand All @@ -114,6 +118,8 @@ public struct ChatModel: Codable, Equatable, Identifiable {
isFullURL: Bool = false,
maxTokens: Int = 4000,
supportsFunctionCalling: Bool = true,
supportsImage: Bool = false,
supportsAudio: Bool = false,
modelName: String = "",
openAIInfo: OpenAIInfo = OpenAIInfo(),
ollamaInfo: OllamaInfo = OllamaInfo(),
Expand All @@ -126,6 +132,8 @@ public struct ChatModel: Codable, Equatable, Identifiable {
self.isFullURL = isFullURL
self.maxTokens = maxTokens
self.supportsFunctionCalling = supportsFunctionCalling
self.supportsImage = supportsImage
self.supportsAudio = supportsAudio
self.modelName = modelName
self.openAIInfo = openAIInfo
self.ollamaInfo = ollamaInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Terminal

public struct CodeiumInstallationManager {
private static var isInstalling = false
static let latestSupportedVersion = "1.20.9"
static let latestSupportedVersion = "1.28.3"
static let minimumSupportedVersion = "1.20.0"

public init() {}
Expand Down Expand Up @@ -90,11 +90,23 @@ public struct CodeiumInstallationManager {
case .orderedAscending:
switch version.compare(Self.minimumSupportedVersion) {
case .orderedAscending:
return .outdated(current: version, latest: Self.latestSupportedVersion, mandatory: true)
return .outdated(
current: version,
latest: Self.latestSupportedVersion,
mandatory: true
)
case .orderedSame:
return .outdated(current: version, latest: Self.latestSupportedVersion, mandatory: false)
return .outdated(
current: version,
latest: Self.latestSupportedVersion,
mandatory: false
)
case .orderedDescending:
return .outdated(current: version, latest: Self.latestSupportedVersion, mandatory: false)
return .outdated(
current: version,
latest: Self.latestSupportedVersion,
mandatory: false
)
}
case .orderedSame:
return .installed(version)
Expand Down
Loading

0 comments on commit 2ab65a5

Please sign in to comment.