feat(git): AI 生成提交信息(Ctrl+G、多行提交框、可固定生成模型)
移植 PR #642(refs/tmp/pr642 → 当前 dev 重写,不机械解冲突)。 复用(与 dev clean 或纯逻辑无冲突面): - src/commit-message.ts 纯逻辑模块原样取用:prompt 契约、provider/model 路由 词法、reasoning effort 取最低档、宽容的 provider/model 目录读取、建议文本清理。 - host 半边(git.suggest-message / git.commit-model / git.models 三条路由 + pinned / 会话 / agent-default-model 三级路由解析)按 dev 现状重贴:ctx.llm、 agentDefaultModel、git.status/diff、sessionId 参数名逐条对照本机 0.2.0-rc.1 核实。 - 设置缝复用 dev 已有的 SidebarSettingsRenderProps + settings.render(PR 侧写在 同一接口上,零适配)。 - 三个新 spec 原样取用,只有 git-suggest 的 harness 改了「visible 默认 true」—— dev 的共享 git-status store 只在可见时订阅,不可见时 snapshot 恒 null, commit bar 根本不渲染(PR 作者当年跑绿的是本机未提交状态)。 丢弃 / 按 dev 重写: - PR 的 GitLens 客户端半边基于 #471 重写前的 GitLens:提交栏在 dev 已是 primitives Input + commitBar/commitRow/commitInput,且 Ctrl/Cmd+Enter 提交 已存在(重复实现)。现按 dev 的 .commitRow 结构重做多行 textarea + 自动增高, 保留既有快捷键,并追加 Ctrl/Cmd+G。 - 六个 Icon*16 具名导入在 0.2.0-rc.1 一个不剩(§3.1 第 2 条:缺导出 = render 期 Element type is invalid),改用 IconSparkleRegular size={14}。 - CSS 类名跟随 dev 的 commit* 前缀(PR 的 gitCommit*/gitSuggest*/gitError 在 dev 已不存在;错误行改走 dev 的 Notice,不新增自绘错误样式)。 - 消息 source kind 用生产者自有值 plugin:dsh-better-sidebar:0.1.7 起 kind:'plugin' 会被 format v4 硬拒。 - locales:dev 已删 commitError 锚点,且 19 份词典与 locales.ts 必须键集相等, 故按各文件在 commit 行后逐份插入,不整份取 PR 侧。 验收:pnpm typecheck 0;pnpm exec vitest run --maxWorkers=3 全绿(163 files / 1836 tests);新增 spec 单独跑绿;真机挂载冒烟未跑(见报告)。 Refs #642 Co-authored-by: rainmanhhh <13862623+rainmanhhh@users.noreply.github.com>
This commit is contained in:
1 parent
3bd5e1947b
commit
6615f63602
34 files changed
+2177
-43
No files matched your search
@@ -208,7 +208,259 @@
|
||||
background: var(--dsw-alias-bg-base);
|
||||
}
|
||||
.commitRow { display: flex; align-items: center; gap: 6px; }
|
||||
.commitInput { flex: 1; min-width: 0; }
|
||||
|
||||
/* The commit-message box and its busy overlay: the input keeps its own
|
||||
flex sizing through a wrapper so the overlay can sit exactly on top of it
|
||||
while the host generates or commits. */
|
||||
.commitInputWrap {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* The multiline commit box: a native textarea styled to match the primitives
|
||||
Input (layer fill, hairline border, brand focus ring). Flex sizing keeps it
|
||||
inside the row — `width: 100%` would overflow its own padding/border. */
|
||||
.commitInput {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
box-sizing: border-box;
|
||||
/* One line by default; GitLens grows it with the text (18px per line,
|
||||
6px vertical padding, six lines before it scrolls). The bounds here are
|
||||
the stylesheet's half of that contract. */
|
||||
min-height: 30px;
|
||||
max-height: 120px;
|
||||
padding: 6px 8px;
|
||||
border: 0.5px solid var(--dsw-alias-border-l4);
|
||||
border-radius: 8px;
|
||||
background: var(--dsw-alias-bg-layer-1);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
font: var(--dsw-font-s-13);
|
||||
line-height: 18px;
|
||||
resize: none;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.commitInput:focus {
|
||||
outline: none;
|
||||
border-color: var(--dsw-alias-brand-primary);
|
||||
}
|
||||
|
||||
.commitInput::placeholder {
|
||||
color: var(--dsw-alias-label-dimmed);
|
||||
}
|
||||
|
||||
.commitInput:disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* Busy text in the input's place: the running-status sweep used by the side
|
||||
chat (gradient text scrolled by background-position). The real placeholder
|
||||
is cleared while busy, so the two never overlap. */
|
||||
.commitBusyText {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
/* Matches the textarea's own padding so the label sits where the text would. */
|
||||
padding: 6px 8px;
|
||||
pointer-events: none;
|
||||
font: var(--dsw-font-xxs-12);
|
||||
background-image: linear-gradient(
|
||||
90deg,
|
||||
var(--dsw-alias-label-tertiary) 0%,
|
||||
var(--dsw-alias-label-primary) 50%,
|
||||
var(--dsw-alias-label-tertiary) 100%
|
||||
);
|
||||
background-size: 200% 100%;
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
color: transparent;
|
||||
animation: commitSweep 2.6s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes commitSweep {
|
||||
from { background-position: 200% 0; }
|
||||
to { background-position: -200% 0; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.commitBusyText { animation: none; }
|
||||
}
|
||||
|
||||
/* The AI commit-message button: a quiet square secondary button beside the
|
||||
input. While the host streams a suggestion it pulses. */
|
||||
.suggestButton {
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
padding: 0;
|
||||
border: 1px solid var(--dsw-alias-border-l1);
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: var(--dsw-alias-label-secondary);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.suggestButton:hover:not(:disabled) {
|
||||
background: var(--dsw-alias-interactive-bg-hover);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
}
|
||||
|
||||
.suggestButton:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.suggestBusy {
|
||||
color: var(--dsw-alias-interactive-bg-hover-accent);
|
||||
animation: commitSuggestPulse 1.2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes commitSuggestPulse {
|
||||
50% { opacity: 0.45; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.suggestBusy { animation: none; }
|
||||
}
|
||||
|
||||
/* The Git card's pinned-model setting (rendered through settings.render). */
|
||||
.commitModel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.commitModelTitle {
|
||||
font: var(--dsw-font-xxs-strong-12);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
}
|
||||
|
||||
.commitModelDesc {
|
||||
font: var(--dsw-font-xxs-12);
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
}
|
||||
|
||||
/* Follow-the-conversation switch: a native checkbox (real semantics and
|
||||
focus) beside its label, matching the side card's switch rows. */
|
||||
.commitModelRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.commitModelSwitch {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font: var(--dsw-font-xxs-12);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.commitModelSwitch input {
|
||||
accent-color: var(--dsw-alias-interactive-bg-hover-accent);
|
||||
}
|
||||
|
||||
/* The searchable route box: the wrapper span the Menu renders around the
|
||||
input. Its default `.root` is `display: inline-flex`, which shrinks to the
|
||||
input's intrinsic width — overridden here so the box fills the panel. The
|
||||
candidate list itself is portalled to <body> (see the component), so its
|
||||
width is pinned to the input at runtime. */
|
||||
.commitModelMenuRoot {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.commitModelBox {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* The stored route, shown on its own line: the search box below stays an empty
|
||||
filter, so reopening the picker lists every candidate instead of filtering
|
||||
down to the model that is already selected. */
|
||||
.commitModelCurrent {
|
||||
margin-bottom: 4px;
|
||||
font: var(--dsw-font-xxs-strong-12);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.commitModelInput {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
height: 26px;
|
||||
padding: 0 6px;
|
||||
border: 1px solid var(--dsw-alias-border-l2);
|
||||
border-radius: 6px;
|
||||
background: var(--dsw-alias-bg-layer-2);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
font: var(--dsw-font-xxs-12);
|
||||
}
|
||||
|
||||
.commitModelInput:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* One candidate row inside the portalled Menu: the route text plus its source
|
||||
badge. The menu shell (background, hover, radius) is the primitive's. */
|
||||
.commitModelOption {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
/* border-box, or `width: 100%` plus the horizontal padding overflows its
|
||||
label box by 12px — which the Menu's `.itemLabel{overflow:hidden}` then
|
||||
slices off the trailing badge. */
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 4px 6px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: var(--dsw-alias-label-primary);
|
||||
font: var(--dsw-font-xxs-12);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.commitModelOption:hover {
|
||||
background: var(--dsw-alias-interactive-bg-hover);
|
||||
}
|
||||
|
||||
/* `flex-basis: auto` (NOT `1`, which is basis 0) matters here: the menu card
|
||||
is sized shrink-to-fit, and a zero basis makes that intrinsic width ignore
|
||||
the route text — the card then converges on the input's width alone and the
|
||||
trailing badge is clipped by the Menu's own `.itemLabel{overflow:hidden}`.
|
||||
With auto the text contributes its real width, and `min-width: 0` still lets
|
||||
it ellipsize when the card hits the Menu's max-width. */
|
||||
.commitModelOptionText {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* The badge keeps its full width under any shrink pressure. */
|
||||
.commitModelOptionNote {
|
||||
flex: 0 0 auto;
|
||||
min-width: max-content;
|
||||
white-space: nowrap;
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
}
|
||||
|
||||
.commitModelHint {
|
||||
font: var(--dsw-font-xxs-12);
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
}
|
||||
|
||||
/* ── History ───────────────────────────────────────────────────────────── */
|
||||
|
||||
|
||||
Reference in new issue
Block a user