Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions configurator/src/components/ActiveApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ interface Props {
layoutId: number;
startChannel: number;
params: Value[];
/** The app declares params but never answered a request for them. */
notResponding?: boolean;
}

// react-hook-form seeds each field's value once, when the form itself is
Expand Down Expand Up @@ -105,7 +107,13 @@ const ActiveAppParamsForm = ({
);
};

export const ActiveApp = ({ app, layoutId, params, startChannel }: Props) => {
export const ActiveApp = ({
app,
layoutId,
params,
startChannel,
notResponding,
}: Props) => {
return (
<details className="group w-full bg-black">
<summary
Expand All @@ -128,7 +136,17 @@ export const ActiveApp = ({ app, layoutId, params, startChannel }: Props) => {
</div>
<div className="flex-1">
<p className="text-yellow-fp text-sm font-bold uppercase">App</p>
<p className="text-lg font-medium">{app.name}</p>
<p className="flex items-center gap-2 text-lg font-medium">
{app.name}
{notResponding && (
<span
className="rounded bg-red-900 px-2 py-0.5 text-xs font-bold tracking-wide text-red-200 uppercase"
title="This app declares parameters but hasn't answered a request for them — its params may be unreachable from the Configurator."
>
Not responding
</span>
)}
</p>
</div>
<div className="flex-1">
<p className="text-yellow-fp text-sm font-bold uppercase">
Expand Down Expand Up @@ -164,7 +182,13 @@ export const ActiveApp = ({ app, layoutId, params, startChannel }: Props) => {
<div className="w-7" />
)}
</summary>
{app.paramCount > 0 ? (
{app.paramCount > 0 && notResponding ? (
<div className="border-default-100 border-y-3 px-4 py-8 text-red-300">
This app hasn't answered a parameter request, so there's nothing real
to show here — showing empty or default values would be misleading,
and saving them could overwrite what the app actually holds.
</div>
) : app.paramCount > 0 ? (
<ActiveAppParamsForm
key={JSON.stringify(params)}
app={app}
Expand Down
11 changes: 7 additions & 4 deletions configurator/src/components/ActiveApps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ export const ActiveApps = () => {
)
.map(({ app, id, startChannel }) => {
const params = allParams.get(id);
if (!params) {
return null;
}
// A missing entry is normal for an app with no params (it never
// gets asked). For one that declares params, it means the app
// never answered a param request — still worth a card, so the
// silence is visible instead of the app just not being listed.
const notResponding = app.paramCount > 0 && !params;
return (
<li key={id}>
<ActiveApp
app={app}
startChannel={startChannel}
layoutId={id}
params={params}
params={params ?? []}
notResponding={notResponding}
/>
</li>
);
Expand Down
11 changes: 11 additions & 0 deletions faderpunk/src/tasks/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ pub async fn start_config_loop<'a>(usb_tx: &'a SharedUsbSender<'a>) {
proto.send_msg(ConfigMsgOut::GlobalConfig(config)).await
}
ConfigMsgIn::GetAppParams { layout_id } => {
// layout_id comes straight from the client with no validation
// elsewhere; every other caller indexes it from a real
// Layout, but this one goes over the wire raw. Answering
// nothing for an out-of-range id (same as an app that never
// replies) beats indexing APP_PARAM_SIGNALS out of bounds.
if layout_id as usize >= GLOBAL_CHANNELS {
continue;
}
drain_app_param_responses();
APP_PARAM_SIGNALS[layout_id as usize].signal(AppParamCmd::RequestParamValues);
match receive_app_params(layout_id).await {
Expand All @@ -258,6 +266,9 @@ pub async fn start_config_loop<'a>(usb_tx: &'a SharedUsbSender<'a>) {
}
}
ConfigMsgIn::SetAppParams { layout_id, values } => {
if layout_id as usize >= GLOBAL_CHANNELS {
continue;
}
drain_app_param_responses();
APP_PARAM_SIGNALS[layout_id as usize].signal(AppParamCmd::SetAppParams { values });
match receive_app_params(layout_id).await {
Expand Down
Loading