[Feature] 远程工作区支持从上级目录开始的 Git 仓库(打开 monorepo 子目录时 Git 可用)

Open
#2,282 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
18/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
git, go
Domain
tooling

Research direction

Start by reading desktop/internal/workbench/remote_git.go, especially remoteRepositoryAbove, and the test TestRemoteWorkspaceSaysItsRepositoryStartsAbove plus the string desktop.remote.workspace.gitAbove that currently only shows the "repository starts above" message. On the Core side, find where the remote scope bounds the workspace's host folder and where git.* requests are validated, so git rev-parse --show-toplevel can admit one extra repo-root prefix, then check remote.runWatch allows watching it and how remoteplaceholder.LocalPath maps to .lithe-remote-host. Done means changes outside the folder are listed, stageable, diffable and committable from the commit window while remaining unopenable in the remote editor, with the trust question for an outside repo root flagged for the #2231 security series.

Written by the indexing model from the issue text.

Description

enhancement review: high
Problem to solve / 要解决的问题

远程工作区打开的主机文件夹如果位于一个从上级目录开始的 Git 仓库里(例如打开 ~/work/repo/service,而仓库根是 ~/work/repo),信任文件夹后 Git 视图不能用:Core 在主机上返回的仓库根在工作区占位目录之外,变更路径是相对仓库根的,和项目树(以主机文件夹为根)对不上。#2231 接缝④ 的 PR 里先让 Git 和提交工具窗口说明“仓库从上级目录开始,请打开仓库顶层文件夹”,不显示变更、不记为失败。用户在主机上习惯只打开 monorepo 的一个子目录时,只能改为打开整个仓库。

本机项目已经支持这种布局(本机的 Git 视图按仓库根解析路径,打开子目录也能看到并提交变更),远程工作区落后于本机。

Proposed solution / 建议方案
  • 远程绑定只覆盖主机文件夹本身。让 Git 能读写文件夹以外的仓库根,需要 Core 的远程作用域允许 git.* 请求访问“该工作区所在仓库的根”这一个额外前缀(由 Core 在主机上用 git rev-parse --show-toplevel 解析并校验,不接受客户端给出的任意路径),并在返回的路径里把仓库根下、文件夹外的路径映射到占位目录旁的保留前缀(桌面端 remoteplaceholder.LocalPath 已有 .lithe-remote-host 映射)。
  • 桌面端的 Git、提交、日志、差异、逐行追溯按仓库根解析路径:文件夹内的变更照常定位到项目树;文件夹外的变更在提交窗口里列出(可暂存、提交、查看差异),但不能在编辑器里打开(远程编辑器只读写文件夹内的文件),并说明原因。
  • git 目录的主机监听已按 Core 给出的 git 目录工作,仓库根在文件夹外时同样适用;需要确认 remote.runWatch 允许监听该前缀。
  • 远程信任:信任决定仍按主机文件夹记录;仓库根在文件夹外时,是否要求同时信任仓库根需要按 Zed 的安全设计(#2231 的 S 系列)单独评估,因为 Git 钩子和配置来自仓库根。
Target platform / 目标平台

Cross-platform / 跨平台

Area / 模块

Remote and WSL / 远程与 WSL

Priority / 优先级

P2 / 后续考虑:目前不着急,可安排到后续版本

Alternatives considered / 已考虑的替代方案
  • 打开子目录时自动改为打开仓库根:会让项目树和用户选择的文件夹不一致,也会扩大远程信任的范围,不采用。
  • 桌面端自己把文件夹外的路径过滤掉、只显示文件夹内的变更:提交时会遗漏文件夹外已暂存的内容,用户看不到将被提交的全部变更,不安全,不采用。
Additional context / 补充信息
  • 当前行为与提示文案在 #2231 接缝④ 的 PR 中实现:desktop/internal/workbench/remote_git.go 的 remoteRepositoryAbove,测试 TestRemoteWorkspaceSaysItsRepositoryStartsAbove,词条 desktop.remote.workspace.gitAbove。
  • 关联 #2231(远程开发完整设计)。
Checklist / 提交前检查
  • I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复建议。
Dominant language
TypeScript
Stars
1.8k
Forks
151
Avg merge
3h 48m
Merged PRs (30d)
571

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 1lck/Lithe-IDEA

All issues in 1lck/Lithe-IDEA

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.