Skip to content

Comments

fix: update CopyButton to handle clipboard operations for both UIKit …#23

Merged
sirily11 merged 1 commit intomainfrom
ios-fix
Feb 9, 2026
Merged

fix: update CopyButton to handle clipboard operations for both UIKit …#23
sirily11 merged 1 commit intomainfrom
ios-fix

Conversation

@sirily11
Copy link
Contributor

@sirily11 sirily11 commented Feb 9, 2026

…and AppKit

Copilot AI review requested due to automatic review settings February 9, 2026 18:42
@sirily11 sirily11 enabled auto-merge (squash) February 9, 2026 18:42
@sirily11 sirily11 disabled auto-merge February 9, 2026 18:43
@sirily11 sirily11 merged commit f938a99 into main Feb 9, 2026
5 of 6 checks passed
@sirily11 sirily11 deleted the ios-fix branch February 9, 2026 18:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates cross-platform clipboard support in CopyButton and expands CI to build on iOS in addition to macOS.

Changes:

  • Add conditional clipboard handling for UIKit (UIPasteboard) vs AppKit (NSPasteboard) in CopyButton.
  • Rename the existing CI job to macOS-specific and add a new iOS Simulator build job in GitHub Actions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Sources/AgentLayout/Markdown/CopyButton.swift Switches clipboard implementation to support both UIKit and AppKit.
.github/workflows/swift.yml Splits macOS testing into a named job and adds an iOS build job.
Comments suppressed due to low confidence (1)

Sources/AgentLayout/Markdown/CopyButton.swift:42

  • onCopied() mutates @State (copied) and calls withAnimation after an await, which may resume off the main actor. Mark onCopied as @MainActor (or hop to MainActor for the state mutations) so SwiftUI state updates and pasteboard access remain on the UI thread.
    func onCopied() async {
        #if canImport(UIKit)
            UIPasteboard.general.string = content
        #elseif canImport(AppKit)
            let pasteboard = NSPasteboard.general
            pasteboard.clearContents()
            pasteboard.setString(content, forType: .string)
        #endif
        copied = true
        // Wait 1.5 secs
        try? await Task.sleep(for: .seconds(1.5))
        withAnimation {
            copied = false
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +30 to +36
#if canImport(UIKit)
UIPasteboard.general.string = content
#elseif canImport(AppKit)
let pasteboard = NSPasteboard.general
pasteboard.clearContents()
pasteboard.setString(content, forType: .string)
#endif
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CopyButton references UIPasteboard/NSPasteboard but the file only imports SwiftUI. To ensure this compiles on both iOS and macOS, add conditional imports for UIKit/AppKit (e.g., under #if canImport(...)) before using these APIs.

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +70
- name: Build for iOS Simulator
run: |
xcodebuild build \
-scheme AgentKit \
-destination 'generic/platform=iOS Simulator' \
-skipPackagePluginValidation \
| tail -n 20
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In build-ios, piping xcodebuild into tail without set -o pipefail means the step can succeed even if xcodebuild fails (the exit code will be from tail). Ensure the pipeline preserves xcodebuild's failure status (e.g., enable pipefail or avoid piping altogether).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant