Repository navigation
refactor(platform): separate layout, host capabilities and native adapters - #289
shihuili1218 wants to merge 1 commit into
Conversation
…pters Keep the shared platform improvements independently reviewable for the existing Linux, macOS, Windows, Android and iOS targets. Separate viewport layout from input handling and runtime capabilities; centralize native file, clipboard, external-link and window operations. Preserve the shared resource cleanup, SFTP, terminal and headless fixes. Exclude HarmonyOS implementations, projects and framework patches.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟡 Changes recommended
Directory downloads can escape through symlinks, and serial close completion does not actually wait for the native port to be released.
2 open findings
What changed in this PR
Refactors platform detection into width-based layout, host-reported capabilities, and shared native adapters, while strengthening resource and file lifecycle handling.
Changes:
- Adds runtime capability, responsive-layout, input, file-access, clipboard, window, and serial abstractions.
- Coordinates session cleanup and serial operations across GUI and headless hosts.
- Expands tests for host policies, touch/keyboard behavior, SFTP transfers, and startup recovery.
| File | Description |
|---|---|
src/App.svelte |
Gates startup on runtime capabilities. |
src/main.ts |
Tracks input source for context menus. |
src/global.d.ts |
Declares IPC-shim runtime state. |
src/update-capability.test.ts |
Tests capability-based updates. |
src/lib/platform.ts |
Limits UA detection to iOS behavior. |
src/lib/platform.test.ts |
Tests iOS detection. |
src/lib/input.ts |
Adds touch and pointer tracking. |
src/lib/input.test.ts |
Tests mixed input detection. |
src/lib/ipc-shim.ts |
Adapts capabilities and file pickers. |
src/lib/file-access.ts |
Defines opaque file-location contracts. |
src/lib/file-access.test.ts |
Tests file-access contracts. |
src/lib/save-file.ts |
Routes native text saves through commands. |
src/lib/save-file.test.ts |
Tests native, browser, and IDE saves. |
src/lib/sftp-name.ts |
Removes URI-derived filenames. |
src/lib/sftp-name.test.ts |
Removes obsolete filename tests. |
src/lib/soft-keyboard-inset.ts |
Updates terminal-keyboard terminology. |
src/lib/stores/runtime.svelte.ts |
Stores host capabilities and terminal policy. |
src/lib/stores/runtime.svelte.test.ts |
Tests capability loading and refresh. |
src/lib/stores/layout.svelte.ts |
Centralizes viewport layout state. |
src/lib/stores/layout.svelte.test.ts |
Tests responsive layout changes. |
src/lib/stores/app.svelte.ts |
Uses capabilities and per-tab controls. |
src/lib/stores/app.svelte.test.ts |
Tests layout and control routing. |
src/lib/stores/serial.svelte.ts |
Loads serial host capabilities. |
src/lib/stores/session-cleanup.svelte.ts |
Exposes persistent cleanup failures. |
src/lib/stores/session-cleanup.test.ts |
Tests cleanup retries after pane removal. |
src/lib/themes/store.svelte.ts |
Uses host GPU policy. |
src/lib/themes/store.svelte.test.ts |
Tests GPU defaults and overrides. |
src/lib/terminal/touch-scroll.ts |
Enables touch scrolling by input event. |
src/lib/terminal/touch-scroll.test.ts |
Tests scrollbar gesture ownership. |
src/lib/terminal/soft-keyboard.ts |
Adds terminal keyboard coordination. |
src/lib/terminal/soft-keyboard.test.ts |
Tests touch, mouse, and hardware input. |
src/lib/terminal/session-cleanup.ts |
Implements retriable cleanup registry. |
src/lib/terminal/session-cleanup.test.ts |
Tests cleanup isolation and retries. |
src/lib/terminal/reserved-session-attempt.ts |
Waits for prior session cleanup. |
src/lib/terminal/output-feeder.test.ts |
Tests host-specific backlog limits. |
src/lib/terminal/limits.ts |
Removes device-derived backlog constants. |
src/lib/components/AppShell.svelte |
Enforces reconcile-before-resource mounting. |
src/lib/components/TerminalPane.svelte |
Integrates policies, input, and cleanup. |
src/lib/components/WelcomeScreen.svelte |
Selects scenes through capabilities. |
src/lib/components/welcome/SceneSync.svelte |
Presents both mobile platforms. |
src/lib/components/ToastStack.svelte |
Adds persistent cleanup retry notices. |
src/lib/components/toast-stack.test.ts |
Tests cleanup notice persistence. |
src/lib/components/TerminalKeybar.svelte |
Localizes keyboard controls and resets modifiers. |
src/lib/components/terminal-connect-error.test.ts |
Tests localized connection failures. |
src/lib/components/ShortcutsScreen.svelte |
Hides unsupported window shortcuts. |
src/lib/components/ShellSettings.svelte |
Uses PTY capabilities instead of device type. |
src/lib/components/SftpBrowser.svelte |
Resolves batch destinations through the host. |
src/lib/components/sftp-download.test.ts |
Tests isolated, batched downloads. |
src/lib/components/SettingsLayout.svelte |
Filters settings by host capabilities. |
src/lib/components/primary-session-window.ts |
Makes reconciliation a startup barrier. |
src/lib/components/primary-session-window.test.ts |
Tests failure and retry behavior. |
src/lib/components/PlaybackScreen.svelte |
Enables touch scrolling on all hosts. |
src/lib/components/HomeScreen.svelte |
Capability-gates serial and discovery. |
src/lib/components/DownloadsScreen.svelte |
Uses remote names for transfer display. |
src/lib/components/CredentialEditor.svelte |
Capability-gates agent and default keys. |
src/lib/components/ConnectionList.svelte |
Capability-gates serial profiles. |
src/lib/components/ConnectionEditor.svelte |
Offers serial when supported. |
src/lib/components/connection-editor.ts |
Refactors connection-kind filtering. |
src/lib/components/connection-editor.test.ts |
Tests serial capability filtering. |
src/lib/components/SerialProfileEditor.svelte |
Validates host serial capabilities. |
src/lib/components/AppearanceSettings.svelte |
Uses compact-layout restrictions. |
src/lib/components/AboutScreen.svelte |
Capability-gates release updates. |
src/lib/clipboard.ts |
Selects native or browser clipboard. |
src/lib/clipboard.test.ts |
Tests clipboard adapter selection. |
src/lib/plugins/store.svelte.ts |
Uses explicit plugin capability. |
src/lib/plugins/store.test.ts |
Tests plugin host support. |
src/lib/plugins/PluginStrip.svelte |
Adds a visible close control. |
src/lib/plugins/PluginSide.svelte |
Adds panel header and close control. |
src/lib/ai/store.svelte.test.ts |
Stabilizes autosave timer tests. |
src/lib/ai/ChatPanel.svelte |
Keeps message actions visible. |
src-tauri/build.rs |
Defines mutually exclusive platform cfgs. |
src-tauri/Cargo.toml |
Documents platform-specific dependencies. |
src-tauri/tauri.conf.json |
Moves asset scope to runtime configuration. |
src-tauri/capabilities/default.json |
Narrows frontend plugin permissions. |
src-tauri/src/lib.rs |
Registers commands and plugin asset scope. |
src-tauri/src/server.rs |
Aligns headless capabilities and commands. |
src-tauri/src/state.rs |
Adds richer resource lifecycle states. |
src-tauri/src/resource.rs |
Coordinates cancellable resource cleanup. |
src-tauri/src/error.rs |
Makes application errors cloneable. |
src-tauri/src/emitter.rs |
Adds host window and download policies. |
src-tauri/src/files/mod.rs |
Defines shared file contracts. |
src-tauri/src/files/native.rs |
Implements native path resolution and access. |
src-tauri/src/files/atomic.rs |
Adds temporary-file download commits. |
src-tauri/src/platform/mod.rs |
Declares native adapter modules. |
src-tauri/src/platform/runtime.rs |
Reports capabilities and terminal policy. |
src-tauri/src/platform/clipboard.rs |
Selects clipboard backend. |
src-tauri/src/platform/external.rs |
Centralizes external-link validation. |
src-tauri/src/platform/window.rs |
Centralizes window creation. |
src-tauri/src/platform/tauri/clipboard.rs |
Implements process-wide clipboard ownership. |
src-tauri/src/platform/tauri/external.rs |
Implements Tauri URL opening. |
src-tauri/src/platform/tauri/window.rs |
Implements Tauri window confirmation. |
src-tauri/src/commands/mod.rs |
Registers platform command modules. |
src-tauri/src/commands/runtime.rs |
Exposes runtime capabilities. |
src-tauri/src/commands/files.rs |
Exposes file resolution and text saving. |
src-tauri/src/commands/clipboard.rs |
Exposes clipboard operations. |
src-tauri/src/commands/external.rs |
Delegates external-link opening. |
src-tauri/src/commands/window.rs |
Delegates native window creation. |
src-tauri/src/commands/lifecycle.rs |
Coordinates resource closing and retries. |
src-tauri/src/commands/serial.rs |
Makes serial operations asynchronous. |
src-tauri/src/commands/forward.rs |
Uses computed lifecycle phases. |
src-tauri/src/commands/plugin.rs |
Updates platform cfgs and lifecycle checks. |
src-tauri/src/commands/discovery.rs |
Uses repository platform cfgs. |
src-tauri/src/commands/cli.rs |
Uses repository platform cfgs. |
src-tauri/src/terminal/mod.rs |
Restricts native transports explicitly. |
src-tauri/src/terminal/pty.rs |
Updates cfgs and adds PTY integration coverage. |
src-tauri/src/terminal/serial.rs |
Coordinates asynchronous serial opening. |
src-tauri/src/terminal/serial/desktop.rs |
Implements desktop serial operations. |
src-tauri/src/ssh/known_hosts.rs |
Separates sandbox and desktop paths. |
src-tauri/src/secret/mod.rs |
Updates key-store platform selection. |
src-tauri/src/secret/keyring_store.rs |
Uses repository platform cfgs. |
src-tauri/src/server_main.rs |
Restricts headless server platforms. |
src-tauri/src/bin/rssh/main.rs |
Updates Linux cfg usage. |
src-tauri/src/ai/skills.rs |
Builds capability-aware AI guidance. |
src-tauri/src/ai/session.rs |
Validates analysis-window availability. |
src-tauri/src/ai/commands.rs |
Applies host analysis/download policy. |
idea-plugin/src/main/kotlin/sh/rssh/idea/RsshBridge.kt |
Signals late IDE-host readiness. |
package.json |
Removes unused frontend file plugins. |
package-lock.json |
Updates locked frontend dependencies. |
AGENTS.md |
Documents layout/capability conventions. |
roadmap.md |
Adds retained roadmap items. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let result = super::validate_relative_path(&relative).map(|()| { | ||
| relative | ||
| .split('/') | ||
| .fold(root.clone(), |path, part| path.join(part)) |
| /// Desktop ports retain their existing last-handle-drop cleanup behavior. | ||
| /// Pending opens remain owned by the shared lifecycle coordinator. | ||
| pub(crate) fn cleanup(_handle: &SerialHandle) -> Option<crate::resource::CleanupHandle> { | ||
| None |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09077fa03e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!tab) return; | ||
| openCtxMenu(e, tab); |
There was a problem hiding this comment.
Preserve native context menus for touch route panes
When a touch or pen long-press fires contextmenu on Home, edit, or forward panes, this branch calls openCtxMenu, which prevents the event's default behavior and opens the tab menu. openPaneContextMenu correctly filters the same input immediately above; apply isTouchContextMenu(e) here as well so touch keeps its native long-press behavior while an attached mouse can still open the app menu.
AGENTS.md reference: AGENTS.md:L75-L75
Useful? React with 👍 / 👎.
|
|
||
| /// Open the port and, on unix, set the IXANY termios flag when `xany` is on — the | ||
| /// serialport crate doesn't expose it, so we reach the raw fd via libc. | ||
| #[cfg(unix)] |
There was a problem hiding this comment.
Replace the
unix cfg with explicit platform aliases
This newly added backend uses the broad Rust-family #[cfg(unix)] predicate, with a corresponding not(unix) fallback, instead of the repository's mutually exclusive OS aliases. Express the implementations as any(linux, macos) and windows so native backend selection follows the platform model established by this change rather than implicitly including every Unix-family target.
AGENTS.md reference: AGENTS.md:L77-L77
Useful? React with 👍 / 👎.


Summary
Layout selection and native feature support previously shared device checks, while file and host operations crossed UI and platform boundaries. This change makes layout depend on width, native features depend on host capabilities, and native operations use shared interfaces.
This PR extracts all non-HarmonyOS changes from #283 for independent review. It is a single commit based on
main; HarmonyOS projects, adapters, build scripts and framework patches are excluded. The original HarmonyOS branch is preserved.Changes and review order
linux,macos,windows,androidandiosconditions; expose host capabilities and terminal runtime policy throughget_runtime_capabilities. Start withsrc-tauri/build.rs,src-tauri/src/platform/runtime.rsandsrc/lib/stores/runtime.svelte.ts.platform/; route file selection, metadata, destination resolution and text export through the sharedfiles/and frontendfile-access.tsinterfaces. Keep the existing native Tauri backends.resource.rs,commands/lifecycle.rsand the frontend session-cleanup helpers together.The branch's existing non-HarmonyOS roadmap additions are retained. Database schema, sync payload format and SSH authentication algorithms are unchanged.
Entry points
Validation
npm test -- --maxWorkers=2: 71 files, 871 tests passed.npm run build: passed; existing accessibility and bundle-size warnings remain.cargo fmt --manifest-path src-tauri/Cargo.toml --check: passed.cargo test --locked --manifest-path src-tauri/Cargo.toml --features cli,server: 802 library tests and 6 CLI tests passed; GUI/server harnesses compiled; one existing doc test ignored.--locked --target aarch64-linux-android: passed using the installed NDK.git diff --check: passed. Build outputs and generated schemas remain ignored; no signing material is included.iOS limitation: the local
aarch64-apple-ioscheck fails while compiling Tauri's upstream Swift package with the installed Xcode 27 SDKs (OpenGLES/EAGL.hmissing / WebKit module failure). The same failure was reproduced on a cleanorigin/mainsnapshot at49a126f; this PR does not resolve that toolchain issue.These checks are compilation and automated-test evidence. Fresh GUI/device acceptance and Windows/Linux native builds were not performed for this extracted tree.