-
Notifications
You must be signed in to change notification settings - Fork 83
feat: add signal_type field (optional, inferred) to InterfaceTemplate and PlacedPort #3120
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
Open
githappens
wants to merge
3
commits into
RackulaLives:main
Choose a base branch
from
githappens:feat/1935-signal-type
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/tests/fixtures/upgrade-corpus/v26.7.0-signal-type.expected.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "allowList": [ | ||
| { | ||
| "pathPattern": "\\.position$", | ||
| "reason": "rail position 3 is converted to internal 1/6U units on load; no coincidental duplicate elsewhere in this fixture unlike the sibling AV fixtures" | ||
| } | ||
| ] | ||
| } |
53 changes: 53 additions & 0 deletions
53
src/tests/fixtures/upgrade-corpus/v26.7.0-signal-type.rackula.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # yaml-language-server: $schema=https://count.racku.la/schemas/rackula-layout.schema.json | ||
| metadata: | ||
| id: 3f8a1c2d-9e4b-4c7a-8d1f-6b2e9a5c3d71 | ||
| name: Signal Type Demo Rack | ||
| schema_version: "1.1" | ||
| version: "26.7.0" | ||
| name: Signal Type Demo Rack | ||
| racks: | ||
| - id: rack-signal | ||
| name: Signal Demo Rack | ||
| height: 8 | ||
| width: 19 | ||
| desc_units: false | ||
| show_rear: true | ||
| form_factor: 4-post-cabinet | ||
| starting_unit: 1 | ||
| position: 0 | ||
| devices: | ||
| - id: dev-signal-demo | ||
| device_type: signal-demo-device | ||
| position: 3 | ||
| face: front | ||
| ports: | ||
| - id: port-mic-in | ||
| template_name: Mic In | ||
| template_index: 0 | ||
| type: xlr-3 | ||
| direction: input | ||
| - id: port-aes-out | ||
| template_name: AES Out | ||
| template_index: 1 | ||
| type: xlr-3 | ||
| direction: output | ||
| signal_type: digital-audio-aes3 | ||
| device_types: | ||
| - slug: signal-demo-device | ||
| manufacturer: Acme Audio | ||
| model: Signal Demo 1U | ||
| u_height: 1 | ||
| colour: "#8BE9FD" | ||
| category: av-media | ||
| interfaces: | ||
| - name: Mic In | ||
| type: xlr-3 | ||
| direction: input | ||
| signal_type: analog-audio-mic | ||
| - name: AES Out | ||
| type: xlr-3 | ||
| direction: output | ||
| signal_type: digital-audio-aes3 | ||
| settings: | ||
| display_mode: label | ||
| show_labels_on_images: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| InterfaceTemplateSchema, | ||
| PlacedPortSchema, | ||
| SignalTypeSchema, | ||
| } from "$lib/schemas"; | ||
| import { getSignalLabel, inferSignalType } from "$lib/utils/port-utils"; | ||
| import { createTestInterfaceTemplate, createTestPlacedPort } from "./factories"; | ||
| import type { SignalType } from "$lib/types"; | ||
|
|
||
| describe("inferSignalType", () => { | ||
| it("infers mic level for XLR inputs and line level otherwise", () => { | ||
| expect(inferSignalType("xlr-3", "input")).toBe("analog-audio-mic"); | ||
| expect(inferSignalType("xlr-3", "output")).toBe("analog-audio-line"); | ||
| expect(inferSignalType("xlr-3")).toBe("analog-audio-line"); | ||
| }); | ||
|
|
||
| it("maps analog connectors to line level and speakon to speaker level", () => { | ||
| expect(inferSignalType("trs-1-4")).toBe("analog-audio-line"); | ||
| expect(inferSignalType("ts-1-4")).toBe("analog-audio-line"); | ||
| expect(inferSignalType("rca")).toBe("analog-audio-line"); | ||
| expect(inferSignalType("db25-audio")).toBe("analog-audio-line"); | ||
| expect(inferSignalType("phoenix")).toBe("analog-audio-line"); | ||
| expect(inferSignalType("speakon")).toBe("analog-audio-speaker"); | ||
| }); | ||
|
|
||
| it("maps digital audio, video, clock, and control connectors", () => { | ||
| expect(inferSignalType("aes3")).toBe("digital-audio-aes3"); | ||
| expect(inferSignalType("dante")).toBe("digital-audio-dante"); | ||
| expect(inferSignalType("avb")).toBe("digital-audio-avb"); | ||
| expect(inferSignalType("hdmi")).toBe("digital-video-hdmi"); | ||
| expect(inferSignalType("sdi-bnc")).toBe("digital-video-sdi"); | ||
| expect(inferSignalType("bnc")).toBe("clock-word"); | ||
| expect(inferSignalType("midi-din")).toBe("control-midi"); | ||
| }); | ||
|
|
||
| it("returns undefined when the connector implies no distinct signal", () => { | ||
| expect(inferSignalType("1000base-t")).toBeUndefined(); | ||
| expect(inferSignalType("console")).toBeUndefined(); | ||
| expect(inferSignalType("dmx-xlr")).toBeUndefined(); | ||
| expect(inferSignalType("adat-optical")).toBeUndefined(); | ||
| expect(inferSignalType("usb-c")).toBeUndefined(); | ||
| }); | ||
| }); | ||
|
|
||
| describe("getSignalLabel", () => { | ||
| it("labels known signals and falls back to the raw slug", () => { | ||
| expect(getSignalLabel("analog-audio-mic")).toBe("Mic level"); | ||
| expect(getSignalLabel("clock-word")).toBe("Word clock"); | ||
| expect(getSignalLabel("future-signal" as SignalType)).toBe("future-signal"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("signal_type schema fields", () => { | ||
| it("accepts signal_type on interface templates and placed ports", () => { | ||
| const template = InterfaceTemplateSchema.parse( | ||
| createTestInterfaceTemplate({ | ||
| type: "xlr-3", | ||
| signal_type: "digital-audio-aes3", | ||
| }), | ||
| ); | ||
| expect(template.signal_type).toBe("digital-audio-aes3"); | ||
|
|
||
| const port = PlacedPortSchema.parse( | ||
| createTestPlacedPort({ type: "xlr-3", signal_type: "analog-audio-mic" }), | ||
| ); | ||
| expect(port.signal_type).toBe("analog-audio-mic"); | ||
| }); | ||
|
|
||
| it("rejects unknown signal_type values", () => { | ||
| expect(SignalTypeSchema.safeParse("laser-show").success).toBe(false); | ||
| expect( | ||
| InterfaceTemplateSchema.safeParse({ | ||
| ...createTestInterfaceTemplate(), | ||
| signal_type: "laser-show", | ||
| }).success, | ||
| ).toBe(false); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Suggestion: This computes signal text from an
InterfaceTemplateonly, so a placed port'ssignal_typeoverride is never considered in the tooltip. That breaks the new precedence contract (placed override should win over template/inference) and will show incorrect signal labels for overridden ports. Update the tooltip input contract to include the placed port override (or a pre-resolved effective signal) and resolve as placed override → template value → inference. [api mismatch]Severity Level: Major⚠️
Steps of Reproduction ✅
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
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.
Good catch, but deferring for this PR. The port tooltip is template-only by existing design: the
portTooltipstore carries anInterfaceTemplate, andshowPortTooltipis invoked with the template (seePortIndicators.svelte). The same gap already exists for the pre-existingPlacedPort.directionoverride, whichgetDirectionLabellikewise does not surface in the tooltip. This change deliberately mirrors that behavior; the issue scopesPlacedPort.signal_typeas a read-time override, with the override-consuming read paths landing in the follow-up connections work.The field is persisted and validated end to end: the
v26.7.0-signal-typeupgrade-corpus fixture round-trips an explicit AES3-over-XLR override. Threading placed-port overrides into the tooltip (for bothsignal_typeanddirection, to keep them consistent) is a reasonable follow-up rather than part of this additive-field change.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.
✅ Customized review instruction saved!
Instruction:
Applied to:
src/lib/components/PortTooltip.sveltesrc/lib/components/PortIndicators.sveltesrc/lib/stores/portTooltip.svelte.ts💡 To manage or update this instruction, visit: CodeAnt AI Settings