Repository navigation
feat(mecatui): add workspace snapshot inspector - #2676
Conversation
Open a frozen workspace inspector with F10 or /workspace while idle or running. Keep observed Edit/Write paths distinct from sampled Git changes, and replace the expanded file appendix with a bounded inspector invitation. Inspect Git only for trusted, verified local execution roots on the embedded transport. Bound and harden subprocesses, reject clean/process filters, and keep failures distinct from confirmed non-repositories. Cover production composition, snapshot lifetime, modal priority, keymaps, Git parsing and helper suppression; document the limits and trust behavior. Co-authored-by: Mecatl <noreply@mecatl.dev>
Approved implementation plan: workspace-status
This is the full approved plan, including the repository-trust/filter amendment and the operator's workspace-discovery, presentation, and toggle refinements. Its verification section describes intended checks; actual test and review results are recorded in the PR description and subsequent delivery notes. No plan content was omitted or redacted. Paths below describe repository files or local planning provenance. Refinement delivery review: incremental Spec, Standards, Test adequacy, Security, Architecture, Reuse, and Duplication checks have no outstanding findings after follow-up fixes. Final full lint and race gates pass, along with focused regressions; documentation/site checks and the offline tool/approval/result demo also pass. The source plan below records the agreed behavior, not a claim of live/manual terminal verification. Workspace status snapshotSlug: workspace-status Goal and agreed scopeReplace F9's unbounded changed-file appendix with a bounded invitation to a dedicated read-only workspace inspector. F10 and
Current seams and minimum approach
Observable view and contractsIdentity and GitRender a compact identity section immediately, followed by a scrollable/filterable file area in an inspector card. Show only known fields; do not claim that embedded transport necessarily means local execution. Once resolved, show the effective local working directory. For eligible Git workspaces show:
Use one authoritative fixed status command: Session observationsLabel these as observed Edit/Write paths, not files successfully changed or current Git changes. Mark matching Git rows as observed and list unmatched observed paths separately (they may be clean, committed, removed, ignored, or outside the repo). Keep the section available without Git. Join only using lexical normalization against the resolved local working directory/repository root; retain original display paths. Do not resolve symlinks, open files, or expand access to match rows. Do not apply local path semantics to opaque/remote observations. A marker is an observed tool-call fact, not ownership of the current diff; absence does not prove the session did not change the file. Capture paths once before starting asynchronous inspection. Later tool calls update root conversation state but never mutate this surface's snapshot. Filter/navigation changes presentation only. No refresh action, timer, event subscription, or root live-sync hook. Input and lifetime
F9 and keybindingsKeep the existing small header file count. Replace the expanded file enumeration with a short, width-bounded advert using the effective remapped Workspace key and Update both Register public Local inspection safety and implementation boundaryPrefer a small host adapter in new Each open resolves the captured session using the existing local-context getter, then invokes Git via stdlib Bound stdout/stderr and ensure cancellation/deadline releases the subprocess and pipes. Do not alter the shared gitenv policy for this feature. Missing binary/root resolution errors are nonfatal view states. Tests must distinguish confirmed non-repository from other Git failures. Keep Git operations read-only, including avoiding optional index refresh writes. Approved implementation amendment: repository trust and filtersThe operator approved using existing repository trust, not a new trust mechanism or a Git sandbox. Gate local Git on trust covering the actual resolved execution root; launch-directory trust must not silently authorize an unrelated selected root. Unknown/untrusted roots retain identity/observations but no Git inspection. Reuse existing trust resolution/confirmed server facts without engine/server/wire changes. Permit additional bounded read-only Git configuration inspection to detect clean/process filters, returning explicit Git-unavailable when helper-free status cannot be established. Keep lightweight environment/argv hardening and the no-helper/no-network inspector contract; do not silently disable filters and report potentially incorrect clean totals. Treat trusted concurrent malicious configuration replacement as outside this feature's confinement guarantees; the child is not an OS sandbox. The operator noted that prompt Git status commonly has this same exposure and asked for proportionate handling, not an elaborate new sandbox. Implementation tasks
Dependencies: task 1's narrow data contract precedes task 2; tasks 2 and 3 integrate together; task 4 verifies the complete candidate. Do not stage/commit/push/create a PR unless separately requested. If an implementation PR is authorized, preserve the latest publishable plan in one verified PR conversation comment per plan-implement, keeping local plan/run metadata ignored. VerificationFocused tests at production seams (not source-text assertions):
Integrator runs focused API compatibilityClient-only UI and host-side observation using the existing embedded local-context RPC unchanged. No engine/server semantics, wire fields, feature identifiers, API major, or stored data format change. Existing remote clients need no upgrade. UI keybinding schema gains an additive action; document its default and collision rules. API compatibility statement should accompany any eventual PR. Confirmed behavior decisions
The operator confirmed both recommendations. No material behavior decisions remain open. Do not reopen remote Git, refresh, network, key choice, or engine expansion during implementation. Approved review refinements: workspace discovery and presentationThe operator requested a normal-view F10 prompt when the session is in Git or has observed Edit/Write paths, richer formatting matching existing data surfaces, clearly separated state sections, and a concise shared standard in Organize the inspector by provenance: session identity/placement, sampled local Git state (including its own unavailable/loading/nonrepo state and time), and retained observed Edit/Write intentions (including limitations/unmatched paths). Use existing theme-owned heading/field/value/status styles, spacing and labels with non-color section cues; keep sanitization, tab expansion, wrapping, bounds and close-only input behavior. Add the reusable inspector/data-section presentation convention under the existing lists/detail-view contributor guidance; do not invent a styling framework or new palette. The operator also requested readable F9-state hints, stronger filenames distinct from headings, and a symmetric Workspace toggle. In expanded conversation mode, advertise the effective F9 action as hiding details; label the workspace invitation with its action. Use bold normal theme text for Git/observed filenames (including rename paths), accented headings/labels, normal field values, and quiet file status/annotations. The effective Workspace binding and all configured aliases close an open workspace inspector, including loading/compact/nonempty-filter states; Escape still closes it. Closing cancels only the captured inspection, never the active run, and retains draft/queue/steer state. Preserve confirmed complete placement across successor bindings while invalidating stale binding metadata and discovery results. Design reviewIndependent fresh-context plan critique completed. It identified one blocker (Git defaults could hide untracked files/divergence) and two important corrections (explicit submodule scope and a restricted child environment). The draft now pins the status argv, non-recursive scope note, allowlisted environment and no-network controls, with negative-control fixtures. The same reviewer rechecked the exact replacement sections and found all three issues addressed. Review used inlined draft text because ignored scratch files are unavailable in the review checkout; it did not verify implementation or execute tests. The operator subsequently confirmed both reserved behavior recommendations unchanged. No review findings or behavior decisions remain unresolved. Implementation was subsequently authorized and completed locally on |
Advertise the workspace inspector for confirmed Git sessions or retained Edit/Write intentions, using one trusted local membership probe per binding. Group snapshot details by provenance, emphasize filenames in bold normal text, and clarify F9 hints and the remap-aware F10 open/close toggle. Preserve confirmed successor placement across clear and worktree handoffs, and strengthen asynchronous, transport-authority, alias, and style regressions. Co-authored-by: Mecatl <noreply@mecatl.dev>
Co-authored-by: Mecatl <noreply@mecatl.dev>
Summary
/workspacewhile idle or running. Capture workspace identity and observed Edit/Write intentions once per open; keep the view readable across ordinary run completion.Safety and limitations
Git runs with fixed arguments, a restricted scrubbed environment, bounded output and a 30-second overall deadline. It does not fetch or inspect submodule working trees. Effective clean/process filters make Git inspection explicitly unavailable rather than allowing helpers or disabling filters and misreporting status. This uses existing repository trust, not a new trust system or OS sandbox; trusted concurrent malicious configuration replacement is outside the confinement guarantee.
Snapshots are non-atomic and static; close and reopen to resample. Observed paths are announced tool intentions, not proof of successful changes or ownership of the current diff. Shell/delegated writes and resumed-history reconstruction remain outside the observation accumulator.
Validation
go test ./cmd/mecatui/... -count=1task testtask lint— final all-module run passed with zero issuestask test:race— final complete offline suite passedtask docstask site:buildgo run ./cmd/mecademo— tool call/result, permission ask/approval and final result verifiedThe aggregate non-race suite passed before lint-only factoring; affected non-race tests and the final complete race suite passed afterward. Manual interactive terminal verification has not been performed.
Review
Panel review against implementation start
1c085bbafc9b99e1aac760a7d2004e5c742a3e7d, with targeted incremental rechecks after fixes: Spec, Standards and Test adequacy clear; Security, Architecture and Duplication clear. One low-priority advisory remains: optionally inline the single-caller Git count helper; the coherent helper is retained. No blocking or important findings remain.API compatibility
Client-only UI and host-side observation using the existing embedded local-context RPC unchanged. No engine/server semantics, wire fields, feature identifiers, API major or stored-data format changes. Existing remote clients need no upgrade. The UI keybinding action
Workspaceis additive, defaults tof10, and uses the documented collision checks.Implementation plan
The full approved implementation plan, including the repository-trust/filter amendment and planned verification, is archived in a regular PR conversation comment. Its published contents were read back and SHA-256 verified. Actual validation results are listed above; the plan's verification section records intended checks rather than test receipts.