Compare commits

...
6 Commits
Author SHA1 Message Date
千川白浪 24da891365 release: prepare v0.2.15
Release Reims-Go / release (push) Canceled after 0s
Archive the bilingual changelog and synchronize the app and frontend release versions.
2026-12-05 02:23:14 -07:00
千川白浪 e24422176a Merge pull request #193 from Nwflower/ci/workflow-timeouts-and-path-filters
ci: bound job time and skip docs-only pushes
2026-12-05 17:20:48 +08:00
千川白浪 8ea7e3141e Merge pull request #192 from Nwflower/fix/held-input-retry-and-generation
fix(plugin): retry a failed held-input release and keep presses made during it
2026-12-05 17:20:29 +08:00
千川白浪 892d67644b fix(runtime): fall back to Reims-Go releases 2026-12-05 02:19:03 -07:00
千川白浪 875f4df333 ci: bound job time and skip docs-only pushes
A stuck Windows job could hold a runner for the default six hours, so each job now has a timeout: ten minutes for the alpha plan step and thirty for the build jobs.

Pushes and pull requests that only touch documentation, readmes or repository templates no longer start the full verification, which keeps the queue for changes that can break the build.
2026-12-05 02:12:36 -07:00
千川白浪 6501fe2000 fix(plugin): retry a failed held-input release and keep presses made during it
A fallback release that fails while the VM is still running left the record without any retry: its timer had already fired and a plugin that exited never makes the next call, so a modifier stayed pressed in the guest. The record now rearms with a retry timeout, and a VM that stopped while the release was in flight drops the record instead of retrying it.

A release that finishes after the plugin pressed something new lifted that press and then deleted it from the record, so a later fallback no longer knew to lift it. Each record now carries a generation, and a release only clears what it lifted when nothing changed since its snapshot.
2026-12-05 02:07:11 -07:00
12 changed files with 233 additions and 37 deletions

No files matched your search

+1
View File
@@ -24,6 +24,7 @@ concurrency:
jobs:
plan:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
outputs:
+17
View File
@@ -3,8 +3,24 @@ name: CI
on:
push:
branches: [main]
paths-ignore:
- 'docs/**'
- 'README.md'
- 'README.*.md'
- 'AGENTS.md'
- '.github/ISSUE_TEMPLATE/**'
- '.github/PULL_REQUEST_TEMPLATE.md'
- '.github/readme/**'
pull_request:
branches: [main]
paths-ignore:
- 'docs/**'
- 'README.md'
- 'README.*.md'
- 'AGENTS.md'
- '.github/ISSUE_TEMPLATE/**'
- '.github/PULL_REQUEST_TEMPLATE.md'
- '.github/readme/**'
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
@@ -16,6 +32,7 @@ env:
jobs:
verify:
runs-on: windows-latest
timeout-minutes: 30
outputs:
rolling: ${{ steps.rolling.outputs.publish }}
steps:
+1
View File
@@ -17,6 +17,7 @@ env:
jobs:
dev-release:
runs-on: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
+1
View File
@@ -25,6 +25,7 @@ env:
jobs:
release:
runs-on: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
+14
View File
@@ -4,6 +4,20 @@
Client releases are listed newest first. Release notes for portable runtimes (`runtime-*`) are available on [GitHub Releases](https://github.com/Nwflower/Reims-Go/releases).
## v0.2.15 — 2026-12-05
[中文](#cn-v0.2.15) | [English](#en-v0.2.15)
<h3 id="cn-v0.2.15">问题修复</h3>
- 插件退出或长时间不再调用后,宿主替它抬起按住的输入时若释放失败会自动重试,不再让修饰键一直卡在客体里。释放期间插件新按下的键不会被误抬起,也不会从宿主记录中丢失。 — [@Nwflower](https://github.com/Nwflower)
- 主运行时发布仓库无法访问时,自动从 `Nwflower/Reims-Go` 检查可用运行时。 — [@Nwflower](https://github.com/Nwflower)
<h3 id="en-v0.2.15">Bug Fixes</h3>
- When the host lifts input a plugin left held and that release fails, it now retries instead of leaving a modifier stuck in the guest. A key the plugin pressed while a release was in flight is no longer lifted by mistake or dropped from the host's record. — [@Nwflower](https://github.com/Nwflower)
- Check `Nwflower/Reims-Go` for available runtimes when the primary runtime release repository is unavailable. — [@Nwflower](https://github.com/Nwflower)
## v0.2.14 — 2026-12-05
[中文](#cn-v0.2.14) | [English](#en-v0.2.14)
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "reims-go-frontend",
"private": true,
"version": "0.2.14",
"version": "0.2.15",
"type": "module",
"scripts": {
"dev": "vite",
+1 -1
View File
@@ -1 +1 @@
282bb36bb366f28f2448bfe5025195e9
e81d377cfdb873b5f163107395859d09
+95 -23
View File
@@ -15,6 +15,12 @@ import (
// plugin's next call.
var heldInputIdleTimeout = 2 * time.Minute
// heldReleaseRetryTimeout is how long the host waits before trying a fallback
// release again. A release can fail while the VM is still running, for example
// while its console is busy, and a plugin that already exited will never make
// the next call that would otherwise retry it.
var heldReleaseRetryTimeout = 30 * time.Second
// heldReleaseTimeout bounds one fallback release, which runs while the plugin
// that held the input may already be gone.
const heldReleaseTimeout = 5 * time.Second
@@ -29,6 +35,10 @@ type heldInputs struct {
buttons map[string]bool
touched time.Time
timer *time.Timer
// generation counts every change to this record. A release that finishes
// after the plugin pressed something new compares it with the generation it
// snapshotted, so it never deletes a press it did not lift.
generation uint64
}
// noteHeldKey records or forgets one key transition. code must already be a
@@ -77,19 +87,25 @@ func (a *App) heldLocked(pluginID, vmKey string) *heldInputs {
return held
}
// touchHeldLocked drops a record that holds nothing and rearms the idle timer
// of one that still does. The caller holds computerUseHeldMu.
// touchHeldLocked marks the record as changed, drops it when it holds nothing
// and rearms its idle timer otherwise. The caller holds computerUseHeldMu.
func (a *App) touchHeldLocked(pluginID, vmKey string, held *heldInputs) {
held.generation++
held.touched = time.Now()
if held.timer != nil {
held.timer.Stop()
held.timer = nil
}
if len(held.keys)+len(held.buttons) == 0 {
a.pruneHeldLocked(pluginID, vmKey)
return
}
held.timer = time.AfterFunc(heldInputIdleTimeout, func() {
a.armHeldTimerLocked(pluginID, vmKey, held, heldInputIdleTimeout)
}
// armHeldTimerLocked replaces the record's timer with one that fires after d.
// The caller holds computerUseHeldMu.
func (a *App) armHeldTimerLocked(pluginID, vmKey string, held *heldInputs, d time.Duration) {
if held.timer != nil {
held.timer.Stop()
}
held.timer = time.AfterFunc(d, func() {
a.releaseHeldForVM(pluginID, vmKey)
})
}
@@ -113,17 +129,18 @@ func (a *App) pruneHeldLocked(pluginID, vmKey string) {
}
}
// heldState returns what one plugin holds in one VM, sorted.
func (a *App) heldState(pluginID, vmKey string) (keys, buttons []string) {
// heldSnapshot returns what one plugin holds in one VM, sorted, with the
// generation it was read at.
func (a *App) heldSnapshot(pluginID, vmKey string) (keys, buttons []string, generation uint64) {
a.computerUseHeldMu.Lock()
defer a.computerUseHeldMu.Unlock()
byVM := a.computerUseHeld[pluginID]
if byVM == nil {
return nil, nil
return nil, nil, 0
}
held := byVM[vmKey]
if held == nil {
return nil, nil
return nil, nil, 0
}
for code := range held.keys {
keys = append(keys, code)
@@ -133,7 +150,18 @@ func (a *App) heldState(pluginID, vmKey string) (keys, buttons []string) {
}
sort.Strings(keys)
sort.Strings(buttons)
return keys, buttons
return keys, buttons, held.generation
}
// heldGeneration returns the record's current generation, or 0 when there is
// no record.
func (a *App) heldGeneration(pluginID, vmKey string) uint64 {
a.computerUseHeldMu.Lock()
defer a.computerUseHeldMu.Unlock()
if held := a.computerUseHeld[pluginID][vmKey]; held != nil {
return held.generation
}
return 0
}
// heldVMs lists the VMs one plugin currently holds input in.
@@ -147,16 +175,13 @@ func (a *App) heldVMs(pluginID string) map[string]bool {
return out
}
// dropHeld forgets the named keys and buttons of one plugin and VM. It is
// called only after the release reached the guest.
// dropHeld forgets the named keys and buttons of one plugin and VM. It is used
// when the caller itself named what it lifted, so there is no snapshot to
// compare with.
func (a *App) dropHeld(pluginID, vmKey string, keys, buttons []string) {
a.computerUseHeldMu.Lock()
defer a.computerUseHeldMu.Unlock()
byVM := a.computerUseHeld[pluginID]
if byVM == nil {
return
}
held := byVM[vmKey]
held := a.computerUseHeld[pluginID][vmKey]
if held == nil {
return
}
@@ -169,6 +194,42 @@ func (a *App) dropHeld(pluginID, vmKey string, keys, buttons []string) {
a.touchHeldLocked(pluginID, vmKey, held)
}
// dropHeldIfGeneration forgets the named keys and buttons only when the record
// has not changed since generation was read. A record that changed in the
// meantime may hold a press this release did not lift, so it keeps everything
// and its timer releases it later.
func (a *App) dropHeldIfGeneration(pluginID, vmKey string, keys, buttons []string, generation uint64) bool {
a.computerUseHeldMu.Lock()
defer a.computerUseHeldMu.Unlock()
held := a.computerUseHeld[pluginID][vmKey]
if held == nil {
return false
}
if held.generation != generation {
return false
}
for _, code := range keys {
delete(held.keys, code)
}
for _, button := range buttons {
delete(held.buttons, button)
}
a.touchHeldLocked(pluginID, vmKey, held)
return true
}
// rearmHeld schedules another fallback release for a record whose release
// failed while the VM is still running.
func (a *App) rearmHeld(pluginID, vmKey string) {
a.computerUseHeldMu.Lock()
defer a.computerUseHeldMu.Unlock()
held := a.computerUseHeld[pluginID][vmKey]
if held == nil || len(held.keys)+len(held.buttons) == 0 {
return
}
a.armHeldTimerLocked(pluginID, vmKey, held, heldReleaseRetryTimeout)
}
// forgetHeld drops the record of one plugin and VM without touching the
// guest. It is for a VM that is not running: nothing in a powered-off guest
// can still be held, and a release sent later could lift a key the user is
@@ -209,10 +270,10 @@ func (a *App) heldConsoleRoute(vmKey string) (consoleRoute, bool) {
// releaseHeldForVM lifts everything one plugin still holds in one VM. It is the
// fallback for a plugin that can no longer release: its process exited, its
// scope was disposed, or it stopped calling. A VM that is not running has
// nothing held, so its record is dropped instead of retried; a release that
// fails on a running VM keeps its record for the next attempt.
// nothing held, so its record is dropped instead of retried. A release that
// fails while the VM is running keeps its record and is retried.
func (a *App) releaseHeldForVM(pluginID, vmKey string) {
keys, buttons := a.heldState(pluginID, vmKey)
keys, buttons, generation := a.heldSnapshot(pluginID, vmKey)
if len(keys)+len(buttons) == 0 {
a.forgetHeld(pluginID, vmKey)
return
@@ -222,6 +283,12 @@ func (a *App) releaseHeldForVM(pluginID, vmKey string) {
a.forgetHeld(pluginID, vmKey)
return
}
// The plugin may have pressed something since the snapshot; lifting now
// would undo that press, so wait for the record to settle instead.
if a.heldGeneration(pluginID, vmKey) != generation {
a.rearmHeld(pluginID, vmKey)
return
}
ctx, cancel := context.WithTimeout(context.Background(), heldReleaseTimeout)
defer cancel()
if err := a.consoleRelease(ctx, route, keys, buttons); err != nil {
@@ -231,9 +298,14 @@ func (a *App) releaseHeldForVM(pluginID, vmKey string) {
return
}
a.emitLog("plugin", "Could not release input held by "+pluginID+" in "+vmKey+": "+err.Error())
a.rearmHeld(pluginID, vmKey)
return
}
a.dropHeld(pluginID, vmKey, keys, buttons)
if !a.dropHeldIfGeneration(pluginID, vmKey, keys, buttons, generation) {
// Something was pressed while the release was in flight. The record
// keeps it, and its timer lifts it if the plugin goes quiet again.
a.rearmHeld(pluginID, vmKey)
}
}
// releaseHeldForPlugin lifts everything one plugin holds in any VM.
+54 -2
View File
@@ -196,14 +196,14 @@ func TestHeldLedgerTracksAndForgets(t *testing.T) {
app.noteHeldButton("p", vmKey, "left", true)
app.noteHeldKey("p", vmKey, "a", true)
keys, buttons := app.heldState("p", vmKey)
keys, buttons, _ := app.heldSnapshot("p", vmKey)
if len(keys) != 2 || len(buttons) != 1 {
t.Fatalf("held = %v %v", keys, buttons)
}
// Releasing one key keeps the rest.
app.dropHeld("p", vmKey, []string{"a"}, nil)
if keys, _ := app.heldState("p", vmKey); len(keys) != 1 || keys[0] != "meta_l" {
if keys, _, _ := app.heldSnapshot("p", vmKey); len(keys) != 1 || keys[0] != "meta_l" {
t.Fatalf("keys after drop = %v", keys)
}
@@ -221,6 +221,58 @@ func TestHeldLedgerTracksAndForgets(t *testing.T) {
}
}
// TestHeldLedgerKeepsAPressMadeDuringARelease checks that a release which
// finished after the plugin pressed something new does not delete that press
// from the record: the fallback would then no longer know to lift it.
func TestHeldLedgerKeepsAPressMadeDuringARelease(t *testing.T) {
app := &App{}
const vmKey = "driver:vm"
app.noteHeldKey("p", vmKey, "meta_l", true)
keys, buttons, generation := app.heldSnapshot("p", vmKey)
// The plugin presses another key while the release is in flight.
app.noteHeldKey("p", vmKey, "shift", true)
if app.dropHeldIfGeneration("p", vmKey, keys, buttons, generation) {
t.Fatal("a stale release deleted a press it did not lift")
}
if keys, _, _ := app.heldSnapshot("p", vmKey); len(keys) != 2 {
t.Fatalf("keys = %v, want both presses kept", keys)
}
// A release whose snapshot is still current does clear the record.
keys, buttons, generation = app.heldSnapshot("p", vmKey)
if !app.dropHeldIfGeneration("p", vmKey, keys, buttons, generation) {
t.Fatal("a current release was refused")
}
if vms := app.heldVMs("p"); len(vms) != 0 {
t.Fatalf("ledger still holds %v", vms)
}
}
// TestHeldLedgerRetriesAfterTheIdleTimeout checks that a record whose fallback
// release could not run keeps a timer: a plugin that already exited never
// makes the call that would otherwise retry it.
func TestHeldLedgerRetriesAfterTheIdleTimeout(t *testing.T) {
previousIdle, previousRetry := heldInputIdleTimeout, heldReleaseRetryTimeout
heldInputIdleTimeout = time.Hour
heldReleaseRetryTimeout = 20 * time.Millisecond
t.Cleanup(func() { heldInputIdleTimeout, heldReleaseRetryTimeout = previousIdle, previousRetry })
app := &App{}
app.noteHeldKey("p", "driver:vm", "meta_l", true)
app.rearmHeld("p", "driver:vm")
deadline := time.Now().Add(2 * time.Second)
for len(app.heldVMs("p")) > 0 && time.Now().Before(deadline) {
time.Sleep(5 * time.Millisecond)
}
// The VM is not running here, so the retry drops the record instead of
// leaving a key pressed forever.
if vms := app.heldVMs("p"); len(vms) != 0 {
t.Fatalf("the retry left %v behind", vms)
}
}
// TestHeldLedgerReleasesAfterTheIdleTimeout checks that a plugin which stops
// calling mid-hold does not leave the guest stuck: the record carries its own
// timer, and a VM that is not running has nothing left to lift.
+23 -6
View File
@@ -27,11 +27,12 @@ import (
)
const (
DefaultReleasesRepo = "reims-go/reims-vgpu"
DefaultAPIBase = "https://api.github.com"
DefaultWebBase = "https://github.com"
runtimeTagPrefix = "runtime-"
sumsAsset = fetch.SumsAsset
DefaultReleasesRepo = "reims-go/reims-vgpu"
fallbackReleasesRepo = "Nwflower/Reims-Go"
DefaultAPIBase = "https://api.github.com"
DefaultWebBase = "https://github.com"
runtimeTagPrefix = "runtime-"
sumsAsset = fetch.SumsAsset
)
var errRateLimited = errors.New("GitHub API rate limit reached")
@@ -145,8 +146,24 @@ func (s Source) webBase() string {
}
// ListRemote lists published runtime packages, newest first. Alpha runtimes
// are included only when includeAlpha is set.
// are included only when includeAlpha is set. If the default repository cannot
// be listed, it tries the original Reims-Go releases repository.
func (s Source) ListRemote(ctx context.Context, includeAlpha bool) ([]Remote, error) {
list, err := s.listRemote(ctx, includeAlpha)
if err == nil || s.Repo != DefaultReleasesRepo || ctx.Err() != nil {
return list, err
}
fallback := s
fallback.Repo = fallbackReleasesRepo
list, fallbackErr := fallback.listRemote(ctx, includeAlpha)
if fallbackErr != nil {
return nil, fmt.Errorf("%s: %w; %s: %w", s.Repo, err, fallback.Repo, fallbackErr)
}
return list, nil
}
func (s Source) listRemote(ctx context.Context, includeAlpha bool) ([]Remote, error) {
base := strings.TrimRight(s.APIBase, "/")
url := fmt.Sprintf("%s/repos/%s/releases?per_page=100", base, s.Repo)
var rels []ghRelease
+23 -2
View File
@@ -28,7 +28,7 @@ func newFakeGitHub(t *testing.T) *fakeGitHub {
sum := sha256.Sum256(g.archive)
g.sums = hex.EncodeToString(sum[:]) + " reims-runtime-win-x64-abc1234.tar.zst\n"
mux := http.NewServeMux()
mux.HandleFunc("/repos/o/r/releases", func(w http.ResponseWriter, r *http.Request) {
listReleases := func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("User-Agent") != "reims-go" {
t.Errorf("User-Agent = %q", r.Header.Get("User-Agent"))
}
@@ -48,7 +48,9 @@ func newFakeGitHub(t *testing.T) *fakeGitHub {
{"tag_name":"runtime-draft00","draft":true,"assets":[]},
{"tag_name":"v0.1.0","prerelease":false,"assets":[]}
]`, len(g.archive), base, base, base, base, base, base, base, base)
})
}
mux.HandleFunc("/repos/o/r/releases", listReleases)
mux.HandleFunc("/repos/Nwflower/Reims-Go/releases", listReleases)
mux.HandleFunc("/a/archive", func(w http.ResponseWriter, r *http.Request) {
g.hits["archive"]++
if r.Header.Get("Range") != "" {
@@ -78,6 +80,25 @@ func TestDefaultSourceRepository(t *testing.T) {
}
}
func TestListRemoteFallsBackFromUnavailableDefaultRepository(t *testing.T) {
g := newFakeGitHub(t)
src := g.source()
src.Repo = DefaultReleasesRepo // This repository returns 404 in the fixture.
stable, err := src.ListRemote(context.Background(), false)
if err != nil || len(stable) != 1 || stable[0].Commit != "0000old" {
t.Fatalf("fallback stable releases = %+v, err = %v", stable, err)
}
all, err := src.ListRemote(context.Background(), true)
if err != nil || len(all) != 2 || all[0].Commit != "abc1234" {
t.Fatalf("fallback alpha and stable releases = %+v, err = %v", all, err)
}
src.Repo = "example/runtime"
if list, err := src.ListRemote(context.Background(), true); err == nil {
t.Fatalf("custom repository attempted fallback, releases = %+v", list)
}
}
func TestListRemoteFiltersChannelsAndIncompleteReleases(t *testing.T) {
g := newFakeGitHub(t)
stable, err := g.source().ListRemote(context.Background(), false)
+2 -2
View File
@@ -16,8 +16,8 @@ import (
// Version is the current Reims-Go release version. Release builds may override
// it at link time with:
//
// -ldflags "-X github.com/Nwflower/reims-go/internal/version.Version=v0.2.14"
var Version = "v0.2.14"
// -ldflags "-X github.com/Nwflower/reims-go/internal/version.Version=v0.2.15"
var Version = "v0.2.15"
const (
DefaultReleasesRepo = "Nwflower/Reims-Go"