Skip to content

Commit

Permalink
1.2.0-4
Browse files Browse the repository at this point in the history
  • Loading branch information
cdillard committed May 29, 2023
1 parent 49e24cd commit 0db5fb8
Show file tree
Hide file tree
Showing 19 changed files with 423 additions and 347 deletions.
11 changes: 11 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@

LogicSage 1.2.0

Features:
- Rename GPT conversations to stay organized.
- Fix syntax highlighting / text selection in chats.
- Customizable name for GPT and Self.
- Wallpaper saved to disk for offline usage.
Fixes:
- Multiple window support improved.


[LogicSage: The Mobile AI Workspace](https://apps.apple.com/us/app/logicsage/id6448485441) - on the AppStore for free now!


----------------

Expand Down
2 changes: 1 addition & 1 deletion SwiftSageiOS/Sourceful/LocalConsole/LCManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
}
}

let defaultConsoleSize = CGSize(width: UIScreen.size.width - (UIScreen.size.width / 2), height: UIScreen.size.height - (UIScreen.size.height / 2))
let defaultConsoleSize = CGSize(width: UIScreen.size.width - (UIScreen.size.width / 1.5), height: UIScreen.size.height - (UIScreen.size.height / 1.5))

lazy var borderView = UIView()

Expand Down
10 changes: 6 additions & 4 deletions SwiftSageiOS/Sourceful/SwiftUI/SourceCodeTextEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,26 @@ public struct SourceCodeTextEditor: _ViewRepresentable {
let overrideText = custom.overrideText()

DispatchQueue.main.async {

view.textView.isEditable = isEditing

view.contentTextView.isEditable = isEditing


view.isEditing = isEditing
view.textView.isSelectable = isEditing
view.contentTextView.isSelectable = isEditing

if let overrideText = overrideText {


let preText = view.textView.text
view.textView.text = overrideText
context.coordinator.wrappedView.text = overrideText

if preText == view.textView.text {

}
else {
// scroll text virew to bottom
// scroll text view to bottom
if view.textView.text.count > 0 {
let location = view.textView.text.count - 1
let bottom = NSMakeRange(location, 1)
Expand Down
4 changes: 2 additions & 2 deletions SwiftSageiOS/SwiftSageiOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@
CODE_SIGN_ENTITLEMENTS = SwiftSageiOS/SwiftSageiOS.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"SwiftSageiOS/Preview Content\"";
DEVELOPMENT_TEAM = "";
Expand Down Expand Up @@ -1333,7 +1333,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = SwiftSageiOS/SwiftSageiOS.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"SwiftSageiOS/Preview Content\"";
DEVELOPMENT_TEAM = 72WEN2C47N;
Expand Down
26 changes: 2 additions & 24 deletions SwiftSageiOS/SwiftSageiOS/SwiftSageiOSApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,12 @@ import Combine
import UIKit
#endif

// TODO MAKE SURE ITS OKAY TO UP THIS SO MUCH
let STRING_LIMIT = 150000

// TODO BEFORE RELEASE: PROD BUNDLE ID
// TODO USE BUILT IN BundleID var.
let bundleID = "com.chrisdillard.SwiftSage"

var serviceDiscovery: ServiceDiscovery?

@main
struct SwiftSageiOSApp: App {
@StateObject private var settingsViewModel = SettingsViewModel.shared
@StateObject private var appState = AppState()
@State private var isDrawerOpen = false
#if !os(macOS)

@State private var isPortrait = UIApplication.shared.statusBarOrientation == .portrait || UIApplication.shared.statusBarOrientation == .portraitUpsideDown
Expand All @@ -51,19 +43,8 @@ struct SwiftSageiOSApp: App {
WindowGroup {
ZStack {
HStack(spacing: 0) {
#if !os(macOS)

if self.isDrawerOpen {
DrawerContent(settingsViewModel: settingsViewModel, isDrawerOpen: $isDrawerOpen, conversations: $settingsViewModel.conversations, isPortrait: $isPortrait)
.environmentObject(appState)
.environmentObject(WindowManager.shared)
.transition(.move(edge: .leading))
.background(settingsViewModel.buttonColor)
.frame(minWidth: isPortrait ? drawerWidth : drawerWidthLandscape, maxWidth: isPortrait ? drawerWidth : drawerWidthLandscape, minHeight: 0, maxHeight: .infinity)
}
#endif
ContentView(settingsViewModel: settingsViewModel, isDrawerOpen: $isDrawerOpen)
.environmentObject(appState)
ContentView(settingsViewModel: settingsViewModel)
}
.overlay(
Group {
Expand Down Expand Up @@ -113,17 +94,14 @@ struct SwiftSageiOSApp: App {
logD("didFinishLaunchingNotification")
SwiftSageiOSAppDelegate.applicationDidFinishLaunching()
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
logD("applicationDidBecomeActive")
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
logD("applicationWillEnterForeground")

screamer.discoReconnect()
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didEnterBackgroundNotification)) { _ in
logD("didEnterBackgroundNotification")
SwiftSageiOSAppDelegate.applicationDidEnterBackground()
//SwiftSageiOSAppDelegate.applicationDidEnterBackground()
}
#endif
}
Expand Down
90 changes: 44 additions & 46 deletions SwiftSageiOS/SwiftSageiOS/SwiftSageiOSAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,52 @@ import BackgroundTasks
class SwiftSageiOSAppDelegate: NSObject, UIApplicationDelegate, ObservableObject {

static func applicationDidFinishLaunching() {
logD("applicationDidFinishLaunching starts")

BGTaskScheduler.shared.register(forTaskWithIdentifier: "\(bundleID)bger", using: nil) { task in
self.handleWebSocketRefresh(task: task as! BGAppRefreshTask)
}


logD("applicationDidFinishLaunching ends")

}
static func applicationDidEnterBackground() {
logD("applicationDidEnterBG starts")

screamer.sendPing()

scheduleWebSocketRefresh()

logD("applicationDidEnterBG ends")

}

static func handleWebSocketRefresh(task: BGAppRefreshTask) {
task.expirationHandler = {
task.setTaskCompleted(success: false)
}

serviceDiscovery?.startDiscovering()
screamer.connect()
screamer.sendPing()
// logD("applicationDidFinishLaunching starts")
// BGTaskScheduler.shared.register(forTaskWithIdentifier: "\(bundleID)bger", using: nil) { task in
// self.handleWebSocketRefresh(task: task as! BGAppRefreshTask)
// }
//
// logD("applicationDidFinishLaunching ends")

// After the task is complete
task.setTaskCompleted(success: true)
scheduleWebSocketRefresh() // Schedule the next background task
}
// static func applicationDidEnterBackground() {
// logD("applicationDidEnterBG starts")
//
// screamer.sendPing()
//
// // scheduleWebSocketRefresh()
//
// logD("applicationDidEnterBG ends")
//
// }

static func scheduleWebSocketRefresh() {
let request = BGAppRefreshTaskRequest(identifier: "\(bundleID)bger")
request.earliestBeginDate = Date(timeIntervalSinceNow: 60 * 2) // 1 minutes from now

do {
logD("scheduleWebSocketRefresh attempt")

try BGTaskScheduler.shared.submit(request)
logD("scheduleWebSocketRefresh success")

} catch {
logD("Could not schedule WebSocket refresh task: \(error)")
}
}
// static func handleWebSocketRefresh(task: BGAppRefreshTask) {
// task.expirationHandler = {
// task.setTaskCompleted(success: false)
// }
//
// serviceDiscovery?.startDiscovering()
// screamer.connect()
// screamer.sendPing()
//
// // After the task is complete
// task.setTaskCompleted(success: true)
// scheduleWebSocketRefresh() // Schedule the next background task
// }

// static func scheduleWebSocketRefresh() {
// let request = BGAppRefreshTaskRequest(identifier: "\(bundleID)bger")
// request.earliestBeginDate = Date(timeIntervalSinceNow: 60 * 2) // 1 minutes from now
//
// do {
// logD("scheduleWebSocketRefresh attempt")
//
// try BGTaskScheduler.shared.submit(request)
// logD("scheduleWebSocketRefresh success")
//
// } catch {
// logD("Could not schedule WebSocket refresh task: \(error)")
// }
// }
}
#endif
3 changes: 0 additions & 3 deletions SwiftSageiOS/SwiftSageiOS/Utilities/WindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import SwiftUI

class WindowManager: ObservableObject {

public static let shared = WindowManager()


@Published var windows: [WindowInfo] = []

func addWindow(windowType: WindowInfo.WindowType, frame: CGRect, zIndex: Int, file: RepoFile? = nil, fileContents: String = "", url: String = "", convoId: Conversation.ID? = nil) {
Expand Down
47 changes: 24 additions & 23 deletions SwiftSageiOS/SwiftSageiOS/ViewViewModel/AddView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct AddView: View {
@FocusState private var field6IsFocused: Bool
@FocusState private var field7IsFocused: Bool
@FocusState private var field8IsFocused: Bool
@Binding var isInputViewShown: Bool

private func resizableButtonImage(systemName: String, size: CGSize) -> some View {
Image(systemName: systemName)
Expand Down Expand Up @@ -89,26 +90,26 @@ struct AddView: View {
withAnimation {
logD("Upload Workspace")
#if !os(macOS)

if consoleManager.isVisible {
consoleManager.isVisible = false
}
#endif
// showAddView.toggle()


logD("UPLOAD Workspace")

// showAddView.toggle()

settingsViewModel.multiLineText = "upload"
DispatchQueue.main.async {

// Execute your action here
screamer.sendCommand(command: settingsViewModel.multiLineText)
self.settingsViewModel.isInputViewShown = false

isInputViewShown = false

settingsViewModel.multiLineText = ""
}
}
Expand All @@ -119,55 +120,55 @@ struct AddView: View {
size: geometry.size)
.fontWeight(.bold)
.cornerRadius(8)

Text("Upload")
.font(.caption)
.foregroundColor(settingsViewModel.appTextColor)
}
}

// NEW FILE WINDOW
Button(action: {
withAnimation {
logD("Download Workspace")
#if !os(macOS)

if consoleManager.isVisible {
consoleManager.isVisible = false
}
#endif
showAddView.toggle()


logD("DO WORKSPACE DOWNLOAD!")

settingsViewModel.multiLineText = "download"
DispatchQueue.main.async {

// Execute your action here
screamer.sendCommand(command: settingsViewModel.multiLineText)
self.settingsViewModel.isInputViewShown = false

isInputViewShown = false

settingsViewModel.multiLineText = ""
}
}
}) {
VStack {


resizableButtonImage(systemName:
"arrow.down.circle.fill",
size: geometry.size)
.fontWeight(.bold)
.cornerRadius(8)

Text("Download")
.font(.caption)
.foregroundColor(settingsViewModel.appTextColor)
}
}

}
}
//.padding(.leading,8)
Expand Down
9 changes: 5 additions & 4 deletions SwiftSageiOS/SwiftSageiOS/ViewViewModel/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ struct ChatView: View {
@ObservedObject var settingsViewModel: SettingsViewModel

@Binding var conversations: [Conversation]

var window: WindowInfo?
@Binding var isEditing: Bool

@State var isEditing = false
@State var chatText = ""
@State var textEditorHeight : CGFloat = 40
@FocusState private var isTextFieldFocused: Bool
Expand Down Expand Up @@ -69,6 +70,7 @@ struct ChatView: View {
.lineLimit(nil)
.font(.system(size: settingsViewModel.fontSizeSrcEditor))
.foregroundColor(settingsViewModel.plainColorSrcEditor)
.scrollContentBackground(.hidden) // <- Hide it
.background(settingsViewModel.backgroundColorSrcEditor)

.frame(height: max( 40, textEditorHeight))
Expand All @@ -94,6 +96,8 @@ struct ChatView: View {
.padding(.leading,4)
.fontWeight(.light)
.font(.system(size: settingsViewModel.fontSizeSrcEditor))
.foregroundColor(settingsViewModel.plainColorSrcEditor)

.allowsHitTesting(false)
.foregroundColor(settingsViewModel.appTextColor.opacity(0.5)).opacity(!isTextFieldFocused && chatText.isEmpty ? 1.0 : 0.0)
}.onPreferenceChange(ViewHeightKey.self) { textEditorHeight = $0 }
Expand Down Expand Up @@ -128,9 +132,6 @@ struct ChatView: View {

chatText = ""
isTextFieldFocused = false

self.settingsViewModel.isInputViewShown = false

}
else {
logD("failed to chat")
Expand Down
Loading

0 comments on commit 0db5fb8

Please sign in to comment.