Skip to content

Refactor/s3 hardware detect - #72

Merged
victoria-lo merged 3 commits into
mainfrom
refactor/s3-hardware-detect
Jun 16, 2026
Merged

Refactor/s3 hardware detect#72
victoria-lo merged 3 commits into
mainfrom
refactor/s3-hardware-detect

Conversation

@natashaannn

@natashaannn natashaannn commented May 14, 2026

Copy link
Copy Markdown
Member

Closes #22

Summary

  • Adds HardwareProfile type and detectHardware(): Promise<HardwareProfile> to scripts/config/hardware.ts
  • Derives encoder profile from process.platform / process.arch: macOS → videotoolbox, Linux x64 → nvenc, all else → libx264
  • 21 unit tests covering all three hardware paths via mocked platform/arch values

Test plan

  • npm test — 205 passing, 0 failures
  • tsc --noEmit — clean
  • macOS (darwin/arm64) smoke test — detectHardware() returns encoderProfile: "videotoolbox", supportsVideoToolbox: true
  • Windows manual test — needs reviewer on Windows machine (see below)
  • Linux/NVIDIA — covered by unit test mock; real hardware not available

Windows manual test instructions

On a Windows machine, check out the branch and run:

git checkout refactor/s3-hardware-detect

Create a test file hw-test.ts in the repo root:

import { detectHardware } from './scripts/config/hardware.ts';
const p = await detectHardware();
console.log(JSON.stringify(p, null, 2));

Run it:

npx tsx hw-test.ts

Expected output:

{
  "platform": "win32",
  "arch": "x64",
  "supportsVideoToolbox": false,
  "supportsCuda": false,
  "encoderProfile": "libx264"
}

Delete the test file when done: del hw-test.ts

Key things to confirm: supportsVideoToolbox and supportsCuda are both false, encoderProfile is "libx264".

Notes

  • Phase 1 only: no FFmpeg integration, no nvidia-smi probe. The Linux/x64 → CUDA heuristic will be refined with a real probe in a later phase.
  • Downstream issues (Add typed FFmpeg command builder #23 FFmpeg command builder) will import detectHardware() and HardwareProfile from this file.

🤖 Generated with issue-pilot skill

…ation

Introduces the canonical hardware detection layer for the DeckCreate
pipeline (Phase 1, Step 1). Downstream callers no longer need to
inspect process.platform or process.arch directly — all hardware-
sensitive decisions should derive from detectHardware().

Phase 1 logic is lightweight and purely synchronous:
- darwin → supportsVideoToolbox=true, encoderProfile=videotoolbox
- linux/x64 → supportsCuda=true (heuristic), encoderProfile=nvenc
- everything else → CPU fallback, encoderProfile=libx264

The function is async so future phases can add non-blocking probes
(e.g. nvidia-smi) without changing the caller interface.

21 unit tests cover darwin/arm64, darwin/x64, linux/x64, linux/arm64,
win32/x64, and the shape contract.

AC: #1 (HardwareProfile type), #2 (detectHardware resolves), #3 (cases covered), #4 (no process.platform in callers needed)
Hardware detection layer implemented on refactor/s3-hardware-detect.
Unblocks issue #6 (typed FFmpeg command abstraction).
Add scripts/config/hardware.ts to Key Source Files table.
@natashaannn
natashaannn requested a review from victoria-lo May 14, 2026 08:33
@natashaannn

Copy link
Copy Markdown
Member Author

Hi @victoria-lo , opening this PR first because it requires testing on a Windows machine. I technically could use my Windows to test but best would be to check with yours as it is intended to work on your hardware - opening the PR early so you can take your time to test when able!

@natashaannn

Copy link
Copy Markdown
Member Author

@victoria-lo Pinging again so you know to review this when you have time!

@victoria-lo victoria-lo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Image

Confirmed the script runs as expected and outputs expected JSON

@victoria-lo
victoria-lo merged commit e6c3eb6 into main Jun 16, 2026
1 check passed
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.

Add hardware detection abstraction

2 participants