Skip to content

Conversation

@NSPC911
Copy link

@NSPC911 NSPC911 commented Dec 29, 2025

Prerequisites

  • I have read and understood the contributing guide.
  • The commit message follows the conventional commits guidelines.
  • Tests for the changes have been added (for bug fixes / features).
  • Docs have been added/updated (for bug fixes / features).

Description

Adds an integration with pear desktop as a segment.

Would like some help with this, because it renders the prompt once, then falls back to the default prompt

image

AI was used in the creation of this PR for scaffolding purposese, I wanted to rawdog my way through as part of my second interaction with GoLang. Code may be scuffed, I copy-pasted it from other segments like YTM

Copilot AI review requested due to automatic review settings December 29, 2025 08:55
@JanDeDobbeleer
Copy link
Owner

Thanks for submitting a PR to the project!

In order to review and merge PRs most efficiently, we require that all PRs grant maintainer edit access before we review them. For information on how to do this, see the documentation.

@NSPC911 NSPC911 marked this pull request as ready for review December 29, 2025 08:58
Copy link
Contributor

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

This PR adds a new segment for integrating Pear Desktop music player into Oh My Posh. The implementation follows the pattern of existing music segments (YTM, Spotify), querying a local API endpoint to display currently playing track information. However, the implementation has several critical bugs that need to be addressed before merging.

Key Changes:

  • New Pear Desktop segment implementation with API integration
  • Documentation and schema configuration for the segment
  • Test coverage for various playback states and error conditions

Reviewed changes

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

Show a summary per file
File Description
src/segments/peard.go Core segment implementation that queries Pear Desktop's local API to fetch track information and status
src/segments/peard_test.go Unit tests covering playing/paused states, error handling, and custom port configuration
src/config/segment_types.go Registers the new PEARD segment type in the type system
website/docs/segments/music/peard.mdx Documentation explaining setup, configuration options, and template properties
website/sidebars.js Adds Pear Desktop segment to the music section of the documentation sidebar
themes/schema.json JSON schema definition for segment validation and IDE autocomplete

Comment on lines 84 to 89
p.Icon = p.options.String(PausedIcon, "\uf04b ")
return nil
}

p.Status = playing
p.Icon = p.options.String(PlayingIcon, "\uf04c ")
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

The playing and paused icons are swapped. When paused, the code uses PlayingIcon (play symbol \uf04b), but should use PausedIcon (pause symbol). Similarly, when playing, it uses PausedIcon instead of PlayingIcon. The logic should be:

  • When paused: use PausedIcon (\uf04c)
  • When playing: use PlayingIcon (\uf04b)
Suggested change
p.Icon = p.options.String(PausedIcon, "\uf04b ")
return nil
}
p.Status = playing
p.Icon = p.options.String(PlayingIcon, "\uf04c ")
p.Icon = p.options.String(PausedIcon, "\uf04c ")
return nil
}
p.Status = playing
p.Icon = p.options.String(PlayingIcon, "\uf04b ")

Copilot uses AI. Check for mistakes.

const (
// Port is the port to connect to Pear Desktop API
Port options.Option = "port"
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

The constants PlayingIcon and PausedIcon are used but never defined in this file. These need to be added to the const block. You can reference how other music segments like Spotify define these constants.

Suggested change
Port options.Option = "port"
Port options.Option = "port"
PlayingIcon options.Option = "playing_icon"
PausedIcon options.Option = "paused_icon"

Copilot uses AI. Check for mistakes.

const (
// Port is the port to connect to Pear Desktop API
Port options.Option = "port"
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

The constants 'playing' and 'paused' are used but never defined. These need to be added to the const block, similar to how they're defined in the Spotify segment.

Suggested change
Port options.Option = "port"
Port options.Option = "port"
paused = "paused"
playing = "playing"

Copilot uses AI. Check for mistakes.
You need to enable the API Server plugin in the Pear Desktop settings.
To do this, open the app, go to `Plugins > API Server [Beta]` and enable it.

You must also disable authorization in `Plugins > API Server [Beta] > Authorization Strategy` for the segment to work.
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

The instruction to disable authorization in the Pear Desktop API Server [Beta] (Authorization Strategy) effectively turns off access control for that API, which can expose playback controls and metadata to any process (or potentially any host) that can reach the API port. An attacker on the same machine or network could abuse this to query or control the player without the user’s consent if the API is not strictly bound to localhost or otherwise isolated. Instead of fully disabling authorization, the segment should support a secure auth mechanism (or clearly document a restricted, localhost-only configuration) so that the API remains protected.

Suggested change
You must also disable authorization in `Plugins > API Server [Beta] > Authorization Strategy` for the segment to work.
Ensure the API Server is configured securely (for example, keep an authorization strategy enabled and/or bind the API to `localhost` only) and that your segment is configured to use the same port.

Copilot uses AI. Check for mistakes.
@NSPC911
Copy link
Author

NSPC911 commented Dec 29, 2025

I spammed the hell out of the Stop Review button, and Copilot refused...

@JanDeDobbeleer
Copy link
Owner

Thanks for submitting a PR to the project!

In order to review and merge PRs most efficiently, we require that all PRs grant maintainer edit access before we review them. For information on how to do this, see the documentation.

@NSPC911
Copy link
Author

NSPC911 commented Dec 29, 2025

In order to review and merge PRs most efficiently, we require that all PRs grant maintainer edit access before we review them. For information on how to do this, see the documentation.

image

well, it's not there, so I don't know what to do

@JanDeDobbeleer
Copy link
Owner

@NSPC911 to solve the issue you have, make sure to add the segment struct to the gob registry as well.

Copilot AI review requested due to automatic review settings December 30, 2025 01:37
Copy link
Contributor

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

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

Comment on lines 63 to 65
| `.TrackUrl` | `string` | YouTube Music URL for the track |
| `.ArtistUrl` | `string` | YouTube Music URL for the artist |
| `.MediaType` | `string` | Media type (`AUDIO`, `ORIGINAL_MUSIC_VIDEO`, `USER_GENERATED_CONTENT`, `PODCAST_EPISODE`, `OTHER_VIDEO`) |
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The documentation incorrectly states that TrackUrl, ArtistUrl, and MediaType properties return "YouTube Music" URLs and types. These properties should describe Pear Desktop-specific values, not YouTube Music values. Update the descriptions to accurately reflect what Pear Desktop returns for these fields.

Suggested change
| `.TrackUrl` | `string` | YouTube Music URL for the track |
| `.ArtistUrl` | `string` | YouTube Music URL for the artist |
| `.MediaType` | `string` | Media type (`AUDIO`, `ORIGINAL_MUSIC_VIDEO`, `USER_GENERATED_CONTENT`, `PODCAST_EPISODE`, `OTHER_VIDEO`) |
| `.TrackUrl` | `string` | URL for the current track as reported by Pear Desktop (for example, a web URL or app deep link; may be empty) |
| `.ArtistUrl` | `string` | URL for the current artist as reported by Pear Desktop (for example, a web URL or app deep link; may be empty) |
| `.MediaType` | `string` | Media type value returned by Pear Desktop for the current item (for example, `AUDIO`, `VIDEO`, or other app-specific types) |

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings December 30, 2025 01:57
@NSPC911
Copy link
Author

NSPC911 commented Dec 30, 2025

I want to know, so Pear Desktop does support API Authentication, and doing something like curl -X POST https://127.0.0.1/auth/oh-my-posh gives you a json of {"accessToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} but I'm not sure how to implement it, aside from well just copy pasting code

The cache as well, I don't think Pear Desktop has any sort of limits, so spamming is possible, but should Caching be implemented?

also oh my god copilot, I turned him off already, he still wants to review it

Copy link
Contributor

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

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

Comment on lines +12 to +23
Base

Status string
Artist string
Track string
TrackUrl string
ArtistUrl string
MediaType string
IsPaused bool
SongDuration int
ElapsedSeconds int
Icon string
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The PearDesktop struct duplicates fields that already exist in the MusicPlayer struct (Status, Artist, Track, Icon). Following the pattern used by Spotify and YTM segments, this struct should embed MusicPlayer instead of duplicating its fields. This would eliminate redundancy and ensure consistency with other music player segments.

Suggested change
Base
Status string
Artist string
Track string
TrackUrl string
ArtistUrl string
MediaType string
IsPaused bool
SongDuration int
ElapsedSeconds int
Icon string
MusicPlayer
TrackUrl string
ArtistUrl string
MediaType string
IsPaused bool
SongDuration int
ElapsedSeconds int

Copilot uses AI. Check for mistakes.
IsPaused bool `json:"isPaused"`
SongDuration int `json:"songDuration"`
ElapsedSeconds int `json:"elapsedSeconds"`
Url string `json:"url"`
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The Url field name violates Go naming conventions. According to Go style guides, initialisms should be all uppercase or all lowercase. This should be renamed to URL to follow idiomatic Go naming, matching the pattern used in ArtistUrl which should also be ArtistURL.

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +19
TrackUrl string
ArtistUrl string
MediaType string
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The TrackUrl and ArtistUrl field names in the struct violate Go naming conventions. According to Go style guides, initialisms like URL should be all uppercase or all lowercase. These should be renamed to TrackURL and ArtistURL to follow idiomatic Go naming.

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.

2 participants