Repository navigation
feat(ios): rich card suite, collapsible reasoning chambers, and celebration particles #285
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| import SwiftUI | ||
| import CompanionCore | ||
|
|
||
| public struct AgentThoughtChamberView: View { | ||
| public let reasoning: String | ||
| public let botName: String | ||
| public let mascotColor: Color | ||
| public let isStreaming: Bool | ||
|
|
||
| @Environment(\.colorScheme) private var colorScheme | ||
| @State private var isExpanded: Bool = false | ||
| @State private var pulseAnimation: Bool = false | ||
|
|
||
| public init( | ||
| reasoning: String, | ||
| botName: String = "Bot", | ||
| mascotColor: Color = .purple, | ||
| isStreaming: Bool = false | ||
| ) { | ||
| self.reasoning = reasoning | ||
| self.botName = botName | ||
| self.mascotColor = mascotColor | ||
| self.isStreaming = isStreaming | ||
| } | ||
|
|
||
| private var steps: [String] { | ||
| reasoning.components(separatedBy: "\n").filter { !$0.trimmingCharacters(in: .whitespaces).isEmpty } | ||
| } | ||
|
|
||
| public var body: some View { | ||
| let isDark = colorScheme == .dark | ||
|
|
||
| VStack(alignment: .leading, spacing: 6) { | ||
| headerButton(isDark: isDark) | ||
|
|
||
| if isExpanded { | ||
| expandedContent(isDark: isDark) | ||
| } | ||
| } | ||
| .padding(6) | ||
| .background( | ||
| LinearGradient( | ||
| colors: isDark ? [ | ||
| Color(hex: "#18181B").opacity(0.92), | ||
| Color(hex: "#0F172A").opacity(0.88) | ||
| ] : [ | ||
| Color.white.opacity(0.94), | ||
| Color(hex: "#F8FAFC").opacity(0.88) | ||
| ], | ||
| startPoint: .topLeading, | ||
| endPoint: .bottomTrailing | ||
| ) | ||
| ) | ||
| .background(.ultraThinMaterial) | ||
| .clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous)) | ||
| .overlay( | ||
| RoundedRectangle(cornerRadius: 12, style: .continuous) | ||
| .stroke(isDark ? mascotColor.opacity(0.3) : Color.black.opacity(0.08), lineWidth: 0.65) | ||
| ) | ||
| .shadow(color: Color.black.opacity(isDark ? 0.25 : 0.04), radius: 3, y: 1) | ||
| .onAppear { | ||
| if isStreaming { | ||
| withAnimation(.easeInOut(duration: 0.8).repeatForever(autoreverses: true)) { | ||
| pulseAnimation = true | ||
| } | ||
| } | ||
| } | ||
| .onChange(of: isStreaming) { _, streaming in | ||
| if streaming { | ||
| withAnimation(.easeInOut(duration: 0.8).repeatForever(autoreverses: true)) { | ||
| pulseAnimation = true | ||
| } | ||
| } else { | ||
| pulseAnimation = false | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private func headerButton(isDark: Bool) -> some View { | ||
| Button { | ||
| withAnimation(.spring(response: 0.35, dampingFraction: 0.72)) { | ||
| isExpanded.toggle() | ||
| } | ||
| Haptics.selection() | ||
| } label: { | ||
| HStack(spacing: 6) { | ||
| Image(systemName: "brain.head.profile") | ||
| .font(.system(size: 11, weight: .bold)) | ||
| .foregroundColor(mascotColor) | ||
| .scaleEffect(pulseAnimation ? 1.15 : 1.0) | ||
|
|
||
| Text(isStreaming ? "Thinking…" : "Thought Process") | ||
| .font(.caption2.weight(.bold)) | ||
| .foregroundColor(isDark ? Color(hex: "#F8FAFC") : Color(hex: "#334155")) | ||
|
|
||
| if isStreaming { | ||
| Circle() | ||
| .fill(mascotColor) | ||
| .frame(width: 6, height: 6) | ||
| .opacity(pulseAnimation ? 1.0 : 0.3) | ||
| } | ||
|
|
||
| Spacer() | ||
|
|
||
| Text("\(steps.count) \(steps.count == 1 ? "step" : "steps")") | ||
| .font(.system(size: 9.5, weight: .medium, design: .monospaced)) | ||
| .foregroundColor(isDark ? Color(hex: "#94A3B8") : Color(hex: "#64748B")) | ||
|
|
||
| Image(systemName: isExpanded ? "chevron.up" : "chevron.down") | ||
| .font(.system(size: 9, weight: .bold)) | ||
| .foregroundColor(isDark ? Color(hex: "#94A3B8") : Color(hex: "#64748B")) | ||
| } | ||
| .padding(.horizontal, 10) | ||
| .padding(.vertical, 6) | ||
| .background(isDark ? Color.white.opacity(0.08) : Color.black.opacity(0.04)) | ||
| .clipShape(Capsule()) | ||
| } | ||
| .buttonStyle(.plain) | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private func expandedContent(isDark: Bool) -> some View { | ||
| VStack(alignment: .leading, spacing: 6) { | ||
| ScrollView { | ||
| VStack(alignment: .leading, spacing: 4) { | ||
| ForEach(Array(steps.enumerated()), id: \.offset) { idx, step in | ||
| stepRow(index: idx, step: step, isDark: isDark) | ||
| } | ||
| } | ||
| } | ||
| .frame(maxHeight: 160) | ||
| } | ||
| .padding(10) | ||
| .background(isDark ? Color.black.opacity(0.35) : Color.white.opacity(0.85)) | ||
| .clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous)) | ||
| .overlay( | ||
| RoundedRectangle(cornerRadius: 10, style: .continuous) | ||
| .stroke(isDark ? Color.white.opacity(0.06) : Color.black.opacity(0.06), lineWidth: 0.5) | ||
| ) | ||
| .transition(.opacity.combined(with: .move(edge: .top))) | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private func stepRow(index: Int, step: String, isDark: Bool) -> some View { | ||
| HStack(alignment: .top, spacing: 6) { | ||
| Text(String(index + 1) + ".") | ||
| .font(.system(size: 10, weight: .bold, design: .monospaced)) | ||
| .foregroundColor(mascotColor) | ||
|
|
||
| Text(step) | ||
| .font(.caption2) | ||
| .foregroundColor(isDark ? Color(hex: "#E2E8F0") : Color(hex: "#1E293B")) | ||
| .fixedSize(horizontal: false, vertical: true) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| import SwiftUI | ||
|
|
||
| public struct GitPRDiffCardView: View { | ||
| public let filename: String | ||
| public let diffText: String | ||
| public let additions: Int | ||
| public let deletions: Int | ||
|
|
||
| @Environment(\.colorScheme) private var colorScheme | ||
| @State private var showDiff: Bool = true | ||
| @State private var isApproved: Bool = false | ||
|
|
||
| public init( | ||
| filename: String = "Changes", | ||
| diffText: String, | ||
| additions: Int = 0, | ||
| deletions: Int = 0 | ||
| ) { | ||
| self.filename = filename | ||
| self.diffText = diffText | ||
|
|
||
| if additions == 0 && deletions == 0 { | ||
| let lines = diffText.components(separatedBy: "\n") | ||
| self.additions = lines.filter { $0.hasPrefix("+") && !$0.hasPrefix("+++") }.count | ||
| self.deletions = lines.filter { $0.hasPrefix("-") && !$0.hasPrefix("---") }.count | ||
| } else { | ||
| self.additions = additions | ||
| self.deletions = deletions | ||
| } | ||
| } | ||
|
|
||
| public var body: some View { | ||
| let isDark = colorScheme == .dark | ||
|
|
||
| VStack(alignment: .leading, spacing: 8) { | ||
| // Header | ||
| HStack(spacing: 6) { | ||
| Image(systemName: "arrow.triangle.pull") | ||
| .font(.system(size: 12, weight: .bold)) | ||
| .foregroundColor(isApproved ? Color(hex: "#A855F7") : Color(hex: "#22C55E")) | ||
|
|
||
| Text(filename) | ||
| .font(.caption.weight(.bold)) | ||
| .foregroundColor(isDark ? Color(hex: "#F8FAFC") : Color(hex: "#0F172A")) | ||
| .lineLimit(1) | ||
|
|
||
| Spacer() | ||
|
|
||
| // Diff Delta (+ / -) | ||
| HStack(spacing: 4) { | ||
| Text("+\(additions)") | ||
| .font(.system(size: 10.5, weight: .bold, design: .monospaced)) | ||
| .foregroundColor(Color(hex: "#22C55E")) | ||
| Text("-\(deletions)") | ||
| .font(.system(size: 10.5, weight: .bold, design: .monospaced)) | ||
| .foregroundColor(Color(hex: "#EF4444")) | ||
| } | ||
| .padding(.horizontal, 6) | ||
| .padding(.vertical, 2.5) | ||
| .background(isDark ? Color.white.opacity(0.08) : Color.black.opacity(0.04)) | ||
| .clipShape(Capsule()) | ||
| } | ||
|
|
||
| // Diff Content | ||
| if !diffText.isEmpty { | ||
| VStack(alignment: .leading, spacing: 0) { | ||
| Button { | ||
| withAnimation(.spring(response: 0.3, dampingFraction: 0.7)) { | ||
| showDiff.toggle() | ||
| } | ||
| Haptics.selection() | ||
| } label: { | ||
| HStack { | ||
| Image(systemName: showDiff ? "chevron.down" : "chevron.right") | ||
| .font(.system(size: 9, weight: .bold)) | ||
| Text(showDiff ? "Hide Diff" : "View Diff") | ||
| .font(.caption2.weight(.semibold)) | ||
| Spacer() | ||
| } | ||
| .foregroundColor(isDark ? Color(hex: "#94A3B8") : Color(hex: "#64748B")) | ||
| .padding(.vertical, 2) | ||
| } | ||
| .buttonStyle(.plain) | ||
|
|
||
| if showDiff { | ||
| ScrollView(.horizontal, showsIndicators: false) { | ||
| VStack(alignment: .leading, spacing: 1) { | ||
| ForEach(Array(diffText.components(separatedBy: "\n").prefix(30).enumerated()), id: \.offset) { _, line in | ||
| diffLineView(line, isDark: isDark) | ||
| } | ||
| } | ||
| .padding(6) | ||
| } | ||
| .background(isDark ? Color.black.opacity(0.55) : Color(hex: "#0F172A")) | ||
| .clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous)) | ||
| .transition(.opacity.combined(with: .move(edge: .top))) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Divider().background(isDark ? Color.white.opacity(0.12) : Color.black.opacity(0.08)) | ||
|
|
||
| // Footer Actions | ||
| HStack(spacing: 8) { | ||
| Button { | ||
| PlatformBridge.copyToPasteboard(diffText) | ||
| Haptics.selection() | ||
| } label: { | ||
| HStack(spacing: 4) { | ||
| Image(systemName: "doc.on.doc") | ||
| Text("Copy Diff") | ||
| } | ||
| .font(.caption2.weight(.medium)) | ||
| .foregroundColor(isDark ? Color(hex: "#94A3B8") : Color(hex: "#64748B")) | ||
| } | ||
| .buttonStyle(.plain) | ||
|
|
||
| Spacer() | ||
|
|
||
| Button { | ||
| withAnimation(.spring(response: 0.35, dampingFraction: 0.6)) { | ||
| isApproved.toggle() | ||
| } | ||
| if isApproved { | ||
| SoundEffects.playActionSuccess() | ||
| Haptics.success() | ||
| } | ||
| } label: { | ||
| HStack(spacing: 4) { | ||
| Image(systemName: isApproved ? "checkmark.circle.fill" : "checkmark") | ||
| .font(.system(size: 10, weight: .bold)) | ||
| Text(isApproved ? "Approved" : "Approve Diff") | ||
| .font(.caption2.weight(.bold)) | ||
| } | ||
| .foregroundColor(.white) | ||
| .padding(.horizontal, 10) | ||
| .padding(.vertical, 5) | ||
| .background( | ||
| isApproved | ||
| ? LinearGradient(colors: [Color(hex: "#8B5CF6"), Color(hex: "#7C3AED")], startPoint: .topLeading, endPoint: .bottomTrailing) | ||
| : LinearGradient(colors: [Color(hex: "#10B981"), Color(hex: "#059669")], startPoint: .topLeading, endPoint: .bottomTrailing) | ||
| ) | ||
| .clipShape(Capsule()) | ||
| } | ||
| .buttonStyle(.plain) | ||
| } | ||
| } | ||
| .padding(10) | ||
| .background( | ||
| LinearGradient( | ||
| colors: isDark ? [ | ||
| Color(hex: "#0D1117").opacity(0.96), | ||
| Color(hex: "#161B22").opacity(0.92) | ||
| ] : [ | ||
| Color.white.opacity(0.96), | ||
| Color(hex: "#F8FAFC").opacity(0.92) | ||
| ], | ||
| startPoint: .topLeading, | ||
| endPoint: .bottomTrailing | ||
| ) | ||
| ) | ||
| .background(.ultraThinMaterial) | ||
| .clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous)) | ||
| .overlay( | ||
| RoundedRectangle(cornerRadius: 12, style: .continuous) | ||
| .stroke(isDark ? Color.white.opacity(0.12) : Color.black.opacity(0.08), lineWidth: 0.75) | ||
| ) | ||
| .shadow(color: Color.black.opacity(isDark ? 0.20 : 0.04), radius: 4, y: 1.5) | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private func diffLineView(_ line: String, isDark: Bool) -> some View { | ||
| let isAddition = line.hasPrefix("+") && !line.hasPrefix("+++") | ||
| let isDeletion = line.hasPrefix("-") && !line.hasPrefix("---") | ||
| let isHeader = line.hasPrefix("@@") || line.hasPrefix("diff") | ||
|
|
||
| Text(line) | ||
| .font(.system(size: 10, design: .monospaced)) | ||
| .foregroundColor( | ||
| isAddition ? Color(hex: "#4ADE80") : | ||
| isDeletion ? Color(hex: "#F87171") : | ||
| isHeader ? Color(hex: "#38BDF8") : | ||
| Color(hex: "#E2E8F0") | ||
| ) | ||
| .padding(.horizontal, 4) | ||
| .padding(.vertical, 1) | ||
| .background( | ||
| isAddition ? Color(hex: "#22C55E").opacity(0.15) : | ||
| isDeletion ? Color(hex: "#EF4444").opacity(0.15) : | ||
| Color.clear | ||
| ) | ||
| .clipShape(RoundedRectangle(cornerRadius: 2)) | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Emit one haptic for each copy action.
PlatformBridge.copyToPasteboardalready callsHaptics.selection(). The explicit calls cause duplicate feedback.ios/App/Cards/GitPRDiffCardView.swift#L105-L107: remove the localHaptics.selection()call.ios/App/Cards/SQLResultTableView.swift#L96-L99: remove the localHaptics.selection()call.📍 Affects 2 files
ios/App/Cards/GitPRDiffCardView.swift#L105-L107(this comment)ios/App/Cards/SQLResultTableView.swift#L96-L99🤖 Prompt for AI Agents