Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions leanring-buddy/CompanionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ final class CompanionManager: ObservableObject {
}
}

/// Whether Clicky's responses are automatically copied to the clipboard.
/// Defaults to OFF. Persisted to UserDefaults.
@Published var isAutoCopyResponseEnabled: Bool = UserDefaults.standard.bool(forKey: "isAutoCopyResponseEnabled")

func setAutoCopyResponseEnabled(_ enabled: Bool) {
isAutoCopyResponseEnabled = enabled
UserDefaults.standard.set(enabled, forKey: "isAutoCopyResponseEnabled")
}

/// Whether the user has completed onboarding at least once. Persisted
/// to UserDefaults so the Start button only appears on first launch.
var hasCompletedOnboarding: Bool {
Expand Down Expand Up @@ -681,6 +690,12 @@ final class CompanionManager: ObservableObject {
print("🎯 Element pointing: \(parseResult.elementLabel ?? "no element")")
}

// Copy the clean response to the clipboard if the user has enabled auto-copy
if isAutoCopyResponseEnabled {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(spokenText, forType: .string)
}

// Save this exchange to conversation history (with the point tag
// stripped so it doesn't confuse future context)
conversationHistory.append((
Expand Down
32 changes: 32 additions & 0 deletions leanring-buddy/CompanionPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ struct CompanionPanelView: View {
Spacer()
.frame(height: 16)

autoCopyResponseToggleRow
.padding(.horizontal, 16)

dmFarzaButton
.padding(.horizontal, 16)
}
Expand Down Expand Up @@ -545,6 +548,35 @@ struct CompanionPanelView: View {



// MARK: - Auto-Copy Response Toggle

private var autoCopyResponseToggleRow: some View {
HStack {
HStack(spacing: 8) {
Image(systemName: "doc.on.clipboard")
.font(.system(size: 12, weight: .medium))
.foregroundColor(DS.Colors.textTertiary)
.frame(width: 16)

Text("Copy responses")
.font(.system(size: 13, weight: .medium))
.foregroundColor(DS.Colors.textSecondary)
}

Spacer()

Toggle("", isOn: Binding(
get: { companionManager.isAutoCopyResponseEnabled },
set: { companionManager.setAutoCopyResponseEnabled($0) }
))
.toggleStyle(.switch)
.labelsHidden()
.tint(DS.Colors.accent)
.scaleEffect(0.8)
}
.padding(.vertical, 4)
}

// MARK: - Show Clicky Cursor Toggle

private var showClickyCursorToggleRow: some View {
Expand Down