From 60ad1db12e4aaf5c991d603aa3f97a92ae03691c Mon Sep 17 00:00:00 2001 From: Yuri Yaryshev Date: Wed, 14 Oct 2026 18:55:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=B0=D0=BD=D1=82:=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=BB=D0=BE=D1=81=D0=B0=D1=85,=20id?= =?UTF-8?q?=20=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B0=20=D1=81=D0=BD=D0=B8?= =?UTF-8?q?=D0=B7=D1=83,=20=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D0=BC?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B8=20=D0=BC=D0=B5=D0=B6=D0=B4=D1=83=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=85=D0=B0=D0=BC=D0=B8=20=D1=81=D0=B2=D1=91=D1=80?= =?UTF-8?q?=D0=BD=D1=83=D1=82=D1=8B=D1=85=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF?= =?UTF-8?q?;=20=D1=82=D0=B5=D1=81=D1=82=D1=8B;=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- docs/proposed/deviations.md | 1 + packages/khbuild_process_viz/src/gantt.ts | 86 ++++++++++++++------ packages/khbuild_process_viz/src/viz.test.ts | 17 ++++ 3 files changed, 81 insertions(+), 23 deletions(-) diff --git a/docs/proposed/deviations.md b/docs/proposed/deviations.md index d1218cb..dfae19e 100644 --- a/docs/proposed/deviations.md +++ b/docs/proposed/deviations.md @@ -24,3 +24,4 @@ 20. **Включение/выключение проектов (14.10.2026)**: флаг `assistant_project.is_enabled` (уже был) теперь действует во всех шагах. Шаг 2 и список менеджеров берут только включённые проекты; в шаге 4 агенту в «Ограничениях среды» перечисляются ОТКЛЮЧЁННЫЕ проекты менеджера: не обсуждать, не напоминать, не писать (id таких проектов исключаются из `allowedJobIds`), на сообщения о них отвечать, что ассистент по проекту отключён. Переключение: `update assistant_project set is_enabled = false where jt_job_id = '...'` (Supabase Studio); вступает в силу со следующего запуска агента. Тест `agents.int.test.ts` («отключённый проект»). 21. **Сообщения от любых участников чата (14.10.2026)**: в чате менеджера (`construction_manager.slack_channel_id`) принимаются сообщения всех участников канала и обрабатываются как сообщения менеджера; отправитель сохраняется в `slack_message_log.sender_slack_user_id` (миграция 008; для файлов из папки Drive - null). Каналы из `slack.channelIds` без закреплённого менеджера по-прежнему определяют менеджера по автору. В промт шага 4 добавлена строка про других участников чата. Причина: аудио Arthur Atanoff в чате Zachary Gange не обрабатывалось, т.к. отправитель не совпадал с `slack_user_id` менеджера. 22. **Права на таблицы (14.10.2026)**: после подключения Mathesar все таблицы public стали принадлежать роли mathesar_process, и миграция 008 под khb_app падала (`must be owner of table`). Роль khb_app включена в mathesar_process (`grant mathesar_process to khb_app`), владельцы не менялись. Если Mathesar снова сменит владельцев - так же работает; при отзыве членства деплой с миграциями упадёт. +23. **Гант процесса: формат по образцу SlideFormat (14.10.2026)**: на полосах вместо дат - название работы (внутри полосы белым, если помещается, иначе над полосой цветом этапа); id шага (CP-x, S-x) мелко справа снизу под полосой (у ромба вехи - справа от него); строка шага стала выше (36 px); ромбы вех чёрные; стрелки зависимостей тёмные с вертикалью от конца предшественника. Свёрнутая группа сохраняет зависимости между вехами: стрелки идут между ромбами сводных полос (для шагов свёрнутых групп, не являющихся вехами, стрелки не рисуются). Тесты в `viz.test.ts`. diff --git a/packages/khbuild_process_viz/src/gantt.ts b/packages/khbuild_process_viz/src/gantt.ts index 4ba2121..4af58ba 100644 --- a/packages/khbuild_process_viz/src/gantt.ts +++ b/packages/khbuild_process_viz/src/gantt.ts @@ -21,7 +21,9 @@ export const GANTT_DEFAULT_PX = 5; export const GANTT_MIN_PX = 0.5; export const GANTT_MAX_PX = 40; -const ROW = 24; +const ROW = 36; // строка шага: подпись над полосой, полоса, id справа снизу +const BAR_CY = 21; // центр полосы от верха строки +const BAR_H = 14; const HEAD = 76; const GROUP_BAR_H = 14; // высота сводной полосы const GROUP_PAD = 8; // отступ сверху и снизу в строке группы @@ -148,7 +150,7 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt if (!g.collapsed) { for (const { row } of g.rows) { rowTop.set(row.id, y); - yOf.set(row.id, y + ROW / 2); + yOf.set(row.id, y + BAR_CY); y += ROW; } } @@ -157,7 +159,11 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt const height = y + 40; const days = Math.ceil((schedule.maxDay + 10) / 10) * 10; // подписи вех могут выступать за правый край оси - const labelRight = Math.max(0, ...groups.flatMap((g) => g.labels.map((l) => l.x + (l.text.length * CHAR_W) / 2))); + const labelRight = Math.max( + 0, + ...groups.flatMap((g) => g.labels.map((l) => l.x + (l.text.length * CHAR_W) / 2)), + ...groups.flatMap((g) => (g.collapsed ? [] : g.rows.map(({ row, t }) => x(Math.max(t.start, t.end)) + 14 + (row.actionName ?? row.description ?? "").length * CHAR_W))), + ); const width = Math.round(Math.max(GANTT_LEFT + days * px + 30, labelRight + 16)); const out: string[] = []; @@ -188,24 +194,36 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt } } - // Зависимости под полосами (только между видимыми строками) + // Зависимости под полосами. Если группа свёрнута, от неё остаются вехи: стрелки идут между ромбами сводных полос. + const groupOf = new Map(); + for (const g of groups) for (const { row } of g.rows) groupOf.set(row.id, g); + const anchor = (id: string): { xs: number; xe: number; y: number } | null => { + const tm = schedule.timings.get(id); + const g = groupOf.get(id); + if (!tm || !g) return null; + if (!g.collapsed) { + const yy = yOf.get(id); + return yy === undefined ? null : { xs: x(tm.start), xe: x(tm.end), y: yy }; + } + const m = g.summary.milestones.find((mm) => mm.row.id === id); + return m ? { xs: x(m.day), xe: x(m.day), y: g.top + GROUP_PAD + g.levels * LABEL_STEP + GROUP_BAR_H / 2 } : null; + }; if (opts.deps !== false) { const arrows: string[] = []; for (const g of groups) { - for (const { row, t } of g.rows) { + for (const { row } of g.rows) { for (const dep of row.dependsOn) { - const dt = schedule.timings.get(dep); - const y1 = yOf.get(dep); - const y2 = yOf.get(row.id); - if (!dt || y1 === undefined || y2 === undefined) continue; - const x1 = x(dt.end); - const x2 = x(t.start); - const xm = Math.min(x2 - 4, Math.max(x1 + 4, (x1 + x2) / 2)); - arrows.push(``); + const from = anchor(dep); + const to = anchor(row.id); + if (!from || !to) continue; + const x1 = from.xe; + const x2 = to.xs; + const d = x2 >= x1 ? `M${x1} ${from.y} V${to.y} H${x2}` : `M${x1} ${from.y} H${x1 + 6} V${to.y} H${x2}`; + arrows.push(``); } } } - out.push(`${arrows.join("")}`); + out.push(`${arrows.join("")}`); } // Строки раскрытых групп @@ -214,7 +232,7 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt const c = color(g.stage); for (const { row, t } of g.rows) { const top = rowTop.get(row.id)!; - const cy = top + ROW / 2; + const cy = top + BAR_CY; const warn = conflicts.get(row.id); const tip = tooltip([ `${row.id} - ${row.actionName ?? ""}${row.isMilestone ? " (веха)" : ""}`, @@ -228,24 +246,46 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt row.questions ? `Вопрос: ${row.questions}` : null, ]); const ms = row.isMilestone; + const name = row.actionName ?? row.description ?? ""; out.push(`${tip}`); out.push(`${esc(row.id)}`); - out.push(`${esc(truncate(row.actionName ?? row.description ?? "", 52))}`); + out.push(`${esc(truncate(name, 52))}`); if (row.questions) out.push(`${esc(row.questions)}`); const stroke = warn ? "#d32f2f" : c.stroke; const dash = t.approx ? ' stroke-dasharray="4 2"' : ""; + const textW = name.length * CHAR_W; + const idText = (tx: number, anchor: "start" | "end") => + out.push(`${esc(row.id)}`); if (t.kind === "recurring") { - out.push(``); + const w = Math.max(2, (t.end - t.start) * px); + out.push(``); + out.push(`${esc(name)}`); + idText(x(t.end), "end"); } else { - if (t.end > t.start) { - out.push(``); + const hasBar = t.end > t.start; + const w = Math.max(3, (t.end - t.start) * px); + const solid = !t.approx; + if (hasBar) { + out.push(``); + if (name) { + if (textW + 8 <= w) out.push(`${esc(name)}`); + else { + out.push(`${esc(name)}`); + } + } } if (ms || t.kind === "milestone") { const px0 = x(t.end); - out.push(``); - out.push(`день ${t.end}`); + out.push(``); + if (!hasBar && name) { + out.push(`${esc(name)}`); + } + idText(px0 + 10, "start"); } else { - out.push(`${t.start}–${t.end}`); + if (!hasBar && name) { + out.push(`${esc(name)}`); + } + idText(hasBar ? x(t.end) : x(t.end) + 6, hasBar ? "end" : "start"); } } out.push(""); @@ -302,7 +342,7 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt }) .join(""); const defs = - `` + + `` + `` + hatches + // запасной шаблон для легенды, если этапов нет diff --git a/packages/khbuild_process_viz/src/viz.test.ts b/packages/khbuild_process_viz/src/viz.test.ts index 7d9ef1f..b26a0d2 100644 --- a/packages/khbuild_process_viz/src/viz.test.ts +++ b/packages/khbuild_process_viz/src/viz.test.ts @@ -165,6 +165,23 @@ describe("Гант: группы, вехи, свёртывание, масшта expect(shut.match(/]*height="(\d+)"/)![1]!).not.toBe(open.match(/]*height="(\d+)"/)![1]!); }); + it("свёрнутая группа: зависимости между вехами сохраняются (стрелка от ромба вехи до зависимой строки)", () => { + const arrows = (svg: string) => svg.split('marker-end="url(#arr)"').length - 1; + const shut = renderGantt(ms, sch, { collapsed: ["A"] }); + expect(arrows(shut)).toBeGreaterThanOrEqual(1); // X-9 (группа A свёрнута) -> S-3 + expect(arrows(renderGantt(ms, sch, { collapsed: ["A", "B"] }))).toBe(0); // S-3 - не веха, к нему стрелки нет + expect(arrows(renderGantt(ms, sch, {}))).toBeGreaterThan(arrows(shut)); + }); + + it("подпись полосы - название работы (внутри полосы или над ней), id справа снизу, без дат", () => { + const svg = renderGantt(ms, sch, { px: 20 }); + expect(svg).toContain('fill="#fff">Работа'); // название внутри длинной полосы + expect(svg).toMatch(/text-anchor="end" font-size="9"[^>]*>S-1<[/]text>/); // id справа снизу + expect(svg).not.toMatch(/>[0-9]+–[0-9]+<[/]text>/); // подписей-интервалов дат у полос нет + const narrow = renderGantt(ms, sch, { px: 0.5 }); + expect(narrow).toMatch(/font-weight="600" fill="#[0-9a-f]{6}">Работа<[/]text>/); // не влезло - подпись над полосой + }); + it("масштаб времени меняет только ось: ширина растёт, шрифты и высота остаются", () => { const a = renderGantt(ms, sch, { px: 5 }); const b = renderGantt(ms, sch, { px: 20 });