-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(v0.9.2): durable update and receipt-safe output presentation #4859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
44e4c62
6942042
1df323d
c0a02fd
b91a94d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: OpenHarmony | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| paths: | ||
| - '.github/workflows/ohos.yml' | ||
| - 'Cargo.lock' | ||
| - 'Cargo.toml' | ||
| - 'crates/**' | ||
| - 'scripts/ohos/**' | ||
| - 'scripts/ohos-env.sh' | ||
| - 'scripts/release/check-ohos-deps.sh' | ||
| pull_request: | ||
| branches: [main, master] | ||
| paths: | ||
| - '.github/workflows/ohos.yml' | ||
| - 'Cargo.lock' | ||
| - 'Cargo.toml' | ||
| - 'crates/**' | ||
| - 'scripts/ohos/**' | ||
| - 'scripts/ohos-env.sh' | ||
| - 'scripts/release/check-ohos-deps.sh' | ||
| schedule: | ||
| - cron: '47 7 * * 1' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ohos-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| CARGO_INCREMENTAL: 0 | ||
| RUSTFLAGS: -Dwarnings | ||
|
|
||
| jobs: | ||
| cargo-check: | ||
| name: cargo check (aarch64-unknown-linux-ohos) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 45 | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - name: Install Rust target | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: aarch64-unknown-linux-ohos | ||
| - name: Install OpenHarmony native SDK | ||
| id: ohos-sdk | ||
| # Pin the action: it downloads a published OpenHarmony SDK and verifies | ||
| # the archive checksum. This job must never substitute host headers or | ||
| # a stub sysroot and report that as target support. | ||
| uses: openharmony-rs/setup-ohos-sdk@b312caf8a43bb836aa24c08f65f97e1f09a89cad | ||
| with: | ||
| version: '6.1' | ||
| components: native | ||
| cache: true | ||
| mirror: true | ||
| - name: Check Codewhale TUI with the real SDK/sysroot | ||
| shell: bash | ||
| env: | ||
| OHOS_NATIVE_SDK: ${{ steps.ohos-sdk.outputs.ohos_sdk_native }} | ||
| run: | | ||
| set -euo pipefail | ||
| test -x "${OHOS_NATIVE_SDK}/llvm/bin/clang" | ||
| test -d "${OHOS_NATIVE_SDK}/sysroot" | ||
| . ./scripts/ohos-env.sh | ||
| cargo check --target aarch64-unknown-linux-ohos -p codewhale-tui --locked | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2352,7 +2352,7 @@ async fn run_event_loop( | |
| // Fire-and-forget version check — runs once per session in the | ||
| // background. On success, a short status toast advertises the update | ||
| // without replacing the user's configured footer/status-line chips. | ||
| let mut version_check: Option<tokio::task::JoinHandle<Option<String>>> = | ||
| let mut version_check: Option<tokio::task::JoinHandle<Option<UpdateNotice>>> = | ||
| spawn_startup_version_check(config.update_config()); | ||
|
|
||
| // Fire a one-shot initial balance fetch for DeepSeek providers | ||
|
|
@@ -2390,12 +2390,18 @@ async fn run_event_loop( | |
| if let Some(ref handle) = version_check { | ||
| done = handle.is_finished(); | ||
| } | ||
| if done && let Ok(Some(hint)) = version_check.take().unwrap().await { | ||
| if done && let Ok(Some(notice)) = version_check.take().unwrap().await { | ||
| // Transient toast for immediate visibility, plus a durable | ||
| // in-transcript notice so the prompt survives the toast TTL and | ||
| // stays actionable during a busy session (#3961). | ||
| app.push_status_toast( | ||
| hint, | ||
| notice.toast_line(), | ||
| StatusToastLevel::Info, | ||
| Some(VERSION_HINT_TOAST_TTL_MS), | ||
| ); | ||
| app.add_message(HistoryCell::System { | ||
| content: notice.notice_block(), | ||
| }); | ||
| } | ||
|
|
||
| if !drain_web_config_events(&mut web_config_session, app, config, &engine_handle).await { | ||
|
|
@@ -16167,7 +16173,7 @@ fn startup_version_check_source(config: &UpdateConfig) -> StartupVersionCheckSou | |
|
|
||
| fn spawn_startup_version_check( | ||
| config: UpdateConfig, | ||
| ) -> Option<tokio::task::JoinHandle<Option<String>>> { | ||
| ) -> Option<tokio::task::JoinHandle<Option<UpdateNotice>>> { | ||
| let source = startup_version_check_source(&config); | ||
| if source == StartupVersionCheckSource::Disabled { | ||
| return None; | ||
|
|
@@ -16182,7 +16188,7 @@ fn spawn_startup_version_check( | |
| async fn version_hint_from_startup_source( | ||
| source: StartupVersionCheckSource, | ||
| current: &str, | ||
| ) -> Option<String> { | ||
| ) -> Option<UpdateNotice> { | ||
| match source { | ||
| StartupVersionCheckSource::Disabled => None, | ||
| StartupVersionCheckSource::ConfiguredUrl(url) => { | ||
|
|
@@ -16208,7 +16214,7 @@ async fn version_hint_from_startup_source( | |
| } | ||
| } | ||
|
|
||
| async fn version_hint_from_release_mirror_env(current: &str) -> Option<String> { | ||
| async fn version_hint_from_release_mirror_env(current: &str) -> Option<UpdateNotice> { | ||
| if !release_mirror_env_configured() { | ||
| return None; | ||
| } | ||
|
|
@@ -16228,7 +16234,7 @@ fn release_mirror_env_configured() -> bool { | |
| async fn version_hint_from_configured_update_uri( | ||
| update_uri: &str, | ||
| current: &str, | ||
| ) -> Result<Option<String>> { | ||
| ) -> Result<Option<UpdateNotice>> { | ||
| let body = codewhale_release::fetch_release_json_async(update_uri, "configured latest release") | ||
| .await?; | ||
| let json: serde_json::Value = serde_json::from_str(&body).with_context(|| { | ||
|
|
@@ -16237,7 +16243,7 @@ async fn version_hint_from_configured_update_uri( | |
| Ok(version_hint_from_custom_release_json(&json, current)) | ||
| } | ||
|
|
||
| fn version_hint_from_release_json(json: &serde_json::Value, current: &str) -> Option<String> { | ||
| fn version_hint_from_release_json(json: &serde_json::Value, current: &str) -> Option<UpdateNotice> { | ||
| if !release_has_required_assets(json) { | ||
| return None; | ||
| } | ||
|
|
@@ -16249,7 +16255,7 @@ fn version_hint_from_release_json(json: &serde_json::Value, current: &str) -> Op | |
| fn version_hint_from_custom_release_json( | ||
| json: &serde_json::Value, | ||
| current: &str, | ||
| ) -> Option<String> { | ||
| ) -> Option<UpdateNotice> { | ||
| if !release_is_publishable(json) { | ||
| return None; | ||
| } | ||
|
|
@@ -16260,15 +16266,47 @@ fn version_hint_from_custom_release_json( | |
| version_hint_from_latest_tag(tag, current) | ||
| } | ||
|
|
||
| fn version_hint_from_latest_tag(tag: &str, current: &str) -> Option<String> { | ||
| /// A newer-stable-release notice, carrying enough context to render both the | ||
| /// short transient toast and the durable in-transcript update prompt (#3961). | ||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| struct UpdateNotice { | ||
| current: String, | ||
| latest: String, | ||
| } | ||
|
|
||
| impl UpdateNotice { | ||
| /// Short line for the transient status toast (unchanged wording). | ||
| fn toast_line(&self) -> String { | ||
| format!( | ||
| "v{latest} available - run `codewhale update` and restart", | ||
| latest = self.latest | ||
| ) | ||
| } | ||
|
|
||
| /// Durable, actionable notice pushed into the transcript so it survives the | ||
| /// toast TTL. Includes current/latest versions, release notes, the exact | ||
| /// update command, and restart guidance. | ||
| fn notice_block(&self) -> String { | ||
| format!( | ||
| "Update available: v{current} -> v{latest}\n\ | ||
| Release notes: https://github.com/Hmbown/CodeWhale/releases/tag/v{latest}\n\ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: the "Release notes" link is hardcoded to Consider omitting the release-notes line (or making it conditional/generic) when the notice originates from a mirror/custom-URI source, since |
||
| Run `codewhale update` (preview with `codewhale update --check`), then restart CodeWhale.", | ||
| current = self.current, | ||
| latest = self.latest | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| fn version_hint_from_latest_tag(tag: &str, current: &str) -> Option<UpdateNotice> { | ||
| let latest = tag.trim_start_matches('v'); | ||
| if !is_newer_version(latest, current) { | ||
| return None; | ||
| } | ||
|
|
||
| Some(format!( | ||
| "v{latest} available - run `codewhale update` and restart, then /change for what's new" | ||
| )) | ||
| Some(UpdateNotice { | ||
| current: current.to_string(), | ||
| latest: latest.to_string(), | ||
| }) | ||
| } | ||
|
|
||
| fn release_has_required_assets(json: &serde_json::Value) -> bool { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug:
RUSTFLAGS: -Dwarningsis set job-wide (line 38), butscripts/ohos-env.sh(sourced here) exportsCARGO_ENCODED_RUSTFLAGSfor the target-specific linker flags. Cargo's rustflags sources are mutually exclusive withCARGO_ENCODED_RUSTFLAGStaking priority overRUSTFLAGS— it does not merge them. So for this job'scargo check(line 71),-Dwarningsis silently dropped and warnings won't fail the build, even though the job is meant to be "a real tier-2 check."This directly undercuts the PR's own stated principle for this doc/CI addition (
docs/HarmonyOS.md: "fails if the SDK, Clang, or sysroot is unavailable rather than substituting host headers ... that could report false success") — the check can currently pass with warnings present.Fix: append
-Dwarningsinto theCARGO_ENCODED_RUSTFLAGSvalue built inscripts/ohos-env.sh(joined with the\037separator already used there) instead of relying on the job-levelRUSTFLAGSenv var.[Fix this →](https://claude.ai/code?q=In%20scripts%2Fohos-env.sh%2C%20the%20script%20exports%20CARGO_ENCODED_RUSTFLAGS%20for%20the%20aarch64-unknown-linux-ohos%20target%2C%20which%20takes%20priority%20over%20and%20silently%20discards%20the%20job-level%20RUSTFLAGS%3D-Dwarnings%20set%20in%20.github%2Fworkflows%2Fohos.yml.%20This%20means%20the%20OpenHarmony%20CI%20check%20does%20not%20actually%20deny%20warnings.%20Fix%20by%20appending%20-Dwarnings%20(joined%20with%20the%20existing%20%5Cx1f%20separator)%20into%20the%20CARGO_ENCODED_RUSTFLAGS%20value%20constructed%20in%20ohos-env.sh%2C%20so%20warn-as-error%20is%20preserved%20for%20the%20OpenHarmony%20cross-check.&repo=Hmbown/CodeWhale