-
Notifications
You must be signed in to change notification settings - Fork 45
Fix LLMStreamView usages not being responsive to device theme changes #372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ import SwiftUI | |||||
| struct GeneratedContentView: View { | ||||||
| @Environment(\.windowState) private var state | ||||||
| @Environment(\.openURL) var openURL | ||||||
| @Environment(\.colorScheme) var colorScheme | ||||||
|
|
||||||
| @Default(.fontSize) var fontSize | ||||||
| @Default(.lineHeight) var lineHeight | ||||||
|
|
@@ -27,7 +28,10 @@ struct GeneratedContentView: View { | |||||
|
|
||||||
| var configuration: LLMStreamConfiguration { | ||||||
| let font = FontConfiguration(size: fontSize, lineHeight: lineHeight) | ||||||
| let color = ColorConfiguration(textColor: .S_0, | ||||||
|
|
||||||
| let textColor = colorScheme == .dark ? Color.white : Color.black | ||||||
|
|
||||||
| let color = ColorConfiguration(textColor: textColor, | ||||||
| citationBackgroundColor: Color.S_6, | ||||||
| citationHoverBackgroundColor: Color.S_4, | ||||||
| citationTextColor: Color.S_1) | ||||||
|
|
@@ -47,7 +51,7 @@ struct GeneratedContentView: View { | |||||
| configuration: configuration, | ||||||
| onUrlClicked: onUrlClicked, | ||||||
| onCodeAction: codeAction) | ||||||
| .id("\(fontSize)-\(lineHeight)") // Force recreation when font settings change | ||||||
| .id("\(fontSize)-\(lineHeight)-\(colorScheme.hashValue)") // Force recreation when font settings change | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Using colorScheme.hashValue could cause unnecessary view recreations if hashValue implementation changes. Consider using a more stable identifier like colorScheme.rawValue or a string representation.
Suggested change
|
||||||
| .padding(.horizontal, 12) | ||||||
|
|
||||||
| if let response = prompt.currentResponse, response.hasToolCall { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,7 @@ struct ViewOffsetKey: @preconcurrency PreferenceKey { | |||||
| struct QuickEditResponseView: View { | ||||||
| @Environment(\.windowState) private var state | ||||||
| @Environment(\.openURL) var openURL | ||||||
| @Environment(\.colorScheme) var colorScheme | ||||||
|
|
||||||
| @State private var previousViewOffset: CGFloat = 0 | ||||||
| @State private var hasUserManuallyScrolled: Bool = false | ||||||
|
|
@@ -54,7 +55,10 @@ struct QuickEditResponseView: View { | |||||
|
|
||||||
| private var configuration: LLMStreamConfiguration { | ||||||
| let font = FontConfiguration(size: fontSize, lineHeight: lineHeight) | ||||||
| let color = ColorConfiguration(textColor: .S_0, | ||||||
|
|
||||||
| let textColor = colorScheme == .dark ? Color.white : Color.black | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Using Color.white/Color.black conflicts with the custom rule that text should use .FG or low gray colors (.gray100, .gray200, .gray300) since the app only has dark mode
Suggested change
|
||||||
|
|
||||||
| let color = ColorConfiguration(textColor: textColor, | ||||||
| citationBackgroundColor: Color.S_6, | ||||||
| citationHoverBackgroundColor: Color.S_4, | ||||||
| citationTextColor: Color.S_1) | ||||||
|
|
@@ -168,7 +172,7 @@ extension QuickEditResponseView { | |||||
| configuration: configuration, | ||||||
| onUrlClicked: onUrlClicked, | ||||||
| onCodeAction: codeAction) | ||||||
| .id("\(fontSize)-\(lineHeight)") // Force recreation when font settings change | ||||||
| .id("\(fontSize)-\(lineHeight)-\(colorScheme.hashValue)") // Force recreation when font settings change | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Consider using a more stable identifier than colorScheme.hashValue - perhaps colorScheme == .dark for better predictability |
||||||
| .frame(maxWidth: .infinity, alignment: .leading) | ||||||
| .padding(.vertical, 8) | ||||||
| .id("content") | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using the existing semantic colors (Color.S_0) instead of hardcoded black/white. The S_0 color is already configured to be black in light mode and white in dark mode in the Assets catalog.