Skip to content

feat: Support repository server - #237

Draft
hhvrc wants to merge 8 commits into
developfrom
feature/support-repository-server
Draft

feat: Support repository server#237
hhvrc wants to merge 8 commits into
developfrom
feature/support-repository-server

Conversation

@hhvrc

@hhvrc hhvrc commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

No description provided.

hhvrc and others added 8 commits March 30, 2026 10:48
…pository-server

# Conflicts:
#	.env
#	.env.production
#	src/lib/api/firmwareCDN.ts
#	src/lib/components/FirmwareChannelSelector.svelte
#	src/routes/(app)/hubs/[hubId=guid]/update/+page.svelte
#	src/routes/terminal/+page.svelte
#	src/routes/terminal/FirmwareBoardSelector.svelte
#	src/routes/terminal/FirmwareFlasher.svelte
#	svelte.config.js
@hhvrc hhvrc self-assigned this Aug 4, 2026
Copilot AI lite review requested due to automatic review settings August 4, 2026 13:42
@hhvrc hhvrc added the enhancement New feature or request label Aug 4, 2026
@hhvrc
hhvrc marked this pull request as draft August 4, 2026 13:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 migrates the frontend’s firmware update/flash flow from the legacy firmware CDN endpoints to a new “repository server” API, and wires the new base URL through environment/config so different deployments can point at different firmware repositories.

Changes:

  • Replace the firmware CDN client with a new firmwareRepo API client (latest/version/history + artifact download + SHA-256 verification).
  • Update terminal flashing UI components to operate on a FirmwareRelease response (board extraction + artifact selection).
  • Make the firmware repository origin configurable via PUBLIC_FIRMWARE_REPO_URL and include it in CSP connect-src.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vite.config.ts Adds firmware repo URL to CSP connect-src.
src/routes/terminal/FirmwareFlasher.svelte Switches flashing to download/verify a selected artifact from the repo response.
src/routes/terminal/FirmwareBoardSelector.svelte Derives board list from the fetched release metadata instead of fetching boards per version.
src/routes/terminal/+page.svelte Plumbs latestResponse through the terminal flashing flow and updates component bindings.
src/routes/(app)/hubs/[hubId=guid]/update/+page.svelte Updates firmware channel type import to the new module.
src/lib/components/FirmwareChannelSelector.svelte Fetches latest firmware release per channel and caches responses.
src/lib/api/firmwareRepo.ts Introduces repository server API client + artifact download/verification helpers.
src/lib/api/firmwareCDN.ts Removes legacy firmware CDN implementation.
.env.development Adds PUBLIC_FIRMWARE_REPO_URL for development.
.env Adds PUBLIC_FIRMWARE_REPO_URL for default environment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vite.config.ts
dotenv.PUBLIC_GATEWAY_CSP_WILDCARD,
getWsUrlFromHttpUrl(dotenv.PUBLIC_GATEWAY_CSP_WILDCARD),
'https://firmware.openshock.org',
dotenv.PUBLIC_FIRMWARE_REPO_URL,
Comment on lines 43 to 45
// Capture the current channel to avoid race conditions if channel changes.
const currentChannel = channel;

changelog: string;
}

const BASE_URL = PUBLIC_FIRMWARE_REPO_URL.replace(/\/+$/, '');
export async function DownloadAndVerifyArtifact(artifact: FirmwareArtifact): Promise<Uint8Array> {
const binary = await DownloadBinary(artifact.url);

const calculatedHash = await HashBuffer(binary.buffer as ArrayBuffer, 'SHA-256');
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
openshock-app d228ee3 Aug 05 2026, 08:23 AM

Copilot AI review requested due to automatic review settings August 5, 2026 08:23
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deploying openshockapp with  Cloudflare Pages  Cloudflare Pages

Latest commit: d228ee3
Status: ✅  Deploy successful!
Preview URL: https://0e718dbe.openshockapp.pages.dev
Branch Preview URL: https://feature-support-repository-s.openshockapp.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 10 out of 10 changed files in this pull request and generated 1 comment.

Suppressed comments (3)

src/lib/api/firmwareRepo.ts:35

  • FirmwareVersionSummary.channel is typed as string, which is inconsistent with the FirmwareChannel type used elsewhere and weakens type-safety for consumers.
  channel: string;

src/lib/api/firmwareRepo.ts:22

  • FirmwareRelease.channel is currently typed as string, which loses the stronger guarantee provided by FirmwareChannel and makes it easier for invalid values to leak into the UI. Since this value is expected to be one of the known channels, type it as FirmwareChannel.

This issue also appears on line 35 of the same file.

  channel: string;

src/lib/components/FirmwareChannelSelector.svelte:60

  • In the error path, the selector caches a null entry for the channel. Because the effect treats any defined cache entry (including null) as a hit, the component will never retry fetching for that channel (even after a transient outage) unless the page is reloaded.
      .catch((error) => {
        latestResponse = null;
        version = null;
        cache[currentChannel] = null;
        handleApiError(error);

Comment on lines +95 to +100
async function DownloadBinary(url: string): Promise<Uint8Array> {
const response = await fetch(url);
if (!response.ok)
throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
return await response.bytes();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants