Skip to content

Update BonjourPico integration with new API and async/await#1

Merged
ronaldmannak merged 6 commits into
mainfrom
claude/relaxed-clarke-0w15yr
Jun 18, 2026
Merged

Update BonjourPico integration with new API and async/await#1
ronaldmannak merged 6 commits into
mainfrom
claude/relaxed-clarke-0w15yr

Conversation

@ronaldmannak

Copy link
Copy Markdown
Contributor

Summary

This PR updates the SelectServerView to work with the latest BonjourPico API, which introduces breaking changes to the data model and scanning interface. The changes modernize the code to use async/await patterns and improve the server connection logic.

Key Changes

  • Data model updates: Changed from bonjourPico.servers to bonjourPico.endpoints with updated property names (displayName instead of name, ipAddresses array instead of single ipAddress)
  • Improved connection logic: Now prefers advertised IP addresses from the endpoint, with fallback to the Bonjour host name for more robust server discovery
  • Async/await migration: Replaced synchronous startStop() method with async startScanning() and stopScanning() methods
  • Lifecycle improvements: Changed from .onAppear to .task modifier for proper async initialization
  • Button action refactoring: Wrapped scanning toggle in a Task to properly handle async operations

Notable Implementation Details

  • The connection URL construction now safely handles multiple IP addresses with a fallback mechanism: endpoint.ipAddresses.first ?? endpoint.hostName
  • Error messages are more descriptive, including the endpoint display name for debugging
  • The scanning button action now explicitly checks isScanning state to call the appropriate async method
  • Updated to track the main branch of BonjourPico for latest development changes

https://claude.ai/code/session_01XhgHkRGhNMDrJ525CAeiga

BonjourPico's v2 rewrite replaced its discovery surface with an
@observable facade. Migrate SelectServerView to the new API:

- bonjourPico.servers      -> bonjourPico.endpoints ([BonjourEndpoint])
- server.name              -> endpoint.displayName
- server.ipAddress         -> endpoint.ipAddresses.first (falls back to hostName)
- startStop()              -> async startScanning() / stopScanning(), toggled
                              in a Task; the initial scan is kicked off via .task

Repoint the example app's BonjourPico dependency from the 0.0.1 tag (old
API) to the main branch, where v2 is merged, and refresh Package.resolved.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XhgHkRGhNMDrJ525CAeiga

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the BonjourPico dependency to the main branch and refactors SelectServerView.swift to use the new asynchronous endpoints API. It also transitions scanning operations to Swift concurrency using Task and the .task modifier. The review feedback points out a potential issue where IPv6 addresses containing colons will fail to parse as valid URLs unless they are enclosed in square brackets, and provides a code suggestion to handle this case.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread ResponsesExample/ResponsesExample/SelectServerView.swift Outdated
The package has no SwiftUI/UIKit/AppKit or platform-conditional code, so a
single macOS SwiftPM run compiles and exercises both library targets
(OpenResponses, OpenResponsesSwiftUI) and both Swift Testing suites.

Runs on pushes to main and on pull requests. Uses the latest stable Xcode
to provide the Swift 6.2 toolchain the package's tools-version requires.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XhgHkRGhNMDrJ525CAeiga

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c51ddccd9e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ResponsesExample/ResponsesExample/SelectServerView.swift Outdated
Comment thread ResponsesExample/ResponsesExample/SelectServerView.swift
claude added 2 commits June 17, 2026 23:42
A discovered endpoint may advertise an IPv6 address as its first IP. Interpolating
it raw into "http://<host>:<port>" produces an invalid URL (URL(string:) returns
nil), so the server can't be selected.

Prefer the Bonjour host name (which BonjourPico documents as the way to connect)
and fall back to an advertised IP, bracketing IPv6 literals so the URL host is
valid. Addresses the IPv6 review feedback on PR #1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XhgHkRGhNMDrJ525CAeiga
With the new BonjourPico API, stopScanning() clears `endpoints`, which made the
"Stop scanning" button wipe every discovered server from the list. Restore the
previous behavior by rendering from a local @State snapshot that mirrors
bonjourPico.endpoints while scanning and is preserved when scanning stops, so the
list stays visible and selectable. Addresses the review feedback on PR #1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XhgHkRGhNMDrJ525CAeiga

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1183db8b3b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ResponsesExample/ResponsesExample/SelectServerView.swift
Comment thread .github/workflows/ci.yml
claude added 2 commits June 18, 2026 00:12
The local discoveredServers snapshot is intentionally preserved when a scan
stops, so the list stays selectable. But the onChange guard only copies
endpoints while isScanning is true, so a *new* scan that finds nothing never
overwrote the old snapshot — leaving stale servers from the previous scan
visible and selectable.

Clear discoveredServers at the start of each scan (via a startScan() helper
used by both .task and the Scan button) so a fresh scan begins empty and only
shows servers it actually rediscovers. Stopping a scan still keeps the list.

Addresses Codex review feedback on PR #1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XhgHkRGhNMDrJ525CAeiga
Codex flagged that CI only built the SwiftPM package, so the example app
(the subject of this PR) and its Xcode package resolution were never
compiled. Wiring it up for CI surfaced stale, pre-existing dependencies:

- The project linked products PicoResponsesCore / PicoResponsesSwiftUI from
  a local sibling package ../../PicoResponses (the repo's pre-rename name),
  while the sources import the renamed OpenResponses / OpenResponsesSwiftUI
  modules. Repoint that dependency to the in-repo package (..) and link the
  OpenResponses / OpenResponsesSwiftUI products.
- PicoMarkdownView was a local sibling (../../PicoMarkdownView) absent from
  this repo, so CI could not resolve it. Convert it to a remote package
  reference (github.com/PicoMLX/PicoMarkdownView, main) and pin it.

Add a shared ResponsesExample scheme so xcodebuild can build it by name, and
add a build-example CI job that resolves packages and builds the app for
macOS with code signing disabled.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XhgHkRGhNMDrJ525CAeiga
@ronaldmannak

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: d6d065f5e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ronaldmannak ronaldmannak merged commit 9c6e168 into main Jun 18, 2026
2 checks passed
@ronaldmannak ronaldmannak deleted the claude/relaxed-clarke-0w15yr branch June 18, 2026 04:14
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.

2 participants