Skip to content

Commit

Permalink
Merge branch 'hotfix/0.34.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
intitni committed Oct 6, 2024
2 parents 6cc4616 + 4235e68 commit 1fe0874
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Core/Sources/HostApp/AccountSettings/CodeiumView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ struct CodeiumView: View {
Text("Language Server Version: \(version)")
uninstallButton
}
case let .outdated(current: current, latest: latest):
case let .outdated(current: current, latest: latest, _):
HStack {
Text("Language Server Version: \(current) (Update Available: \(latest))")
uninstallButton
Expand Down Expand Up @@ -323,7 +323,7 @@ struct CodeiumView_Previews: PreviewProvider {

CodeiumView(viewModel: TestViewModel(
isSignedIn: true,
installationStatus: .outdated(current: "1.2.9", latest: "1.3.0"),
installationStatus: .outdated(current: "1.2.9", latest: "1.3.0", mandatory: true),
installationStep: .downloading
))

Expand Down
7 changes: 4 additions & 3 deletions Tool/Sources/ChatTab/ChatTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ open class BaseChatTab {

public init(store: StoreOf<ChatTabItem>) {
chatTabStore = store
self.id = store.id
self.title = store.title


Task { @MainActor in
self.id = store.id
self.title = store.title

storeObserver.observe { [weak self] in
guard let self else { return }
self.title = store.title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import Terminal

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

public init() {}

Expand Down Expand Up @@ -60,7 +61,7 @@ public struct CodeiumInstallationManager {
public enum InstallationStatus {
case notInstalled
case installed(String)
case outdated(current: String, latest: String)
case outdated(current: String, latest: String, mandatory: Bool)
case unsupported(current: String, latest: String)
}

Expand All @@ -87,14 +88,21 @@ public struct CodeiumInstallationManager {
{
switch version.compare(targetVersion, options: .numeric) {
case .orderedAscending:
return .outdated(current: version, latest: targetVersion)
switch version.compare(Self.minimumSupportedVersion) {
case .orderedAscending:
return .outdated(current: version, latest: Self.latestSupportedVersion, mandatory: true)
case .orderedSame:
return .outdated(current: version, latest: Self.latestSupportedVersion, mandatory: false)
case .orderedDescending:
return .outdated(current: version, latest: Self.latestSupportedVersion, mandatory: false)
}
case .orderedSame:
return .installed(version)
case .orderedDescending:
return .unsupported(current: version, latest: targetVersion)
}
}
return .outdated(current: "Unknown", latest: Self.latestSupportedVersion)
return .outdated(current: "Unknown", latest: Self.latestSupportedVersion, mandatory: false)
}

public enum InstallationStep {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ struct CompletionPart: Codable {
}

struct CodeiumDocument: Codable {
var absolute_path: String
// Path relative to the root of the workspace.
var relative_path: String
var absolute_path_migrate_me_to_uri: String
var text: String
// Language ID provided by the editor.
var editor_language: String
Expand Down
13 changes: 4 additions & 9 deletions Tool/Sources/CodeiumService/Services/CodeiumService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class CodeiumService {
languageServerVersion = version
case .notInstalled:
throw CodeiumError.languageServerNotInstalled
case let .outdated(version, _):
case let .outdated(version, _, _):
languageServerVersion = version
throw CodeiumError.languageServerOutdated
}
Expand Down Expand Up @@ -257,14 +257,12 @@ extension CodeiumService: CodeiumSuggestionServiceType {

requestCounter += 1
let languageId = languageIdentifierFromFileURL(fileURL)
let relativePath = getRelativePath(of: fileURL)

let task = Task {
let request = try await CodeiumRequest.GetCompletion(requestBody: .init(
metadata: getMetadata(),
document: .init(
absolute_path: fileURL.path,
relative_path: relativePath,
absolute_path_migrate_me_to_uri: fileURL.path,
text: content,
editor_language: languageId.rawValue,
language: .init(codeLanguage: languageId),
Expand All @@ -278,8 +276,7 @@ extension CodeiumService: CodeiumSuggestionServiceType {
.map { openedDocument in
let languageId = languageIdentifierFromFileURL(openedDocument.url)
return .init(
absolute_path: openedDocument.url.path,
relative_path: openedDocument.relativePath,
absolute_path_migrate_me_to_uri: openedDocument.url.path,
text: openedDocument.content,
editor_language: languageId.rawValue,
language: .init(codeLanguage: languageId)
Expand Down Expand Up @@ -417,11 +414,9 @@ extension CodeiumService: CodeiumSuggestionServiceType {
workspaceURL: URL
) async throws {
let languageId = languageIdentifierFromFileURL(fileURL)
let relativePath = getRelativePath(of: fileURL)
let request = await CodeiumRequest.RefreshContextForIdeAction(requestBody: .init(
active_document: .init(
absolute_path: fileURL.path,
relative_path: relativePath,
absolute_path_migrate_me_to_uri: fileURL.path,
text: content,
editor_language: languageId.rawValue,
language: .init(codeLanguage: languageId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public enum SuggestionServiceMiddlewareContainer {

public struct DisabledLanguageSuggestionServiceMiddleware: SuggestionServiceMiddleware {
public init() {}

struct DisabledLanguageError: Error, LocalizedError {
let language: String
var errorDescription: String? {
"Suggestion service is disabled for \(language)."
}
}

public func getSuggestion(
_ request: SuggestionRequest,
Expand All @@ -55,10 +62,7 @@ public struct DisabledLanguageSuggestionServiceMiddleware: SuggestionServiceMidd
if UserDefaults.shared.value(for: \.suggestionFeatureDisabledLanguageList)
.contains(where: { $0 == language.rawValue })
{
#if DEBUG
Logger.service.info("Suggestion service is disabled for \(language).")
#endif
return []
throw DisabledLanguageError(language: language.rawValue)
}

return try await next(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public extension AppInstanceInspector {
.joined(separator: " of ")
return """
click menu item "\(button)" of \(list) \
of menu 1 \
of menu bar item "\(menuBarItem)" \
of menu bar 1
"""
Expand Down
4 changes: 2 additions & 2 deletions Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
APP_VERSION = 0.34.1
APP_BUILD = 413
APP_VERSION = 0.34.2
APP_BUILD = 415

0 comments on commit 1fe0874

Please sign in to comment.