-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[WIP] feat(peard): add segment #7096
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
base: main
Are you sure you want to change the base?
Conversation
|
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. |
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.
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 |
src/segments/peard.go
Outdated
| p.Icon = p.options.String(PausedIcon, "\uf04b ") | ||
| return nil | ||
| } | ||
|
|
||
| p.Status = playing | ||
| p.Icon = p.options.String(PlayingIcon, "\uf04c ") |
Copilot
AI
Dec 29, 2025
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.
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)
| 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 ") |
|
|
||
| const ( | ||
| // Port is the port to connect to Pear Desktop API | ||
| Port options.Option = "port" |
Copilot
AI
Dec 29, 2025
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.
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.
| Port options.Option = "port" | |
| Port options.Option = "port" | |
| PlayingIcon options.Option = "playing_icon" | |
| PausedIcon options.Option = "paused_icon" |
|
|
||
| const ( | ||
| // Port is the port to connect to Pear Desktop API | ||
| Port options.Option = "port" |
Copilot
AI
Dec 29, 2025
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.
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.
| Port options.Option = "port" | |
| Port options.Option = "port" | |
| paused = "paused" | |
| playing = "playing" |
| 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. |
Copilot
AI
Dec 29, 2025
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.
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.
| 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. |
|
I spammed the hell out of the Stop Review button, and Copilot refused... |
|
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. |
well, it's not there, so I don't know what to do |
|
@NSPC911 to solve the issue you have, make sure to add the segment struct to the gob registry as well. |
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.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
| | `.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`) | |
Copilot
AI
Dec 30, 2025
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.
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.
| | `.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) | |
|
I want to know, so Pear Desktop does support API Authentication, and doing something like 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 |
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.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
| Base | ||
|
|
||
| Status string | ||
| Artist string | ||
| Track string | ||
| TrackUrl string | ||
| ArtistUrl string | ||
| MediaType string | ||
| IsPaused bool | ||
| SongDuration int | ||
| ElapsedSeconds int | ||
| Icon string |
Copilot
AI
Dec 30, 2025
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.
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.
| 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 |
| IsPaused bool `json:"isPaused"` | ||
| SongDuration int `json:"songDuration"` | ||
| ElapsedSeconds int `json:"elapsedSeconds"` | ||
| Url string `json:"url"` |
Copilot
AI
Dec 30, 2025
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.
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.
| TrackUrl string | ||
| ArtistUrl string | ||
| MediaType string |
Copilot
AI
Dec 30, 2025
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.
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.

Prerequisites
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
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