diff --git a/Makefile b/Makefile index f302afac6..b3c56edd0 100644 --- a/Makefile +++ b/Makefile @@ -283,7 +283,7 @@ core/bindings/index.ts: $(call ls-files, core) $(ENVIRONMENT_FILE) rm -rf core/bindings ./core/build/build-ts.sh ls core/bindings/*.ts | sed 's/core\/bindings\/\([^.]*\)\.ts/export { \1 } from ".\/\1";/g' | grep -v '"./index"' | tee core/bindings/index.ts - npm --prefix sdk/base exec -- prettier --config=./sdk/base/package.json -w ./core/bindings/*.ts + npm --prefix sdk/base exec -- prettier --config=./sdk/base/package.json -w './core/bindings/**/*.ts' touch core/bindings/index.ts sdk/dist/package.json sdk/baseDist/package.json: $(call ls-files, sdk) sdk/base/lib/osBindings/index.ts diff --git a/docs/TODO.md b/docs/TODO.md index 1bd166d88..62d80fdfe 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -23,19 +23,14 @@ Pending tasks for AI agents. Remove items when completed. other crate types. Extracting them requires either moving the type definitions into the sub-crate (and importing them back into `start-os`) or restructuring to share a common types crate. -- [ ] Use auto-generated RPC types in the frontend instead of manual duplicates +- [ ] Make `SetupExecuteParams.password` optional in the backend - @dr-bonez - **Problem**: The web frontend manually defines ~755 lines of API request/response types in - `web/projects/ui/src/app/services/api/api.types.ts` that can drift from the actual Rust types. + **Problem**: In `core/src/setup.rs`, `SetupExecuteParams` has `password: EncryptedWire` (non-nullable), + but the frontend needs to send `null` for restore/transfer flows where the user keeps their existing + password. The `AttachParams` type correctly uses `Option` for this purpose. - **Current state**: The Rust backend already has `#[ts(export)]` on RPC param types (e.g. - `AddTunnelParams`, `SetWifiEnabledParams`, `LoginParams`), and they are generated into - `core/bindings/`. However, commit `71b83245b` ("Chore/unexport api ts #2585", April 2024) - deliberately stopped building them into the SDK and had the frontend maintain its own types. - - **Goal**: Reverse that decision — pipe the generated RPC types through the SDK into the frontend - so `api.types.ts` can import them instead of duplicating them. This eliminates drift between - backend and frontend API contracts. + **Fix**: Change `password: EncryptedWire` to `password: Option` in `SetupExecuteParams` + and handle the `None` case in the `execute` handler (similar to how `attach` handles it). - [ ] Auto-configure port forwards via UPnP/NAT-PMP/PCP - @dr-bonez diff --git a/sdk/base/lib/osBindings/AttachParams.ts b/sdk/base/lib/osBindings/AttachParams.ts index 31283fec6..9b3d87422 100644 --- a/sdk/base/lib/osBindings/AttachParams.ts +++ b/sdk/base/lib/osBindings/AttachParams.ts @@ -5,4 +5,5 @@ export type AttachParams = { password: EncryptedWire | null guid: string kiosk?: boolean + hostname: string | null } diff --git a/sdk/base/lib/osBindings/SetServerHostnameParams.ts b/sdk/base/lib/osBindings/SetServerHostnameParams.ts new file mode 100644 index 000000000..df42a6445 --- /dev/null +++ b/sdk/base/lib/osBindings/SetServerHostnameParams.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type SetServerHostnameParams = { hostname: string } diff --git a/sdk/base/lib/osBindings/SetupExecuteParams.ts b/sdk/base/lib/osBindings/SetupExecuteParams.ts index 0df094f0b..330390060 100644 --- a/sdk/base/lib/osBindings/SetupExecuteParams.ts +++ b/sdk/base/lib/osBindings/SetupExecuteParams.ts @@ -7,4 +7,5 @@ export type SetupExecuteParams = { password: EncryptedWire recoverySource: RecoverySource | null kiosk?: boolean + hostname: string | null } diff --git a/sdk/base/lib/osBindings/index.ts b/sdk/base/lib/osBindings/index.ts index 74e59e2b3..517bf57f8 100644 --- a/sdk/base/lib/osBindings/index.ts +++ b/sdk/base/lib/osBindings/index.ts @@ -257,6 +257,7 @@ export { SetMainStatusStatus } from './SetMainStatusStatus' export { SetMainStatus } from './SetMainStatus' export { SetNameParams } from './SetNameParams' export { SetOutboundGatewayParams } from './SetOutboundGatewayParams' +export { SetServerHostnameParams } from './SetServerHostnameParams' export { SetStaticDnsParams } from './SetStaticDnsParams' export { SetupExecuteParams } from './SetupExecuteParams' export { SetupInfo } from './SetupInfo' diff --git a/web/projects/setup-wizard/src/app/app.component.ts b/web/projects/setup-wizard/src/app/app.component.ts index b6bf0b3e5..1f9b84705 100644 --- a/web/projects/setup-wizard/src/app/app.component.ts +++ b/web/projects/setup-wizard/src/app/app.component.ts @@ -31,23 +31,15 @@ export class AppComponent { switch (status.status) { case 'needs-install': - // Restore keyboard from status if it was previously set - if (status.keyboard) { - this.stateService.keyboard = status.keyboard.layout - } - // Start the install flow await this.router.navigate(['/language']) break case 'incomplete': // Store the data drive info from status - this.stateService.dataDriveGuid = status.guid - this.stateService.attach = status.attach - // Restore keyboard from status if it was previously set - if (status.keyboard) { - this.stateService.keyboard = status.keyboard.layout + if (status.guid) { + this.stateService.dataDriveGuid = status.guid } - + this.stateService.attach = status.attach await this.router.navigate(['/language']) break diff --git a/web/projects/setup-wizard/src/app/pages/password.page.ts b/web/projects/setup-wizard/src/app/pages/password.page.ts index adef97f3a..fb3f4f39e 100644 --- a/web/projects/setup-wizard/src/app/pages/password.page.ts +++ b/web/projects/setup-wizard/src/app/pages/password.page.ts @@ -8,11 +8,17 @@ import { ReactiveFormsModule, Validators, } from '@angular/forms' -import { ErrorService, i18nPipe, LoadingService } from '@start9labs/shared' +import { + ErrorService, + generateHostname, + i18nPipe, + LoadingService, +} from '@start9labs/shared' import { TuiAutoFocus, TuiMapperPipe, TuiValidator } from '@taiga-ui/cdk' import { TuiButton, TuiError, + TuiHint, TuiIcon, TuiTextfield, TuiTitle, @@ -20,6 +26,7 @@ import { import { TuiFieldErrorPipe, TuiPassword, + TuiTooltip, tuiValidationErrorsProvider, } from '@taiga-ui/kit' import { TuiCardLarge, TuiHeader } from '@taiga-ui/layout' @@ -31,31 +38,49 @@ import { StateService } from '../services/state.service'

{{ - isRequired - ? ('Set Master Password' | i18n) + isFresh + ? ('Set Up Your Server' | i18n) : ('Set New Password (Optional)' | i18n) }} - - {{ - isRequired - ? ('Make it good. Write it down.' | i18n) - : ('Skip to keep your existing password.' | i18n) - }} -

- + @if (isFresh) { + + + + .local + + + + + } + + @@ -87,14 +112,14 @@ import { StateService } from '../services/state.service' - @if (!isRequired) { + @if (!isFresh) { } + @if (error) { +

{{ error }}

+ }