Repository navigation
feat(composer): accept file manager line references - #2129
Tioit-Wang merged 25 commits into
Conversation
Let the installed File Manager add a saved selection to the draft through its sandboxed view. Copy and paste use the same line range. Keep the reference bound to the active project and session, then read only those lines through the existing tool permission path on send.
Use the required decision record sections and index the candidate so the documentation checks and generated site can validate it.
Model clipboard formats separately and check both ordinary and ranged chip labels so the existing Composer regressions exercise the new contract.
…-file-lines-20261106
|
The app-side boundaries are solid — two permissions, only a visible view may ask, a second confirmation, and a "local project only" switch that closes off remote and outside paths. All six checks pass, and the code stays on current main. One thing is missing: the linked reference points at an issue that was already closed as not planned, so please open one in this repository describing the ordering and that "local only" rule. After that this can go through normal review. 应用侧的边界很扎实——两个权限、只允许可见视图发起、二次确认,以及「仅限本地项目」把远端和外部路径都挡回去。六项检查全绿,代码也基于当前主干。 缺一件事:关联引用指向的那个 issue 已按「不计划」关闭,请在本仓库开一个,说明先后顺序和「仅限本地」这条规则。之后就可以正常评审了。 |
Review: host capability is sound, four things to fix before mergingI read the whole 48-file diff (only this PR's changes), traced the path end to end, and cross-checked the two external contracts the change now leans on: How the feature flows today1. The prefetch Read is persisted as an orphan tool row; restore then fabricates an assistant turn (medium — I would fix this before merge)
On the next session restore, So the file text reaches the model as a tool result after a restart and as a user-message block before it, and a Read the model never asked for appears in its history (and in the UI). It compounds: retry/revision re-sends the attachments ( Suggestion: don't emit persisted tool events for the prefetch — use a non-persisted progress signal, or tag the row and skip it in 2. A blocked or failed read is delivered to the model as file content (high)
<file_lines source="gpt.py (85:86)">
Call tool_search to activate Read before using it. A tool declaration does not grant execution permission.
</file_lines>
Suggestion: branch on 3. The prefetch read's Host file batch is registered but never closed (low-medium)
The consequence is bounded rather than permanent: the slot lingers until the 4. The capability is advertised to plugins the action always rejects (medium)
Smaller items
Checked and fine (so it does not get re-litigated)
ProcessThe head |
File line references are user-supplied context. Keep their Reads outside assistant tool history and batches while preserving normal Host permission checks. Label blocked and failed references separately from file content. Advertise the capability only to an eligible File Manager view whose loaded version matches the enabled Host registry entry. Keep path and session checks on invocation.
|
@Tioit-Wang, thanks for tracing the prefetch through Pi and the Host registry. The four items in your review are addressed in
Local validation on the updated base |
Follow-up review of
|
| Finding | What the fix does | My check |
|---|---|---|
| Prefetch Read persisted as an orphan tool row, so restore fabricated an assistant carrier | The prefetch no longer emits tool_start/tool_end; fileLineReadCalls became Map<string, { blocked }> and is used only for workspaceOnly (runtime.ts:3653) and the beforeToolCall skip |
No role: "tool" row can be created, so historyToEntries never reaches the synthetic-carrier path. The new test asserts no tool_end event and no tools.fileBatchRegister call |
| A blocked/failed read delivered as file content | promptText now emits <file_reference_error status="blocked|failed"> (runtime.ts:367-368), with blocked set from a missing tool, a beforeToolCall block (9218-9221) and a Host denied || PERMISSION_DENIED (3730-3732) |
I checked the one link that could have silently left a denial inside <file_lines>: a denied tool result is isError: true (result.isError === true || result.ok === false), so it always lands in the blocked branch. Two parameterised tests cover failed and blocked |
| Host file batch registered but never closed | beforeToolCall skips registerBatchCall for a prefetch (runtime.ts:2676) |
No batch, so the 15-minute UNUSED_TTL slot retention and the MAX_CALLS = 512 exhaustion path are gone too |
| Capability advertised to a plugin the action rejects | composerFileLines is now an explicit PluginViewOpenRequest field computed in plugin-ui-ipc.ts:325-333 (!development, not disposing, ui.view + fs.read, enabled registry entry with the loaded version, same Host instance) |
The gate and the invocation check now agree, and the errors are split by reason (file-line-reference.ts:47/60/62/67/74/76), which also makes the plugin side diagnosable |
ADR, runtime spec and the E2E scenario are consistent with the new behaviour (the scenario now requires "no synthetic Read in the transcript or restored model history", a failed marker after deleting the file, and a blocked marker on denial). types/messages.ts doc drift and the dead FILE_LINES_VIEW_KEY import are cleaned up.
Three things the fix introduced or exposed
1. The capability is computed once at view creation, and that computation now sits on the open path (low-medium)
pluginViewOpen ──▶ await plugins.list (Host round-trip) ──▶ pluginViews.open({ composerFileLines })
│
└─ throws/timeout ─▶ .catch(() => false) ─▶ view opens WITHOUT the capability,
and argv never refreshes
plugin-ui-ipc.ts:328 awaits a Host call before pluginViews.open. Two consequences: opening the File Manager tab is now gated on that round-trip (bounded by rpcTimeoutMs), and a failure degrades silently to "no capability" for the lifetime of that webContents — the user has to re-open the tab or restart to get Add to chat back. Suggest a short explicit timeout (compare refreshProjectGroups, which passes 5 s) and a way to recompute later — e.g. push the capability once the Host is ready, or answer it lazily on the invocation instead of baking it into argv.
2. Two different messages for the same condition (low)
The handler already throws "plugin is not active in this project" a few lines above, and the new block throws "plugin is no longer active in this project" (plugin-ui-ipc.ts:331) for the same family of conditions — and that branch additionally covers "grant was revoked" and "workspace is null or switched" under one message. Either reuse the existing message or split the real causes.
3. Host unavailable is reported as "not registered" (low)
When getHost() is null, addFileLinesFromView reaches "The File Manager is not enabled in the Host registry." (file-line-reference.ts:67) although the real cause is a restarting/unavailable Host. Worth a distinct HOST_UNAVAILABLE reason.
Still open from the first review (all nits)
parseFileLineRangehas no upper bound onend:{start:1,end:9e15}still yieldslimit: 9007199254740991; only the Host'smax_linesclamp keeps the read sane.- The 4-reference cap is enforced three different ways: the renderer truncates silently, main throws
INVALID_ARGUMENT, the runtimecontinues silently — a visible chip can end up sending nothing. - The renderer normalises the workspace (
normalizeProjectPath) while main compares strictly; same source string today, consistency risk only. runtimeAttachmentFromMessagestill dropslineRange, so a restored context keeps thepath (85:86)label in the message text but no attachment metadata. The E2E wording ("the reference is still visible") holds; it only matters if a future change wants to rebuild the block after a restart.
Scope
Static review of the fix commit plus a check of the merge itself (the merged composer changes — directory cards, model picker — do not alter the line-reference path: applyEditorDraft goes through restoreDraftAttachments, and detachDirectoryTokens only touches kind === "directory"). I did not run the suites; the test claims above are read from the new assertions, not from a local run.
Opening File Manager must not wait for Host registration or retain a false capability after a transient Host failure. Advertise bridge support from the loaded grants and authorize registration on each action with a bounded query. Report Host unavailability separately from disabled registration and allow a retry from the same view after reconnection.
|
@Tioit-Wang, the three follow-up items in your review are addressed in
The two focused regressions failed on the previous head and pass with this fix. Tests cover opening with a failing Host without issuing a query, a missing Host, query failure followed by recovery, disabled/version-mismatched registration, and stale-session rejection. All 39 focused desktop tests, desktop build/typecheck, and documentation checks passed. Composer paste E2E was rerun successfully on the integrated head. All six GitHub checks passed for This follow-up covers the three new findings. The remaining items marked as nits in your review and the normally installed File Manager integration acceptance are still open. |
Preserve agent mentions and steering cancellation while refreshing the shared PR. Keep pasted text when the line-reference limit is reached, with a native regression covering the fallback.
|
Refreshed the PR against current main Also addressed the four-reference overflow feedback: an extra paste now keeps the plain text and shows the limit warning. The native Composer regression fails with the previous return value ( Validation on the integrated tree: 415 runtime tests, 43 shared Composer tests, 28 focused desktop tests, desktop typecheck and production build, documentation, architecture, style-token and PR-base checks passed. The macOS arm64 Composer paste suite passed, including draft races and restart persistence. The task reused the existing dependency store; no live model or user profile was used. Please re-review the updated candidate. Acceptance with the normally installed File Manager remains sequenced after the host lands, as agreed with plugin PR #10. The earlier upper-bound, workspace-normalization and restored attachment-metadata nits are not claimed as resolved by this refresh. |
|
CI update for The browser Host/capture implementation and capture/resize fixture are unchanged by this PR relative to main An attempt to rerun only the failed job was rejected with GitHub 403 ( |
Preserve the existing Composer line-reference commits and current main\nsession and browser fixes. Retain both sides of appended specification\nand acceptance scenarios.
Reject unsupported line coordinates and selections beyond the Host Read line budget. Validate all runtime references before reading so invalid drafts cannot silently lose context. Use Composer workspace normalization at the plugin action boundary and retain line ranges when restoring recorded attachments.
A delayed window manager loses the early maximize request while the test holds its screenshot response. This reproduces the Linux 30-second capture timeout without changing browser code. Wait for the EWMH root claim with bounded startup and cleanup, retain all native assertions, and print probe progress on failure.
|
Addressed the remaining review items in
Validation passed: 1,790 agent-runtime tests, 1,420 shared tests, 21 focused desktop tests, the launcher regression, full JS build, desktop typecheck, docs/architecture/style/Pi dependency/base/diff checks, macOS arm64 Composer paste/draft races/restart persistence, and macOS plus Linux native browser capture/resize/lifecycle. Linux validation used Debian 12 arm64, Xvfb/Openbox and Electron 43.6.0 in an isolated container with The updated GitHub CI run is running. Normally installed File Manager acceptance remains sequenced after host landing, as agreed with plugin PR #10. Please re-review the updated candidate. |
|
CI update: all six checks passed for The fetched PR merge candidate |
Preserve the published line-reference history while integrating current main. Keep the staged-mode prompt refresh before reference prefetch and retain both sets of appended specifications and acceptance scenarios. Exercise the combined mode/reference path and synchronize the affected documentation mirrors. Installed-plugin acceptance remains sequenced after Host landing.
|
Refreshed the existing PR in Resolved the runtime conflict by retaining the staged-mode system-prompt refresh before file-reference prefetch, and retained both sets of appended docs/scenarios. A combined Goal/objective plus scoped-reference regression fails when the main refresh is removed and passes with the resolution. The affected documentation mirrors now match the reference contract. Local validation passed: full JS build; Desktop/runtime TypeScript; 506 runtime/mode, 1,458 shared, 26 Desktop/launcher and 31 i18n tests; three targeted Rust persistence/authorization tests; macOS Composer paste/draft-race/restart and native Browser capture/resize/lifecycle E2E; docs/architecture/style/Pi/base checks. The first refresh's CI exposed a dead ADR link in the new locale mirror; the final documentation-only follow-up fixes that route, and the complete VitePress build passes. Final CI: all six checks passed on The fetched integration candidate |
The line-reference ADR exists in the English documentation tree. Use its canonical route from the locale mirror so VitePress can resolve it on clean CI builds.
Preserve mode snapshots, queue refresh ordering and file reads. Keep the original PR history and local-project authorization boundary.
|
Refreshed the existing PR to Full JS/Desktop/VitePress builds, Desktop TypeScript, 427 runtime tests, 50 focused shared tests, 26 Desktop/launcher tests, three Rust persistence/authorization regressions, and fresh candidate-local Host build passed. Native Composer submission/overflow, draft races, focus recovery and process-restart persistence passed in the final serial run; native Browser capture/resize/lifecycle also passed. Docs, architecture, style, base and whitespace checks passed. Official Electron 43.6.0 arm64 bytes were downloaded and SHA-256 verified; profiles/projects are synthetic and isolated. Fresh CI is running. Please re-review the updated candidate. Plugin File Manager #10 now contains its current main and rebuilt production view, but remains Draft under the agreed host-first sequence: normally installed joint acceptance follows this Host PR landing. No live-provider or installed-client success is claimed. |
|
All six fresh-head checks passed on CI: https://github.com/vastsa/PI-Desktop/actions/runs/43368787715 . The fetched GitHub integration candidate has the same complete tree as the locally validated head. The description records the final results. Ready for maintainer re-review; normally installed plugin #10 joint acceptance still follows Host landing. |
Incorporate main 82823a6 without rewriting published review history. Retain both the proposal and the new JSON settings acceptance coverage.
|
Final candidate All six final-head GitHub checks passed: https://github.com/vastsa/PI-Desktop/actions/runs/43370704200 . This includes the complete Linux Electron job and Windows transcript cache acceptance. The fetched PR integration candidate has the same complete tree as the tested head; the description records final results. Ready for maintainer re-review. Plugin #10 is refreshed, conflict-free and tested in isolation, but its normally installed joint acceptance still follows this Host PR landing. |
Preserve both reference paths when incorporating current main without rewriting the published proposal. Keep line selections through input recall and reject ambiguous metadata before scoped reads. Mixed draft, prompt and runtime regressions cover the combined contracts while retaining native-file size refresh and canonical persistence.
|
Deployment failed for project pi-desktop with the following error: |
|
Refreshed this existing PR non-destructively to Validation: full workspace/Desktop and documentation builds, Desktop TypeScript, configured lint/architecture/style/docs checks, 429 runtime tests, 50 shared tests, 49 Desktop tests, both Rust canonical-attachment tests and the launcher regression passed. The new input-recall regression fails with main's history reader and passes after preserving validated ranges. Real Electron full paste, large-file metadata and second-process recovery passed; native Browser capture/resize/lifecycle passed. Existing compatible dependencies were reused with candidate-local workspace builds. Specs, E2E mirrors and the line-reference ADR are synchronized. All six current-head repository Actions checks passed: https://github.com/vastsa/PI-Desktop/actions/runs/43398679372 . This includes the full Linux Electron job and Windows transcript-cache E2E. GitHub integration The separate Vercel preview status is still failing: the bot reports that the configured repository cannot find the requested branch or commit reference. Could a maintainer inspect that deployment integration? I have not changed deployment settings or claimed the overall status is green. Normally installed File Manager #10 joint acceptance and its merge order remain pending. Manual Finder copy gestures, live providers and Windows/Linux local UI acceptance are not claimed. Ready for maintainer re-review; no merge performed. |
Preserve the published file-reference proposal while incorporating the current runtime, Plan permissions, cache usage and native window fixes. Keep both sides of the E2E scenario additions in the integration candidate.
The current queue reads session mode selection state before dispatch. Supply that dependency in the native history fixture and fail promptly if submission settles before its prompt boundary instead of timing out.
The asynchronous waitForFunction predicate resolves after its first read, which can precede the atomic write. Wait for the visible saved state before checking disk bytes so integration validation observes completion.
|
@Linuxdazhao is attempting to deploy a commit to the vastsa's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Refreshed this PR to All six repository Actions checks passed on this head, including the complete Linux Electron job and Windows transcript-cache acceptance: CI, Docs, PR base. Integration merge Local validation passed: production builds/typecheck and targeted checks; 430 runtime, 50 shared and 53 Desktop/launcher tests; fresh Host build, two attachment-persistence tests and the scoped Read regression; native Composer paste/restart and large-file metadata/restart; and the real File Manager process/view + Desktop broker + loopback RACP journey. File Manager #10 now includes merged #12, preserves both Electron suites/docs, rebuilds its IIFE and passes all 14 verify suites, isolated line-reference/Markdown Electron checks and official check/pack. It is now Ready under its maintainer's confirmed prerequisites. Limits remain explicit in the PR description: normally installed line-reference joint acceptance is unverified. The additional macOS Browser capture/resize run stopped at maximize (the serial attempt hit a screenshot timeout), while the Linux CI version passed. Vercel separately reports |
…uring Keep the published proposal compatible with current main without rewriting its history. Move its acceptance scenarios into the new domain catalogs and retain main's removal of detailed Chinese specification mirrors.
Exercise the merged plugin package through normal Host installation and the production Desktop, plugin bridge, Composer, scoped Read and sidecar. Keep only the provider synthetic and isolate application and capability state. Verify disk freshness, unsaved-selection gating and restart recovery.
Main restored the installed-card Open panel action in 438a1a3 but left the extensions-page assertion expecting its absence. Align the stale assertion with the documented behavior so the integration gate can run. No product behavior or permission boundary changes.
|
File Manager #10 is merged. This PR is refreshed to The installed-plugin integration gap is now covered by All six current-head checks passed: CI, Docs, PR base. Local Composer/restart and large-file metadata journeys also passed. Integration merge The final test-only commit corrects main's stale assertion that Open panel must be absent after |
Preserve the published history while incorporating the current Pi runtime and Host changes. Retain main's stronger installed-panel action assertion to resolve the only conflict without changing product behavior.
|
Updated the existing branch to All six checks have finished successfully: CI, Docs and latest base. Integration merge Local validation was rerun on Pi 1.5.0: the normally installed merged File Manager package passed selection, unsaved-edit gating, fresh scoped Read and full Desktop/Host restart; native Composer paste/draft/history and 64 MiB+1 metadata/restart journeys passed. Also passed: 430 runtime, 50 shared and 83 Desktop/plugin/launcher tests; fresh Host build, attachment persistence and scoped-path regressions; builds/typecheck/lint/docs/architecture checks. The description is current and retains the release/live-provider/platform limits. Ready for re-review; no merge or release performed. |
Merge main aa03aa6 into the feature branch so the request head contains the latest base again. Three conflicts needed a hand resolution: - api.ts keeps the new onComposerFileLines hook and adopts main's ComposerSuggestionMessage type for onPluginComposerSuggestion. - runtime.ts keeps main's background-completion entries and runs the file-line resolution before the prompt content is built. - runtime.test.ts takes both import sets: requestTranscript from main and builtinModeDefinition from this branch. The merge also surfaced one fixture gap that the textual merge hid: main now registers the composer suggestion result through registrar.handleWithEvent, and the installed-panel test added here only stubbed handle. The mock now follows the same handleWithEvent() stub the rest of that file uses. No product behavior or acceptance assertion was weakened.
|
Refreshed this branch to Three conflicts needed a hand resolution, and none of them changed product behavior:
The textual merge also hid one fixture gap: main now registers Local validation on macOS arm64 / Node 26.13.1 / Electron 43.6.0, task candidate
Not rerun in this refresh: All six checks are green on |
|
久等了,已合并! |
Refs #2135 and supersedes #2121. Earlier discussion: #2119.
File Manager selections become removable Composer references such as
gpt.py (85:86), through Add to chat or clipboard paste. References stay bound to the active local project and session; other clipboard consumers retain plain text.At execution, the runtime reads the saved range through the existing workspace-only Host Read and tool hooks. Read failures remain separate from content and prefetches create no assistant tool history. Ranges survive queueing, input recall and transcript restoration. Coordinates are positive signed 32-bit integers, with a 4,000-line selection limit and four-reference cap; invalid inputs fail before reads. Lexical and real-path containment remain enforced.
Line selections coexist with native disk-file references in mixed drafts and persisted messages. An attachment combining
lineRangeandlocalReferenceis rejected before a scoped Read.File Manager #10 is now merged (
90cfc010a3f9). This Host candidate is92d039aa4575, containing mainaa03aa69c368without rewriting the published history. The refresh follows main's documentation restructuring: line-reference and browser acceptance scenarios live in the new domain catalogs, and removed Chinese specification mirrors stay removed.The new
scripts/e2e-file-manager-lines.mjscloses the installed-plugin integration gap. It installs the merged 0.9.1 package through the real Host package-install API with its declared grants, then runs the production Desktop, plugin view/bridge, Composer, Host and sidecar against isolated data/capability directories. The view is opened through public Host IPC; selection and submission use actual UI input. Only the model provider is a loopback Chat Completions fixture.Current local validation on macOS arm64 / Node 26.13.1 / Electron 43.6.0 / Pi 1.5.0:
b1797bd787292eb39ff248848381eecbaec3fe629ab05d699db0b6c1b79b0fbb.The latest refresh merges main
aa03aa69c368into92d039aa4575, preserving the published history. Three conflicts were resolved by hand (theonComposerFileLineshook alongside main'sComposerSuggestionMessagetype, main's background-completion entries alongside the file-line resolution, and both import sets in the runtime test), and the installed-panel test's registrar mock gained thehandleWithEventstub main now requires. No product behavior or acceptance assertion was weakened. Local validation for this candidate is recorded in the comment below; the installed-package, Composer/restart and large-file/restart journeys are unchanged from the run above.All six current-head checks passed on
92d039aa4575: JS, Linux Rust, Windows Rust/transcript-cache and Linux Electron E2E, Docs and latest base. GitHub reports the branchMERGEABLE. There is no Vercel status attached to this head.This qualifies a normally installed plugin against a production candidate build, not an installed release/upgrade. Native clipboard/Finder gestures, live providers, real SSH and Windows/Linux local UI acceptance remain unverified. The earlier macOS browser maximize timeout was not rerun in this refresh; Linux browser capture/resize passed in the current CI run. No merge or release is claimed.