Skip to content

Commit 6986299

Browse files
committed
fix(orientation): disclose an unconfirmed rotation instead of asserting it
executeSetOrientation fell back to the requested rotation when the owner reported no resulting orientation, then reported 'Rotated to <request>' as a success claim. Keep the requested rotation for compatibility, but mark the claim unconfirmed and warn.
1 parent f57b421 commit 6986299

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/daemon/__tests__/orientation-runtime.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ test('resolves one admitted binding and reports the owner-observed rotation', as
142142
});
143143
});
144144

145-
test('falls back to the requested rotation when the owner reports nothing', async () => {
145+
test('keeps the requested rotation but discloses that the owner reported nothing', async () => {
146146
const harness = runtimeHarness();
147147

148148
const resolved = await resolveBoundOrientationRuntime({
@@ -156,7 +156,10 @@ test('falls back to the requested rotation when the owner reports nothing', asyn
156156
expect(await resolved.execute(orientationExecutionParams(['portrait']))).toEqual({
157157
action: 'orientation',
158158
orientation: 'portrait',
159-
message: 'Rotated to portrait',
159+
confirmed: false,
160+
warning:
161+
'Requested portrait; the device owner reported no resulting orientation, so the rotation is unconfirmed.',
162+
message: 'Rotation requested: portrait (unconfirmed)',
160163
});
161164
});
162165

src/daemon/orientation-runtime.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ async function executeSetOrientation(
6363
const result = await runtime.operations.setOrientation(
6464
setOrientationInput(requestedRotation, context),
6565
);
66-
const orientation = result?.orientation ?? requestedRotation;
67-
return { action: 'orientation', orientation, ...successText(`Rotated to ${orientation}`) };
66+
const reported = result?.orientation;
67+
if (reported) {
68+
return {
69+
action: 'orientation',
70+
orientation: reported,
71+
...successText(`Rotated to ${reported}`),
72+
};
73+
}
74+
// An owner that reports no resulting rotation is not evidence the device rotated: keep the
75+
// requested rotation for compatibility, but disclose the unconfirmed claim instead of asserting it.
76+
return {
77+
action: 'orientation',
78+
orientation: requestedRotation,
79+
confirmed: false,
80+
warning: `Requested ${requestedRotation}; the device owner reported no resulting orientation, so the rotation is unconfirmed.`,
81+
...successText(`Rotation requested: ${requestedRotation} (unconfirmed)`),
82+
};
6883
}

0 commit comments

Comments
 (0)