Skip to content

[API] Add client file selection on IClientWindow - #725

Open
spaingnv wants to merge 7 commits into
NVIDIA:mainfrom
spaingnv:dev/spaing/client-file-selection
Open

spaingnv wants to merge 7 commits into
NVIDIA:mainfrom
spaingnv:dev/spaing/client-file-selection

Conversation

@spaingnv

Copy link
Copy Markdown
Collaborator

Replaces #674 with the same change as one commit on current main, for a clean history.

Summary

  • Fixes #649: a UI loop calls request_file_selector(request_id, initial_path=None, *, accept=(), max_file_bytes=None, multiple=False), and the result comes back on a later tick as one SelectedFilesUserInputEvent carrying request_id, on the same input stream as keyboard and mouse.
  • The event has status and files (name + data bytes, no host path). status is ok, cancelled, busy, too_large, disallowed_type, or unavailable. Sizes are clamped to 32 MiB per file, 256 MiB and 256 files per set. Apps do not branch on --mode.
  • IClientWindow owns the rules and creates every event: every call gets exactly one event unless its session ends first; one picker at a time (a call while one is open is answered busy); results are checked against the request (types, sizes, count, base names); an internal id per picker so late results are dropped; unavailable if a picker is not shown within 30 s, and no deadline once it is shown. Session replacement withdraws an open picker without a result. Windows implement the platform hooks and the abstract _put_user_input_event; the IClientWindow docstring is the full lifecycle.
  • Native opens a Tk file dialog on a worker thread, so the window keeps presenting. WebRTC shows a non-modal "The app requested a file" prompt; Select… opens the browser's chooser, and the bytes are uploaded with a one-time token that only the connected page receives. MP4 and null answer unavailable.
  • Demo: imgui-ui-file-picker with Open file (A), Open file (B) and Open files, asking for .bin / .raw. Failed picks show in red with the status name.

Test plan

  • CPU:
uv run --no-sync pytest -m ci_cpu \
  flashdreams/test_v2/test_selected_files.py \
  flashdreams/test_v2/test_session_runner.py \
  flashdreams/test_v2/test_native_window_client_window.py \
  flashdreams/test_v2/test_webrtc_client_window.py \
  integrations_v2/imgui_ui_demo/imgui_ui_demo/tests/test_imgui_ui_demo.py
  • Native: Open file (A) → Tk dialog filtered to .bin / .raw. While it is open, A or B shows BUSY. under-32mb.bin → name (N bytes); oversize / wrong type / dismiss → red TOO_LARGE / DISALLOWED_TYPE / CANCELLED. Open files accepts several files. The window keeps presenting while the dialog is open.
uv sync --package flashdreams-imgui-ui-demo --inexact
uv run --no-sync flashdreams-run-v2 imgui-ui-file-picker --mode native-window
  • WebRTC: same buttons; prompt ("The app requested a file") → Select… → browser chooser (not the GPU host). Same statuses as native. Video keeps playing under the prompt.
uv sync --package flashdreams-imgui-ui-demo --inexact
uv run --no-sync flashdreams-run-v2 imgui-ui-file-picker --mode webrtc --host 127.0.0.1 --port 8080
  • MP4 / null: no interactive client; they answer unavailable, covered by the CPU tests above.

@spaingnv
spaingnv requested a review from a team as a code owner October 15, 2026 23:10
@spaingnv
spaingnv requested a review from csyonghe October 15, 2026 23:10
@copy-pr-bot

copy-pr-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@spaingnv
spaingnv removed the request for review from csyonghe October 15, 2026 23:12
@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest changes appear safe to merge; no new actionable issue was established.

Summary

Adds client file selection through IClientWindow, with results returned as SelectedFilesUserInputEvent.

  • The UI loop can request files and receive a result in its input stream.
  • Native windows open a file chooser without pausing the display.
  • WebRTC viewers can approve a file request and send selected files to the app.
  • The ImGui demo offers single-file and multi-file picks with a status for each button.

Diagram

sequenceDiagram
    participant UI as UI loop
    participant Window as IClientWindow
    participant Picker as Native or browser picker
    UI->>Window: FileSelectionRequest
    alt Picker already active
        Window-->>UI: BUSY event on later input read
    else Picker available
        Window->>Picker: Show selector
        Picker-->>Window: Status and selected files
        Window->>Window: Check request limits and selector id
        Window-->>UI: SelectedFilesUserInputEvent
    end
Loading

Reviews (7) · Last reviewed commit: "Make file selection limits app-declared ..." · Reviewed by Greptile

Comment thread flashdreams/flashdreams/runtime_v2/serving/web/app.js Outdated
Comment thread flashdreams/flashdreams/runtime_v2/native_window_client_window.py
@spaingnv

Copy link
Copy Markdown
Collaborator Author

/ok to test 77c89cf

Comment thread flashdreams/flashdreams/runtime_v2/native_window_client_window.py Outdated
@spaingnv

Copy link
Copy Markdown
Collaborator Author

/ok to test f66bcd0

@spaingnv

Copy link
Copy Markdown
Collaborator Author

/ok to test 7a7be4a

@spaingnv
spaingnv force-pushed the dev/spaing/client-file-selection branch from 62718b8 to 7a7be4a Compare October 17, 2026 00:20

@ArielG-NV ArielG-NV left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design is effectively perfect; minor clean-up suggested.

Comment thread docs/source/documentation/demo_api/api_reference/application.md Outdated
Comment thread flashdreams/flashdreams/api_v2/client_window.py Outdated
Comment thread flashdreams/flashdreams/api_v2/client_window.py Outdated
Comment thread flashdreams/flashdreams/api_v2/client_window.py Outdated
Comment thread flashdreams/flashdreams/api_v2/client_window.py
Comment thread flashdreams/flashdreams/api_v2/client_window.py Outdated
Comment thread flashdreams/flashdreams/api_v2/client_window.py Outdated
Comment thread flashdreams/flashdreams/api_v2/loop.py Outdated
Comment thread flashdreams/flashdreams/runtime_v2/native_window_client_window.py Outdated
Signed-off-by: Set Paing <spaing@nvidia.com>
Remove the file-selector locks: IClientWindow and the WebRTC server's
upload tokens are each touched by one thread. The native file dialog runs
in a child process polled by the UI thread, so a dialog left open when its
session ends is closed. Trim the file-selection docstrings.

Signed-off-by: Set Paing <spaing@nvidia.com>
The native dialog writes its paths to a temporary file, so a long path
list cannot fill a pipe and block the child. The WebRTC page trusts the
server's one-selector rule and replaces a finished picker with a new one.

Signed-off-by: Set Paing <spaing@nvidia.com>
Signed-off-by: Set Paing <spaing@nvidia.com>
- Run the native Tk dialog on a worker thread instead of a child process.
  A dialog left open at session end stays until the user closes it; its
  result is dropped by the selector id, and new requests get BUSY meanwhile.
- Drop the 30-second presentation deadline and the browser ack it needed.
- Rename _checked_result to _check_file_selection_result, mark
  request_file_selector and flush_file_selectors @Final, and use
  Path(name).name for basenames.
- Add a delayed "Restart session" button to the file-picker demo.

Signed-off-by: Set Paing <spaing@nvidia.com>
Restore main's behavior: input read by a run with no step is dropped.

Signed-off-by: Set Paing <spaing@nvidia.com>
@spaingnv
spaingnv force-pushed the dev/spaing/client-file-selection branch from 7a7be4a to 231b722 Compare October 19, 2026 21:07
Comment thread flashdreams/flashdreams/api_v2/loop.py
@spaingnv

Copy link
Copy Markdown
Collaborator Author

/ok to test 231b722

@ArielG-NV ArielG-NV left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes suggested.

Comment thread flashdreams/flashdreams/api_v2/client_window.py Outdated
Comment thread flashdreams/flashdreams/api_v2/loop.py Outdated
Comment thread docs/source/documentation/demo_api/api_reference/application.md Outdated
request_file_selector takes max_file_bytes, max_total_bytes and
max_file_count, defaulting to 1 GiB, 1 GiB and 256, with no hard ceiling.
max_file_bytes must not exceed max_total_bytes. The WebRTC server enforces
the app's limits on its side and bounds the request body up front.

Signed-off-by: Set Paing <spaing@nvidia.com>
@spaingnv

Copy link
Copy Markdown
Collaborator Author

/ok to test 8fde1264c

@copy-pr-bot

copy-pr-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

/ok to test 8fde1264c

@spaingnv, there was an error processing your request: E2

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/

@spaingnv

Copy link
Copy Markdown
Collaborator Author

/ok to test 8fde126

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API] Add SelectedFilesUserInputEvent support

2 participants