Commit Graph
23 Commits
Author SHA1 Message Date
Yudong Hanandimccyu f7cb4926dc feat(frame-forwarding): video-frame forwarding support (#8440)
* fix(desktop): hide the Windows menu entries while the document is fullscreen

Frame forwarding offers plugins the Fullscreen API; the Application and Edit caption entries now stay hidden during fullscreen and return when it ends.

* feat(desktop): build declared native addons for development and packaging

* feat(frame-forwarding): receive native frames and submit them to the Desktop sink

* feat(frame-forwarding): route Host channels to video mounts in the Client

Keep the producer interface internal while Office integration evolves. Include channel lifecycle, receiver integration and video presentation tests.

Co-authored-by: imccyu <276526105+imccyu@users.noreply.github.com>

* test(frame-forwarding): cover wire packet and endpoint parsing with fuzz tests

* refactor(desktop): preinstall the native frame receiver

* build(desktop): compile the preinstalled receiver from the plugin workspace

* refactor(frame-forwarding): load the preinstalled receiver inside the plugin

* refactor(desktop): pass the frame receiver path as a Host argument

---------

Co-authored-by: imccyu <276526105+imccyu@users.noreply.github.com>
2026-11-27 06:39:04 +00:00
Yudong Hanandimccyu 5cff6056ba feat(desktop): add shared texture interface and transport (#8439)
* feat(desktop): add shared texture transport and native presentation layers

* fix(desktop): keep split fixtures and generated notices self-contained

* refactor(theme): defer presentation stage token to Office layer

* refactor(desktop): move frame integration into its consumer layer

* refactor(sidebar-right): move native-layer visibility support to frame layer

The fullscreen tab-body background and the tab visibility test only serve
the frame integration that hides native layers through tab.visible, so they
belong with that consumer layer.

* refactor(desktop): keep shared textures on the renderer path

* fix(desktop): settle shared textures across GPU loss and teardown

* fix(desktop): correlate late texture arrivals and settlements by request

* test(desktop): exercise late ingress delivery after presenter reset

* fix(desktop): bound unsettled textures before handle export

* fix(desktop): retain probe handles and invalidate unsynchronized imports

* refactor(desktop): leave the fullscreen caption rule to frame forwarding

The caption-menu fullscreen rule, its test, and the README sentences describe fullscreen that frame forwarding offers to plugins. They belong with frame forwarding, not the texture transport.

* refactor(desktop): validate Host texture limits in the channel only

The Host channel already shortens deadlines to 30 seconds and refuses dimensions above 8192 before Main's presenter sees a request, and it is the presenter's only caller. Remove the repeated checks from the presenter and assert the limits where they are enforced.

* fix(desktop): drop only the surface that finds the ingress queue full

A full delivery queue ended the macOS ingress reader, so a Main JavaScript thread that stalled for 16 surfaces failed every waiting presentation and left the Host without an endpoint until its next capability query. Release that one surface and keep reading; its presentation fails at the delivery deadline. A closing delivery function still ends the reader.

* fix(desktop): reach Main through one process handle for Windows texture handles

The Windows adapter opened Main by process identifier for every export, import, and reclamation. After Main exited, the Host's disconnect cleanup reclaimed each unsettled handle with DUPLICATE_CLOSE_SOURCE, which closes the source handle even when the call fails; an identifier reassigned by then named an unrelated process. Keep one handle to Main's process until the endpoint closes, refuse to reclaim without it, and leave duplicates to Main's exit after a disconnect.

* feat(desktop): carry shared-texture frames on a native Host-Main channel

Each frame was a Node IPC request from the Host's JavaScript thread, answered by a reply and a later notification on the same channel, with the macOS surface sent separately and paired in Main by token, and the Windows handle duplicated into Main by the Host through Koffi.

The hop and ingress addons now form a two-way native channel on both platforms: a Mach port pair on macOS and a duplex message pipe on Windows. A frame's handle and description reach Main in one message, and Main returns the delivery reply and the settlement on the same channel. On Windows, Main verifies the pipe client's process and duplicates the Host's handle into its own process, so the Host opens no process and closes no remote handle. The Host IPC channel keeps only the capability and probe controls.

A frame that finds Main's 32-frame delivery queue full is refused at once and stays reusable. When the channel is lost, the hop settles every unsettled frame as invalidated. The hop also exposes its connection to other Host addons as a C function table, which the sharedTexture claim returns from nativeSink, so a native producer can submit frames without the Host's JavaScript event loop.

* refactor(desktop): drop unused parts of the shared-texture ingress

Main never closed a handle inside the Host, never read a frame's delivery deadline, and waited for the Host's pipe connection only to cover the instant before the ingress registers it. Remove reclaimFromPeer, the timeoutMs field of the frame event, and the peer event with the probe's wait for it: a probe that arrives in that instant now fails with the export error.

With frames as the only queued deliveries, the delivery function's own queue limit bounds them again.

* refactor(desktop): submit shared-texture frames through the native sink only

The Host had two entries for submitting a frame: the hop's JavaScript present, wrapped as SharedTextureService.present with promises fed by per-frame events, and the C sink for native addons. Frame forwarding, the only consumer, submits through the sink.

Remove the JavaScript entry: the hop's present function and its delivered and settled events, the service's present with its frame, presented, and settlement types, and the wrapper's request table. The hop reports only the loss of a connection to JavaScript. The sink ABI and the wire format are unchanged.

* feat(desktop): tell a refused shared-texture frame from a lost connection

Every sink refusal returned 1, so a native consumer could not tell whether to keep its sink or replace it: a frame refused at the 128-request limit and a present after Main disappeared looked the same.

present now returns DSH_SHARED_TEXTURE_PRESENT_OK (0) when the request left the Host, DSH_SHARED_TEXTURE_PRESENT_REJECTED (1) when only that frame was refused (invalid arguments or fields, the request limit, an identifier in use, or a failed send on a live connection), and DSH_SHARED_TEXTURE_PRESENT_DISCONNECTED (2) when the connection was closed or lost, including a send that found Main gone before the reader did. A sent request still returns 0 and settles through the reader when the connection ends during its send.

* refactor(desktop)!: drop frame identifiers and the wire deadline from shared-texture presentation

Each frame carried a Host-chosen identifier that the hop and Main both kept unique among unsettled frames, and a delivery deadline that Main never read. Frame forwarding tracks its own deliveries, so the identifiers only cost a string copy, a set lookup on each side, and an extra refusal reason.

The sink ABI becomes version 2: dsh_shared_texture_frame_v2 drops id and id_len, and a consumer built for version 1 refuses the version 2 sink. DSTX becomes version 3: its present header drops timeout_ms and id_length and is followed by the metadata alone, and both sides refuse other versions and nonzero reserved fields. The hop still enforces each request's delivery deadline locally and still admits at most 128 unsettled requests; Main bounds admitted frames with a count instead of an identifier set.

The native e2e labels frames through their metadata, proves that a timed-out request keeps its slot through the request limit, and forges version 2 and malformed version 3 headers.

* refactor(desktop)!: read the Windows compositor adapter in Main

To learn which adapter Chromium's compositor renders on, the Host asked Main for a probe texture, Main duplicated it into the Host and kept its own handle and hidden window until the Host released the probe, and the Host closed its duplicate after reading the adapter. The exchange needed the native connection to be open first, a probe table and late-reply cleanup on both sides, and two handle-transfer operations that nothing else used.

Main now reads the adapter itself: the ingress addon reports the LUID of a Main-local shared texture through DXGI, formatted as "<HighPart>:<LowPart>" in unpadded lowercase hexadecimal, the text Host addons derive from an adapter LUID. Main exports one compositor texture, reads its adapter, and releases the texture and its window at once. The answer is kept for the GPU process generation, which a GPU process exit or Host teardown advances; concurrent queries share one probe, a probe that finds nothing or fails is not kept, a cleanup cancels a pending probe, and a probe that a GPU process exit overtook records nothing.

SharedTextureService.probe becomes adapterLuid(timeoutMs), which resolves to that text or null, returns null outside Windows without asking Main, rejects when Desktop does not present shared textures, and no longer opens the native connection. The Host control requests are capabilities and adapter-luid; the probe and release-probe requests, the ingress exportToPeer, and the hop closeHandle are removed.

* perf(desktop): block the macOS shared-texture ingress reader until a request or stop

The macOS ingress reader woke every 100 ms to check for a stop request, so an idle Desktop woke the reader ten times a second and a close waited for the next wake-up.

The reader now waits without a timeout. stop sets the flag and then sends an empty message to the ingress port through the send right Main already holds; a full queue already wakes the reader, so a wake-up that does not fit is dropped. Once stopped, the reader destroys whatever it receives, including its own wake-up, and Host requests still pass the audit-token check unchanged.

* perf(desktop): trim per-frame work on the shared-texture path

Every frame repeated work that only the first frame of a connection or no frame needs. On macOS each request carried a new send right to the Host's reply port, which Main merged and deallocated under a lock; the hop allocated and cleared a 4 KB message per request and the ingress cleared its whole receive buffer per message; the hop copied each frame's metadata into a string, and the Windows hop allocated a message vector; Main parsed every frame's metadata as JSON only to have Electron serialize the value again; and the product preload imported textures that no consumer would read.

The first request of a macOS connection that reaches Main carries the reply port, and Main keeps it for that connection. Main drops the right when a reply cannot be delivered, as the Windows ingress disconnects the pipe, and the hop then receives a no-senders notification and settles every request as invalidated; Main discards requests that arrive on the dropped connection, and the endpoint serves the Host's next connection. Sends reuse a buffer per connection under the send lock and clear only the header fields and alignment padding, the ingress clears only the fixed message fields, and the hop passes metadata to the transport as a view of the caller's bytes.

Main forwards the metadata text, and the product preload parses it before importing the texture. A transfer with metadata that is not JSON, or one that arrives while no consumer is registered, is refused before import, so the Host sees a failed delivery and a released settlement once Main drops its own reference.

* fix(desktop): never import a handle from a closed Windows shared-texture connection

A Windows request names its texture only by a handle value inside the Host, and Main duplicates it when its reader reaches the request. When the Host closed a connection itself, it settled every unsettled request as invalidated right after closing its pipe end, and the owner could then close the handle. A request still queued in the pipe stays readable after that close, so Main could duplicate a value that already named another object and present that texture as the settled frame.

After duplicating, Main now checks that the Host's end of the pipe is still connected. The Host closes its end before it reports any settlement, so a duplicate taken while the end is open names the texture the request was sent with. Otherwise Main closes the duplicate and ends the connection, which discards the requests still queued; the endpoint then serves the Host's next connection. macOS needs no check because each request carries the IOSurface port itself.

A Windows e2e suspends Main, presents a frame, closes the connection, and replaces the texture with one that takes over its handle value before resuming Main. Without the check Main delivered that frame with the replacement texture; with it Main delivers only the frames of open connections.

* chore(desktop): state how long an ingress reply can block, and end a build script with a newline

SharedTextureIngress.reply described a non-blocking queue, but it writes the reply on the calling thread and waits up to the 100 ms reply timeout while the Host is not reading. The comment now says so, together with the connection drop that follows a reply that cannot be written in time.

native-package-builds.mjs ended without a newline.

* fix(desktop): accept every enabled GPU compositing status in the adapter probe

The probe required gpu_compositing to be exactly 'enabled', while support() accepts any 'enabled*' status, so adapterLuid returned null where capabilities reported support. Also type the e2e frame tuple to satisfy no-unsafe-return.

* chore(desktop): end native-package-builds.d.mts with a newline

* refactor(desktop)!: provide shared textures through the dsh-shared-texture plugin

Desktop Host imported its shared-texture types from the private Electron application package, frame forwarding publishes declarations that referenced it, so an installed consumer could not resolve them, and renderer plugins read the texture bridge from globalThis.dshDesktop.

@deepseek-ai/dsh-shared-texture (packages/shared-texture/shared-texture) is a Host and Client plugin package that owns the contract:

- its Host root exports the abstract Cordis service SharedTexture, registered as ctx.sharedTexture and declaring only claim(), with the claim, capability, and native-sink types; its apply does nothing, because the Loader mounts the package only to deliver the Client half;
- ./client is the Client plugin: where Desktop's product preload exposes dshDesktop.textures, it provides that bridge as the Client ctx.sharedTexture, typed SharedTextureBridge, and otherwise provides nothing;
- ./bridge carries the type-only renderer SharedTextureBridge and SharedTextureLease;
- ./protocol carries the type-only private control protocol between Desktop Main and the Desktop Host, including the hop addon types; it is not a plugin API.

web-app mounts the package, so plugins inject ctx.sharedTexture instead of reading host globals. Desktop Host's SharedTexture extends the abstract Host service. Desktop Main and the Desktop Host take the low-frequency control message types from ./protocol and each still validates every message it receives at runtime, so Desktop Host no longer depends on Desktop. Desktop drops its ./shared-texture/host, ./shared-texture/client, and ./shared-texture/internal exports. The shared-texture subsystem page describes the entry points, and the capability-seam graph lists the service.

* refactor(desktop): keep the shared-texture protocol in Desktop Host

Main and the Desktop Host now share the child-process message types from
`apps/desktop-host/src/types.ts`, imported as `@deepseek-ai/dsh-desktop-host/types`,
so the published package no longer carries a private protocol subpath. The hop
addon interfaces return to the Host module that is their only user.

The renderer vocabulary keeps one Cordis-free module, renamed from `bridge` to
`types`: `SharedTextureClientExport`, `SharedTextureHostExport`, and
`SharedTextureLease`, imported by preload and IPC modules from
`@deepseek-ai/dsh-shared-texture/types`. The module is required because the two
compiler faces declare `ctx.sharedTexture` with different types: one program
holding `src/index.ts` and `src/client/index.ts` fails with TS2717.

---------

Co-authored-by: imccyu <276526105+imccyu@users.noreply.github.com>
2026-11-27 02:15:04 +08:00
Turtleandimccyu c0399fb981 fix(desktop): keep development Harness state out of .desktop-build
pnpm run clean removes apps/desktop/.desktop-build, which held the
development Harness home and Electron user data, so cleaning deleted
development Sessions, settings and credentials. Store them under
apps/desktop/.desktop-dev and move existing state there on launch.

Fixes #8658

Co-authored-by: imccyu <276526105+imccyu@users.noreply.github.com>
2026-11-17 19:15:02 +08:00
imccyu f6b0c5af59 build: rename build:src and build:test to build:artifacts and build:check
build:artifacts produces every artifact, including the tsdown bundles,
the Desktop bundle, and Web, so naming it after sources undersold it;
build:check checks scripts, benchmarks, and website code besides tests.
The build.ts scopes, aggregate step ids, the Python builder flag
(--build-artifacts), workflows, callers, docs, and the build-split Agent
Note follow the new names. The note also records the naming
alternatives.

Refs #5852
2026-10-11 22:16:47 +08:00
imccyu 129c915498 build: split build:src and build:test, and schedule build in parallel
pnpm run build ran every step in one serial chain, including the two
noEmit aggregate programs (tests, scripts, benchmarks, website) that no
artifact step consumes, so the Host aggregate check alone delayed tsdown by
about 66 s.

- build:src (scripts/build.ts --scope src) builds every artifact in the
  existing order and writes the client build record; it replaces the
  removed --artifacts-only flag and the libraries CLI mode.
- build:test (--scope test) type-checks only the Host and Client aggregate
  programs with tsc -p, concurrently, without compiling references or
  checking prerequisites.
- build runs both as one dependency graph through run-gates' new
  runAggregate: each aggregate check starts once its face's packages are
  compiled, and Client compilation stays after the Host bundle that writes
  the Typert /remote declarations. DSH_GATE_CONCURRENCY=1 serializes it;
  DSH_GATE_FAIL_FAST=1 stops the remaining steps at the first failure.
  Passing steps print one PASS line (DSH_GATE_VERBOSE=1 shows their output).
- PR artifact builds (e2e, release, preview, Node 22 compatibility) and the
  Python builder (--build-src) use build:src; dev:web and dev:desktop use
  build:src. test:*, bench, typecheck and the required consumer/Windows
  lanes keep the complete build.
- lint, lint:fix, doc-typecheck and the Typert contracts gate prepare with
  host-libraries (Host package compilation + Host bundle) instead of
  build:lib:host; their own checks never read the aggregate root or the
  Desktop bundle.

Parallel and serial build produce byte-identical lib/, Web dist and client
build record; a test-only type error fails build and build:test while
build:src passes.

Refs #5852
2026-10-11 18:19:23 +08:00
Xinyu Yang 4b03fefec1 Merge origin/master into feat/shortcuts-rework 2026-09-23 22:10:54 +08:00
mektpoy 80e4da0e3d fix(desktop): take the development project target as an explicit input
`prepareDevelopmentProject()` resolved the build target from the host
platform and architecture, so a Linux host threw `unsupported target
linux-x64` while writing the runtime descriptor. Pass the target in
instead: the launcher supplies the target it prepared, and isolated tests
supply a fixed supported target.

Extract `desktopTargetPlatform()` into desktop-build-paths.mjs so the
target-to-payload mapping has one home, and use it for the qualification
runner, which previously derived both its target directory and its
descriptor from the host architecture.

Correct the README limitation to name the module that now performs the
architecture check.
2026-09-23 16:03:17 +08:00
Xinyu Yang 91423ea1b4 revert: restore configurable Web and desktop shortcuts
Restore the feature removed by #4886 on current master. Preserve the current settings entry point, moving-menu behavior, and desktop update UI.
2026-09-22 21:02:32 +08:00
mektpoy 5925925d20 Merge remote-tracking branch 'origin/master' into fix/desktop-dev-runtime-target
# Conflicts:
#	apps/desktop/src/main.ts
2026-09-22 20:30:25 +08:00
Turtle 2c95550e87 Revert "feat(shortcuts): add configurable Web and desktop shortcuts" 2026-09-22 11:04:01 +08:00
Xinyu Yangand神河一号 - 烈焰流光 efdf8e5b6d feat(shortcuts): add configurable Web and desktop shortcuts
Add the keyboard registry, device-local preferences, and searchable shortcut editor. Support Web routing and native Desktop single-key and two-key bindings.

Co-authored-by: 神河一号 - 烈焰流光 <1115886391@qq.com>
2026-09-21 23:57:28 +08:00
mektpoy a2487e34b7 fix(desktop): lock the development runtime target and complete the resolution
- main-startup: assert primaryRuntime for the unpackaged Host and cover a
  missing DSH_DESKTOP_PRIMARY_RUNTIME_DIR as a fatal startup dialog with no
  Host started.
- test-workspace-updates: pass the prepared primary-runtime directory instead
  of an application/runtime path the runner never creates.
- development-project: derive the descriptor platform/arch from
  resolveDesktopBuildTarget so it matches the prepared payload.
- main: resolve the unpackaged primary runtime once at startup instead of
  inside the Host factory.
- dev: keep the environment override symmetric with its neighbours.
- README: document the variable as required for unpackaged launches and record
  the remaining win32-arm64 payload architecture limitation.
2026-09-21 11:53:32 +08:00
mektpoy 3515c48a37 fix(desktop): resolve the development runtime directory from the build target
The unpackaged shell derived the primary-runtime directory from process.arch, while preparePrimaryRuntime() resolves the target through resolveDesktopBuildTarget(), which fixes Windows to x64. On a Windows ARM64 host the shell looked under targets/win-arm64 while the payload was under targets/win-x64, and the missing office-skills/scripts/check_office.py became a fatal startup dialog.

The launcher now resolves that directory through the same resolver and passes it to the shell as DSH_DESKTOP_PRIMARY_RUNTIME_DIR.
2026-09-20 15:37:38 +08:00
lsdsjy 52d5ecd7c6 fix(desktop): update welcome copy and remove forced preview 2026-09-20 11:31:41 +08:00
lsdsjy 5b7195e032 feat(desktop,credentials,client): update sign-in protocol and Platform experience 2026-09-20 11:31:40 +08:00
lsdsjy 048297321a feat(desktop,credentials,client): integrate DeepSeek account sign-in and Platform pages 2026-09-20 11:31:40 +08:00
lsdsjy 753eff67b1 feat(desktop,client): add the native welcome window 2026-09-20 11:31:27 +08:00
07akioni f4b7a5948c fix(desktop): support Node 26 runtime archive extraction 2026-09-15 19:44:59 +08:00
07akioni 0c88492646 feat(desktop): bundle release-bound workspace runtimes 2026-09-14 18:09:22 +08:00
07akioni bebf88de4f Use Electron Node runtime and replace Windows installations by directory 2026-09-11 15:52:05 +08:00
07akioni d09b4accd3 feat: 打包 + 错误处理优化 2026-09-09 21:10:02 +08:00
07akioni fe0b7f2814 fix(desktop): move host out of CLI package 2026-09-04 16:21:45 +08:00
07akioni 19444907f0 feat: electron 打包 2026-08-31 11:54:28 +08:00