Repository navigation
feat(git): Git 控制台按类别记录内部查询并支持显示选项,默认与 IntelliJ IDEA 一致 - #64
Merged
Merged
Conversation
…details it shows
- gitExecution.consoleQueries lists the query categories a console records
(references, reload, diffRefresh, diff, log, logPathFilter, annotate, panels,
checks); gitExecution.queryCategory names the category of a read the command
alone does not tell apart. reportQueries is removed. An empty list records no
internal query, as IntelliJ IDEA does, and an unrecorded query emits no events,
so it takes none of the console's capacity.
- console::category::of_command maps every request command to its category;
a background request without a named category stays silent.
- git.consolePresentation accepts display { foldSingleLineQueries,
showCompletedWithoutOutput, hideTemporaryConfig, hideRepository }. All default
to false, which is IDEA's console: single-line query output stays visible, a
command without output shows no notice, temporary -c values fold, and the
repository label shows.
- Fixtures: console-queries-v1.json (new) and console-presentation-v1.json
cases for each display option; rust-core-api.md documents both.
26 of 29 tasks
…tion, report failed queries - Progress blocks and query output fold only when they are longer than ten lines; `display.foldSingleLineQueries` becomes `display.foldShortQueries`, which folds a successful query's output at any length. - A record whose arguments delete something (rm, clean, branch/tag/update-ref/symbolic-ref -d, push --delete/--prune/:ref, fetch/pull --prune, remote remove/prune, config --unset, stash drop/clear/pop, worktree remove/prune) folds neither its `-c` configuration, its progress, nor a query's output. The shared `deletions` table fixes the list. - A query the console does not record still reports itself once it fails in a request that is not `background`, as every query did before categories: started, stderr and finished arrive together; stdout is not kept, and a cancelled query stays silent.
- A reported query's `started` event carries `queryCategory`, so a console that stops recording a category can drop the successful queries of it that it kept. A visible command, and a query of no category (an automatic refresh or watcher), carries none. - `execution_policy::query_category()` gives the running request's category, and `reports_queries()` checks it against `consoleQueries`. - `console-queries-v1.json` lists every category in `queryCategories`, which hosts read to check their own names; a test matches the list against the enum, so it fails to compile when a category is added and the list is not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
#2025 要求在 Version Control 设置里提供开关,按类别省略 Git 控制台里的内部查询,并调整显示方式;所有开关的初始状态和 IntelliJ IDEA 的控制台一致。本 PR 是 Core 部分:按类别决定记不记录查询,
git.consolePresentation接受显示选项。桌面端的设置页和控制台在 1lck/Lithe-IDEA#2029 里,它把PINNED_CORE_REVISION升到本分支后关闭 #2025。PR 类型 / Type
改动说明 / What changes
背景 / Why
原来只有一个布尔开关
gitExecution.reportQueries:打开后,除background来源以外的所有内部只读查询都进入控制台。用户只能全开或全关,打开时 diff、日志浏览、注解、面板列表这些高频读取会挤满控制台,还会占掉控制台的 200 条记录。IDEA 的控制台不显示任何只读查询(silent handler),只显示用户执行的命令。本 PR 把开关拆成 9 个查询类别,默认一个都不记录,与 IDEA 一致;控制台不记录的类别根本不产生执行事件,所以不占记录容量。另外加了 4 个显示选项,默认值同样是 IDEA 的显示方式。
改动 / Changes
查询类别(
rust/crates/git/src/console/types.rs、新文件console/category.rs)QueryCategory(camelCase 序列化),共 9 类:referencesreloaddiffRefreshdiffloglogPathFilterannotatepanelscheckscategory::of_command(command)按请求命令推出类别:diff:git.diff、git.comparison、git.planDiffBlocks;log:git.history*、git.references、git.referenceTree、git.graphProjection、git.tags、git.commit、git.commitFiles、git.changedFileGroups;annotate:git.blame、git.lineHistory;panels:git.worktrees、git.stashes、git.remotes、git.remoteUrl、git.pullRequestContext、git.untrackedDirectory、git.repositorySetup、git.executionInspect;git.*都算checks;None),它们的查询不会被记录。执行选项(
execution_policy.rs、runtime/dispatcher.rs)GitExecutionOptions:report_queries(reportQueries)。结构体是deny_unknown_fields,旧桌面端继续发reportQueries会直接报错,所以桌面端必须和本 PR 一起升级。console_queries: Vec<QueryCategory>(consoleQueries):控制台记录哪些类别,默认空,即 IDEA 的行为。query_category: Option<QueryCategory>(queryCategory):命令本身分不出类别时由宿主指定,例如操作后的 reload、保存后的 diff 刷新、后台的引用读取。command_category:#[serde(skip)],不从请求读取,由调度器调用for_command(&parsed.command)填入。execution_policy::reports_queries():先取宿主指定的queryCategory;没有时,非background来源取命令的类别;再看consoleQueries是否包含它。background请求只有宿主指定了类别才会被记录,自动刷新和 watcher 仍然不进控制台。execution_events::Invocation::reported改用reports_queries();started事件里的query: true语义不变。显示选项(
console/types.rs、console/mod.rs、command.rs、output.rs)git.consolePresentation请求新增display(Display,deny_unknown_fields),4 个字段默认都是false,即 IDEA 的显示方式:true时foldShortQueriesshowCompletedWithoutOutputcompletedWithoutOutput提示;默认不显示,IDEA 在没有输出的命令后不打印任何内容。waitingForOutput、fetchUnchanged不受影响hideTemporaryConfig-c配置,而不是折叠;操作自己参数里的-c照旧原位折叠hideRepositoryrepositoryLabel为空,搜索也不再匹配仓库路径display时completedWithoutOutput不再出现(以前总会出现)。原来依赖它的夹具用例改为显式传showCompletedWithoutOutput: true。折叠规则(
console/output.rs、console/command.rs、新文件console/deletion.rs)progress片段,成功查询的输出超过 10 行才合成一个query片段;10 行以内照常显示。foldShortQueries让成功查询的短输出也折叠。失败的记录什么都不折叠。-c配置、进度和查询输出都完整显示,与显示选项无关,让用户看清删掉了什么。hideTemporaryConfig对删除类命令仍然生效,因为那是用户明确选的省略,不是折叠。--之前的选项):rm、clean(含试运行clean -n);带-d/-D/--delete的branch、tag、update-ref、symbolic-ref;带-d/--delete/--prune或空源 refspec(:refs/heads/topic)的push;带-p/--prune/-P/--prune-tags的fetch、pull;remote remove/rm/prune和remote update --prune;带--unset、--unset-all、--remove-section、unset、remove-section的config;stash drop/clear/pop;worktree remove/prune。reset、checkout --这类回退不算删除。 夹具console-presentation-v1.json的deletions表逐条固定这份清单。失败的未记录查询仍然报告(
execution_events.rs、execution_policy.rs)background请求里失败(出错,或者退出码不是查询本身的回答)时,Core 在它结束时一次发出started(query: true)、stderr 行和finished,控制台能看到失败的命令、诊断和退出码;不保留 stdout,请求也不再需要failureRecord。取消的查询不报,background请求里的未记录查询失败了也不报。started 事件带类别(
execution_events.rs、execution_policy.rs)started事件带queryCategory,宿主停止记录某个类别时可以移除它已保存的该类成功查询;可见命令和没有类别的查询不带。execution_policy::query_category()给出当前请求的查询类别,reports_queries()拿它对照consoleQueries。契约与夹具
rust/contracts/rust-core-api.md:gitExecution的字段从reportQueries改为consoleQueries和queryCategory;background规则,以及未记录的类别不产生事件、不占控制台容量;git.consolePresentation的display字段和默认值。rust/fixtures/git/console-queries-v1.json:queryCategories列出全部 9 个类别(宿主读取它核对自己的类别名,gitExecution拒绝其他名字),命令到类别的映射,以及 8 个“是否记录”的用例(IDEA 默认、记录的类别、其他类别、未列出的命令算 checks、后台刷新、指定类别覆盖命令类别、后台指定类别、Git 以外的命令)。rust/fixtures/git/console-presentation-v1.json新增用例:默认不显示无输出提示、10 行以内的查询输出和进度默认可见、超过 10 行才折叠、foldShortQueries折叠短输出、隐藏临时配置但保留操作自己的配置、隐藏仓库后标签为空且不参与搜索;新增deletions表,逐条验证删除类命令的配置、进度和输出都不折叠,以及reset、checkout --不算删除。started事件的queryCategory。测试
execution_policy::tests::console_queries_follow_the_named_or_command_category:逐条校验夹具里的映射和用例,作用域结束后恢复为不记录;queryCategories用穷尽match对照枚举,新增类别而清单没跟上时编译失败。execution_events的reported_queries_are_marked_apart_from_visible_commands改为用consoleQueries: ["log"]和git.history,并校验查询的started带queryCategory: "log"、可见命令不带;新增unrecorded_queries_report_only_a_real_failure:失败的未记录查询一次报出 started、stderr、finished,取消的查询和后台请求不报。core/src/tests/git_workspace_commit.rs的git_internal_queries_report_events_only_when_the_request_asks:真实仓库上验证未记录的类别、其他类别、后台刷新都不产生事件,记录的类别每条started都有对应的finished。不在本 PR 范围内 / Out of scope
queryCategory、控制台按选项呈现,在 feat(desktop): Git 控制台按类别省略内部查询并调整显示方式,初始状态与 IntelliJ IDEA 一致 1lck/Lithe-IDEA#2029 中。PINNED_CORE_REVISION升到 main 上的 commit。类型专属:feat
多平台对齐
范围检查 / Scope checks
git-history条目,由桌面端 PR 更新。shared/i18n/。generate-log-events.mjs --check通过。reports_queries()只在启动查询时做一次最多 9 项的线性查找。默认不记录查询,控制台的事件比以前更少。rust-core-api,没有改shared/plugins/的插件契约、能力版本或插件函数协议。reportQueries及其判断已删除,没有留下兼容分支。验证 / Verification
本机为 Apple M4、macOS arm64,在 5aae479 上运行。
cargo fmt --manifest-path rust/Cargo.toml --all -- --checkscripts/rust-core/verify-rust-core-comments.sh git、… corenode scripts/rust-core/verify-platform-tests.mjsnode scripts/logging/generate-log-events.mjs --checknode shared/plugins/scripts/verify-docs.mjscargo clippy --locked … -p lithe-git -p lithe-core --all-targets -- -D warnings--target x86_64-pc-windows-msvccargo test --locked … -p lithe-git -p lithe-coredesktop-go.sh test ./internal/core ./internal/settingswindow ./internal/workbench未能执行的检查和原因:
cargo test在本机沙盒里会因lithe-remote的测试失败(与本 PR 无关),所以只跑了改动涉及的lithe-git、lithe-core;完整工作区由 CI 覆盖。提交前确认 / Final checks
main创建,并已用 merge 合入最新main(ad148ec),目标分支main