Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23d7a3d1c8 | ||
|
|
ab23a82b1d | ||
|
|
069f271b1c | ||
|
|
e17a333d3f | ||
|
|
5dfc78e85e | ||
|
|
462442667e | ||
|
|
c69120f484 | ||
|
|
7b928d5488 | ||
|
|
2fdc704bbb | ||
|
|
3513fa04fb |
No files matched your search
@@ -0,0 +1,510 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>T3 Code — Sidebar v2 Beta Plan</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #000;
|
||||
--fg: #fff;
|
||||
--muted: #9ca3af;
|
||||
--dim: #6b7280;
|
||||
--surface: #0d0d0f;
|
||||
--surface2: #16161a;
|
||||
--border: #26262c;
|
||||
--amber: #f59e0b;
|
||||
--sky: #38bdf8;
|
||||
--indigo: #818cf8;
|
||||
--violet: #a78bfa;
|
||||
--emerald: #34d399;
|
||||
--red: #f87171;
|
||||
--teal: #2dd4bf;
|
||||
--mono: ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||
}
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body {
|
||||
background: var(--bg);
|
||||
color: var(--fg);
|
||||
font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
.wrap { max-width: 960px; margin: 0 auto; padding: 56px 24px 120px; }
|
||||
h1 { font-size: 32px; line-height: 1.2; letter-spacing: -0.02em; }
|
||||
h2 { font-size: 21px; letter-spacing: -0.01em; margin: 72px 0 8px; }
|
||||
h2 .num { color: var(--dim); font-weight: 500; margin-right: 10px; }
|
||||
h3 { font-size: 15px; margin: 28px 0 8px; }
|
||||
p { color: var(--muted); margin: 10px 0; max-width: 72ch; }
|
||||
p strong, li strong { color: var(--fg); font-weight: 600; }
|
||||
a { color: var(--sky); text-decoration: none; }
|
||||
a:hover { text-decoration: underline; }
|
||||
code {
|
||||
font-family: var(--mono); font-size: 12.5px;
|
||||
background: var(--surface2); border: 1px solid var(--border);
|
||||
padding: 1px 5px; border-radius: 4px; color: #d4d4d8;
|
||||
}
|
||||
pre {
|
||||
font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
|
||||
background: var(--surface); border: 1px solid var(--border);
|
||||
border-radius: 10px; padding: 16px 18px; overflow-x: auto;
|
||||
color: #d4d4d8; margin: 14px 0;
|
||||
}
|
||||
pre .c { color: var(--dim); }
|
||||
pre .k { color: var(--violet); }
|
||||
pre .s { color: var(--emerald); }
|
||||
ul, ol { margin: 10px 0 10px 22px; color: var(--muted); max-width: 72ch; }
|
||||
li { margin: 6px 0; }
|
||||
li::marker { color: var(--dim); }
|
||||
.lede { font-size: 17px; color: var(--muted); margin-top: 14px; }
|
||||
.meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
|
||||
.chip {
|
||||
font-size: 12px; padding: 3px 10px; border-radius: 999px;
|
||||
border: 1px solid var(--border); color: var(--muted); background: var(--surface);
|
||||
}
|
||||
.chip.hot { border-color: rgba(52,211,153,.4); color: var(--emerald); }
|
||||
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 18px 0; }
|
||||
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }
|
||||
.panel {
|
||||
background: var(--surface); border: 1px solid var(--border);
|
||||
border-radius: 12px; padding: 18px 20px;
|
||||
}
|
||||
.panel h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); margin-bottom: 10px; }
|
||||
.panel ul { margin-left: 18px; font-size: 13.5px; }
|
||||
.kv { font-size: 13.5px; color: var(--muted); }
|
||||
.kv b { color: var(--fg); font-weight: 600; }
|
||||
.note {
|
||||
border-left: 3px solid var(--violet); background: rgba(167,139,250,.06);
|
||||
padding: 12px 16px; border-radius: 0 10px 10px 0; margin: 18px 0; color: var(--muted);
|
||||
font-size: 14px; max-width: 78ch;
|
||||
}
|
||||
.warn { border-left-color: var(--amber); background: rgba(245,158,11,.06); }
|
||||
|
||||
/* ————— sidebar mock ————— */
|
||||
.mockwrap { display: grid; grid-template-columns: 320px 1fr; gap: 28px; margin: 24px 0; align-items: start; }
|
||||
@media (max-width: 820px) { .mockwrap { grid-template-columns: 1fr; } }
|
||||
.sidebar {
|
||||
background: #0a0a0c; border: 1px solid var(--border); border-radius: 14px;
|
||||
overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.6);
|
||||
font-size: 12px;
|
||||
}
|
||||
.sb-top {
|
||||
display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--border);
|
||||
align-items: center;
|
||||
}
|
||||
.sb-search {
|
||||
flex: 1; display: flex; align-items: center; gap: 6px;
|
||||
background: var(--surface2); border: 1px solid var(--border); border-radius: 7px;
|
||||
padding: 5px 9px; color: var(--dim); font-size: 11.5px;
|
||||
}
|
||||
.sb-search kbd {
|
||||
margin-left: auto; font-family: var(--mono); font-size: 10px;
|
||||
border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; color: var(--dim);
|
||||
}
|
||||
.sb-new {
|
||||
width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border);
|
||||
background: var(--surface2); color: var(--muted); display: grid; place-items: center;
|
||||
font-size: 15px; cursor: default;
|
||||
}
|
||||
.rows { padding: 6px; display: flex; flex-direction: column; gap: 3px; }
|
||||
|
||||
.row {
|
||||
position: relative; border-radius: 8px; cursor: default;
|
||||
transition: background .12s;
|
||||
overflow: hidden;
|
||||
}
|
||||
.row:hover { background: rgba(255,255,255,.045); }
|
||||
.row .rail {
|
||||
position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 2px;
|
||||
}
|
||||
.rail.amber { background: var(--amber); }
|
||||
.rail.sky { background: var(--sky); animation: pulse 1.6s ease-in-out infinite; }
|
||||
.rail.red { background: var(--red); }
|
||||
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
|
||||
|
||||
.card { padding: 8px 10px 8px 14px; }
|
||||
.card .l1 { display: flex; align-items: center; gap: 8px; }
|
||||
.card .title { color: #d4d4d8; font-weight: 500; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.row.unread .card .title { color: var(--fg); font-weight: 650; }
|
||||
.fav {
|
||||
width: 15px; height: 15px; border-radius: 4px; flex: none;
|
||||
display: grid; place-items: center; font-size: 8px; font-weight: 700; letter-spacing: .02em;
|
||||
}
|
||||
.fav.t3 { background: rgba(167,139,250,.14); color: var(--violet); border: 1px solid rgba(167,139,250,.3); }
|
||||
.fav.fh { background: rgba(56,189,248,.12); color: #7dd3fc; border: 1px solid rgba(56,189,248,.3); }
|
||||
.slim .fav { width: 13px; height: 13px; font-size: 7px; }
|
||||
.card .diff { font-family: var(--mono); font-size: 10px; white-space: nowrap; }
|
||||
.diff .add { color: var(--emerald); } .diff .del { color: var(--red); }
|
||||
.card .time { margin-left: auto; color: var(--dim); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||
.card .time.wait { color: var(--amber); }
|
||||
.card .meta {
|
||||
margin-top: 3px; display: flex; align-items: center; gap: 8px;
|
||||
color: var(--dim); font-size: 10px; padding-left: 23px;
|
||||
white-space: nowrap; overflow: hidden;
|
||||
}
|
||||
.meta .st { font-weight: 650; font-size: 9.5px; letter-spacing: .02em; }
|
||||
.st.amber { color: var(--amber); } .st.sky { color: var(--sky); } .st.red { color: var(--red); }
|
||||
.branch { font-family: var(--mono); font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.model { font-family: var(--mono); font-size: 9.5px; display: inline-flex; align-items: center; gap: 3px; }
|
||||
.hx.cl { color: rgba(217,119,87,.75); font-size: 9px; }
|
||||
.hx.cx { color: rgba(255,255,255,.45); font-size: 9px; }
|
||||
.mach { font-size: 9.5px; color: var(--dim); display: inline-flex; align-items: center; gap: 3px; }
|
||||
|
||||
.slim { display: flex; align-items: center; gap: 7px; padding: 5px 10px; height: 27px; }
|
||||
.slim .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--dim); flex: none; }
|
||||
.slim .title { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.slim .pr { font-family: var(--mono); font-size: 9.5px; color: var(--violet); white-space: nowrap; }
|
||||
.slim .pr.open { color: var(--emerald); }
|
||||
.slim .time { margin-left: auto; color: var(--dim); font-size: 10px; flex: none; }
|
||||
|
||||
.settle-btn {
|
||||
position: absolute; right: 8px; top: 8px; opacity: 0;
|
||||
border: 1px solid var(--border); background: var(--surface2); color: var(--muted);
|
||||
border-radius: 6px; font-size: 10px; padding: 2px 8px; cursor: pointer;
|
||||
transition: opacity .12s; font-family: inherit;
|
||||
}
|
||||
.row:hover .settle-btn { opacity: 1; }
|
||||
.settle-btn:hover { color: var(--fg); border-color: var(--dim); }
|
||||
.row.settling { transition: opacity .35s, max-height .35s ease; max-height: 0 !important; opacity: 0; }
|
||||
|
||||
.mock-legend h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); margin: 18px 0 8px; }
|
||||
.mock-legend .kv { display: block; margin: 7px 0; }
|
||||
.lg-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; vertical-align: baseline; }
|
||||
.toast {
|
||||
margin: 10px 6px 8px; border: 1px solid rgba(45,212,191,.35); background: rgba(45,212,191,.07);
|
||||
border-radius: 8px; padding: 8px 10px; font-size: 11px; color: var(--muted);
|
||||
display: none; align-items: center; gap: 8px;
|
||||
}
|
||||
.toast.show { display: flex; }
|
||||
.toast b { color: var(--teal); font-weight: 600; }
|
||||
.toast button {
|
||||
margin-left: auto; border: 1px solid rgba(45,212,191,.4); background: transparent;
|
||||
color: var(--teal); border-radius: 5px; font-size: 10px; padding: 2px 8px; cursor: pointer;
|
||||
}
|
||||
.reset { font-size: 12px; color: var(--dim); cursor: pointer; background: none; border: none; font-family: inherit; }
|
||||
.reset:hover { color: var(--muted); }
|
||||
|
||||
table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 13.5px; }
|
||||
th { text-align: left; color: var(--dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 12px; border-bottom: 1px solid var(--border); }
|
||||
td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--muted); vertical-align: top; }
|
||||
td:first-child { color: var(--fg); white-space: nowrap; }
|
||||
.phase { border: 1px solid var(--border); border-radius: 12px; margin: 16px 0; overflow: hidden; }
|
||||
.phase-h {
|
||||
display: flex; align-items: baseline; gap: 12px; padding: 14px 20px;
|
||||
background: var(--surface); border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.phase-h .n {
|
||||
font-family: var(--mono); font-size: 12px; color: var(--bg); background: var(--fg);
|
||||
border-radius: 6px; padding: 1px 8px; font-weight: 700;
|
||||
}
|
||||
.phase-h .t { font-weight: 600; font-size: 15px; }
|
||||
.phase-h .d { margin-left: auto; font-size: 12px; color: var(--dim); }
|
||||
.phase-b { padding: 6px 20px 16px; }
|
||||
.phase-b ul { font-size: 13.5px; }
|
||||
svg text { font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
|
||||
svg .mono { font-family: var(--mono); }
|
||||
.foot { margin-top: 80px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--dim); font-size: 12.5px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
|
||||
<h1>Sidebar v2 — beta plan</h1>
|
||||
<p class="lede">One flat, recency-sorted thread list where row size is earned by state — and “settled” becomes a real lifecycle stage users control. Familiar mechanics only: nothing here requires learning a new gesture.</p>
|
||||
<div class="meta">
|
||||
<span class="chip hot">beta · toggle in settings</span>
|
||||
<span class="chip">plan: <code style="border:none;background:none;padding:0">.plans/21-sidebar-v2-beta.md</code></span>
|
||||
<span class="chip"><a href="https://hsyscdqldmk5.postplan.dev/" target="_blank" rel="noopener noreferrer">original 5 concepts ↗</a></span>
|
||||
</div>
|
||||
|
||||
<h2><span class="num">01</span>What we're building</h2>
|
||||
<p>The hybrid the concepts page predicted, filtered through “meet users where they are”: <strong>concept 4's adaptive density</strong> as the skeleton, <strong>concept 1's card layout</strong> (trimmed to two structured lines — no generated text) for active rows, and <strong>concept 3 reduced to a sort rule</strong> (approval-blocked threads pin above the recency flow — no tiers, no inline approve).</p>
|
||||
<div class="cols">
|
||||
<div class="panel">
|
||||
<h4>Changes</h4>
|
||||
<ul>
|
||||
<li><strong>Flat recency list</strong> — project group headers gone; project becomes a chip. This is how Claude Code, Codex, and Cursor already present sessions.</li>
|
||||
<li><strong>Settled lifecycle state</strong> — explicit, user- or rule-triggered. Settled rows collapse to slim one-liners (≈ today's density).</li>
|
||||
<li><strong>Four states, three colors</strong> — Needs approval (amber, pinned with wait time), Working (sky, pulsing), <strong>Ready</strong> (no color, no label — the normal resting state; bold title until visited), Failed (red).</li>
|
||||
<li><strong>Structured metadata only</strong> — the card's second line is status word · branch · harness + model · machine. No summaries or free text to generate; every field is data the shell already carries.</li>
|
||||
<li><strong>Project identity = favicon</strong> — the existing <code>ProjectFavicon</code> per-row, not a text chip. Harness (Claude Code / Codex / other) is a tinted glyph on the model; machine shows only when the thread lives on another computer.</li>
|
||||
<li><strong>Failed sessions visible</strong> — <code>session.lastError</code> finally gets a red state; today a dead session shows nothing.</li>
|
||||
<li><strong>Settle → worktree cleanup</strong> — settling an orphaned-worktree thread offers a one-click remove.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<h4>Deliberately not</h4>
|
||||
<ul>
|
||||
<li>Inline approve/reject in the sidebar — needs a safety story first.</li>
|
||||
<li>Message snippets (concept 2) — streaming churn unsolved.</li>
|
||||
<li>Ops-grid density mode (concept 5).</li>
|
||||
<li>Auto-archive of long-settled threads (future: settled ≥ 30d).</li>
|
||||
<li>Removing v1 — it stays the default; v2 is opt-in.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2><span class="num">02</span>The mock</h2>
|
||||
<p><strong>Hover any card and hit “Settle”</strong> — it collapses into the slim tail. That height change is the whole design: it happens only at lifecycle transitions, never from streaming updates, which is what keeps the list calm.</p>
|
||||
|
||||
<div class="mockwrap">
|
||||
<div class="sidebar" id="mock">
|
||||
<div class="sb-top">
|
||||
<div class="sb-search">⌕ Search <kbd>⌘K</kbd></div>
|
||||
<div class="sb-new">+</div>
|
||||
</div>
|
||||
<div class="toast" id="toast"><span>Settled · worktree <b>fix-pr-titles</b> is orphaned</span><button id="toast-remove">Remove</button></div>
|
||||
<div class="rows" id="rows">
|
||||
|
||||
<div class="row unread" data-card style="max-height:64px">
|
||||
<div class="rail amber"></div>
|
||||
<div class="card">
|
||||
<div class="l1"><span class="fav t3">T3</span><span class="title">Normalize open PR titles</span><span class="time wait">waiting 2m</span></div>
|
||||
<div class="meta"><span class="st amber">APPROVAL</span><span class="branch">fix-pr-titles</span><span class="model"><span class="hx cl">✳</span>opus-4.8</span></div>
|
||||
</div>
|
||||
<button class="settle-btn" data-settle data-toast>✓ Settle</button>
|
||||
</div>
|
||||
|
||||
<div class="row" data-card style="max-height:64px">
|
||||
<div class="rail sky"></div>
|
||||
<div class="card">
|
||||
<div class="l1"><span class="fav t3">T3</span><span class="title">Sidebar v2 UX Redesign</span><span class="time">14m 22s</span></div>
|
||||
<div class="meta"><span class="st sky">WORKING</span><span class="branch">sidebar-v2-beta</span><span class="model"><span class="hx cl">✳</span>fable-5</span></div>
|
||||
</div>
|
||||
<button class="settle-btn" data-settle>✓ Settle</button>
|
||||
</div>
|
||||
|
||||
<div class="row unread" data-card style="max-height:64px">
|
||||
<div class="card">
|
||||
<div class="l1"><span class="fav fh">FH</span><span class="title">Fix image upload stalls</span><span class="time">18m</span></div>
|
||||
<div class="meta"><span class="branch">main</span><span class="model"><span class="hx cl">✳</span>sonnet-5</span><span class="mach">⏻ mac-studio</span></div>
|
||||
</div>
|
||||
<button class="settle-btn" data-settle>✓ Settle</button>
|
||||
</div>
|
||||
|
||||
<div class="row unread" data-card style="max-height:64px">
|
||||
<div class="card">
|
||||
<div class="l1"><span class="fav t3">T3</span><span class="title">Review default experience plan</span><span class="time">9m</span></div>
|
||||
<div class="meta"><span class="branch">plan-ux-review</span><span class="model"><span class="hx cl">✳</span>opus-4.8</span></div>
|
||||
</div>
|
||||
<button class="settle-btn" data-settle>✓ Settle</button>
|
||||
</div>
|
||||
|
||||
<div class="row unread" data-card style="max-height:64px">
|
||||
<div class="card">
|
||||
<div class="l1"><span class="fav t3">T3</span><span class="title">Disable pairing codes by default</span><span class="diff"><span class="add">+214</span> <span class="del">−38</span></span><span class="time">12m</span></div>
|
||||
<div class="meta"><span class="branch">disable-pairing-codes</span><span class="model"><span class="hx cx">◈</span>gpt-5.6-sol</span></div>
|
||||
</div>
|
||||
<button class="settle-btn" data-settle>✓ Settle</button>
|
||||
</div>
|
||||
|
||||
<div class="row unread" data-card style="max-height:64px">
|
||||
<div class="rail red"></div>
|
||||
<div class="card">
|
||||
<div class="l1"><span class="fav t3">T3</span><span class="title">iOS Simulator Remote Setup</span><span class="time">34m</span></div>
|
||||
<div class="meta"><span class="st red">FAILED</span><span class="branch">main</span><span class="model"><span class="hx cx">◈</span>gpt-5.6-sol</span><span class="mach">⏻ mbp-16</span></div>
|
||||
</div>
|
||||
<button class="settle-btn" data-settle>✓ Settle</button>
|
||||
</div>
|
||||
|
||||
<div class="row"><div class="slim"><span class="fav t3">T3</span><span class="title">Default new worktrees from origin main</span><span class="time">41m</span></div></div>
|
||||
<div class="row"><div class="slim"><span class="fav t3">T3</span><span class="title">Fix performance bottlenecks</span><span class="pr">#3825 merged</span><span class="time">1d</span></div></div>
|
||||
<div class="row"><div class="slim"><span class="fav t3">T3</span><span class="title">Stress test long thread rendering</span><span class="pr open">#3822 open</span><span class="time">2d</span></div></div>
|
||||
<div class="row"><div class="slim"><span class="fav fh">FH</span><span class="title">CLI File Hosting Options</span><span class="time">2d</span></div></div>
|
||||
</div>
|
||||
<div style="padding:4px 10px 10px; text-align:right"><button class="reset" id="reset-mock">↺ reset mock</button></div>
|
||||
</div>
|
||||
|
||||
<div class="mock-legend">
|
||||
<h4>Card anatomy (active threads, ~52px)</h4>
|
||||
<span class="kv"><b>Line 1</b> — project favicon · title (bold = unread) · diff stats when present · time</span>
|
||||
<span class="kv"><b>Line 2</b> — structured metadata only: status word (only when colored) · branch · harness glyph + model · machine (only when not this one). No generated text — everything on the card is data we already have.</span>
|
||||
<h4>Four states, three colors</h4>
|
||||
<span class="kv"><span class="lg-dot" style="background:var(--amber)"></span><b>APPROVAL</b> — blocked mid-run, pinned to top with “waiting Xm”</span>
|
||||
<span class="kv"><span class="lg-dot" style="background:var(--sky)"></span><b>WORKING</b> — pulsing rail, live elapsed timer</span>
|
||||
<span class="kv"><span class="lg-dot" style="background:var(--fg)"></span><b>Ready</b> — the default; needs no label. Stopped, waiting on you. Bold title until visited.</span>
|
||||
<span class="kv"><span class="lg-dot" style="background:var(--red)"></span><b>FAILED</b> — session error, invisible today</span>
|
||||
<h4>Harness · model · machine</h4>
|
||||
<span class="kv"><b>✳</b> Claude Code · <b>◈</b> Codex · a neutral glyph for “other” — one tinted glyph before the model name, deliberately quiet.</span>
|
||||
<span class="kv"><b>⏻ machine</b> appears only on threads running somewhere other than the current computer; local threads show nothing.</span>
|
||||
<h4>Slim row (settled, ~28px)</h4>
|
||||
<span class="kv">favicon · title · PR when notable · time. Visually ≈ today's v1 row, so density for history is preserved.</span>
|
||||
<h4>Sort</h4>
|
||||
<span class="kv">Approval first (by wait time) → then pure recency. No sections, no headers, no “show more” — the tail just scrolls, virtualized.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2><span class="num">03</span>The settled model</h2>
|
||||
<p>Concept 4 derived “settled” passively. This version makes it an <strong>acknowledgment with an act attached</strong> — Gmail's archive, GitHub notifications' “Done” — which is what makes row heights stable and the list trustworthy.</p>
|
||||
|
||||
<svg viewBox="0 0 900 210" style="width:100%; max-width:900px; margin:18px 0" role="img" aria-label="Settled state machine">
|
||||
<defs>
|
||||
<marker id="arr" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M0 0 L10 5 L0 10 z" fill="#6b7280"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect x="30" y="65" width="180" height="80" rx="14" fill="rgba(56,189,248,.08)" stroke="#38bdf8" stroke-width="1.5"/>
|
||||
<text x="120" y="100" text-anchor="middle" fill="#fff" font-size="17" font-weight="600">Active</text>
|
||||
<text x="120" y="122" text-anchor="middle" fill="#9ca3af" font-size="11">rich card · in rollups</text>
|
||||
<rect x="370" y="65" width="180" height="80" rx="14" fill="rgba(107,114,128,.1)" stroke="#6b7280" stroke-width="1.5"/>
|
||||
<text x="460" y="100" text-anchor="middle" fill="#fff" font-size="17" font-weight="600">Settled</text>
|
||||
<text x="460" y="122" text-anchor="middle" fill="#9ca3af" font-size="11">slim row · out of rollups</text>
|
||||
<rect x="700" y="65" width="170" height="80" rx="14" fill="rgba(248,113,113,.06)" stroke="#3f3f46" stroke-width="1.5" stroke-dasharray="5 4"/>
|
||||
<text x="785" y="100" text-anchor="middle" fill="#fff" font-size="17" font-weight="600">Archived</text>
|
||||
<text x="785" y="122" text-anchor="middle" fill="#9ca3af" font-size="11">existing flow, unchanged</text>
|
||||
<path d="M212 85 C 270 60, 310 60, 368 85" fill="none" stroke="#6b7280" stroke-width="1.5" marker-end="url(#arr)"/>
|
||||
<text x="290" y="52" text-anchor="middle" fill="#9ca3af" font-size="11.5">user settles · PR merged/closed · inactive ≥ 3d</text>
|
||||
<path d="M368 128 C 310 153, 270 153, 212 128" fill="none" stroke="#6b7280" stroke-width="1.5" marker-end="url(#arr)"/>
|
||||
<text x="290" y="172" text-anchor="middle" fill="#9ca3af" font-size="11.5">any real activity · user un-settles</text>
|
||||
<path d="M552 105 L 698 105" fill="none" stroke="#4b5563" stroke-width="1.5" stroke-dasharray="5 4" marker-end="url(#arr)"/>
|
||||
<text x="625" y="94" text-anchor="middle" fill="#6b7280" font-size="11.5">manual (future: 30d auto)</text>
|
||||
</svg>
|
||||
|
||||
<p><strong>Storage is one override, everything else is computed.</strong> No background jobs, no sweeper:</p>
|
||||
<pre><span class="k">effectiveSettled</span>(thread) =
|
||||
override === <span class="s">"settled"</span> → <span class="k">true</span> <span class="c">// manual settle</span>
|
||||
override === <span class="s">"active"</span> → <span class="k">false</span> <span class="c">// manual keep-active (beats auto rules)</span>
|
||||
pr.state ∈ {<span class="s">merged</span>, <span class="s">closed</span>} → <span class="k">true</span> <span class="c">// auto — strongest signal</span>
|
||||
lastActivityAt < now − inactivityThreshold → <span class="k">true</span> <span class="c">// auto — backstop, default 3d, configurable</span>
|
||||
otherwise → <span class="k">false</span></pre>
|
||||
<ul>
|
||||
<li>Stored: <code>settledOverride: "settled" | "active" | null</code> + <code>settledAt</code>, server-side next to <code>archivedAt</code> — it must sync across desktop/remote, and worktree cleanup needs the server to know. Mirrors the <code>thread.archived</code> event pattern exactly.</li>
|
||||
<li><strong>Activity clears the override</strong> (new user message, session start, approval request) — a settled thread that wakes up expands and floats back up. Settled is never a hole a thread disappears into.</li>
|
||||
<li><strong>Viewing ≠ settling.</strong> Visiting clears unread (existing <code>lastVisitedAt</code>); settling asserts “this work is concluded.” Conflating them would make auto-unsettle fight the user.</li>
|
||||
</ul>
|
||||
<div class="note warn"><strong>Inbox-zero hedge:</strong> manual settling must feel like optional satisfaction, not homework. The auto rules guarantee a user who never touches the affordance still gets a tidy list. Beta telemetry decides how prominent the affordance stays.</div>
|
||||
|
||||
<h2><span class="num">04</span>Swap boundary</h2>
|
||||
<p><strong>Whole-component swap, one seam.</strong> Today's <code>Sidebar.tsx</code> (~3,750 lines) takes zero props and mounts at exactly one place. Everything that must behave identically in both sidebars already lives <em>outside</em> the component in shared hooks and stores — and what lives inside (project grouping, drag-and-drop, show-more) is precisely what v2 deletes.</p>
|
||||
|
||||
<svg viewBox="0 0 900 330" style="width:100%; max-width:900px; margin:18px 0" role="img" aria-label="Component swap architecture">
|
||||
<defs>
|
||||
<marker id="arr2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M0 0 L10 5 L0 10 z" fill="#6b7280"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect x="280" y="14" width="340" height="52" rx="10" fill="#0d0d0f" stroke="#26262c"/>
|
||||
<text x="450" y="36" text-anchor="middle" fill="#fff" font-size="13" font-weight="600" class="mono">AppSidebarLayout.tsx:93</text>
|
||||
<text x="450" y="54" text-anchor="middle" fill="#9ca3af" font-size="11" class="mono">{sidebarV2Enabled ? <ThreadSidebarV2/> : <ThreadSidebar/>}</text>
|
||||
<path d="M380 66 L 235 108" stroke="#6b7280" stroke-width="1.5" marker-end="url(#arr2)"/>
|
||||
<path d="M520 66 L 665 108" stroke="#6b7280" stroke-width="1.5" marker-end="url(#arr2)"/>
|
||||
<rect x="70" y="112" width="330" height="78" rx="10" fill="#0d0d0f" stroke="#26262c"/>
|
||||
<text x="235" y="136" text-anchor="middle" fill="#fff" font-size="13" font-weight="600" class="mono">Sidebar.tsx (v1 — untouched, default)</text>
|
||||
<text x="235" y="156" text-anchor="middle" fill="#9ca3af" font-size="11">project groups · dnd · show-more · collapse</text>
|
||||
<text x="235" y="174" text-anchor="middle" fill="#6b7280" font-size="11">ignores new settled fields entirely</text>
|
||||
<rect x="500" y="112" width="330" height="78" rx="10" fill="rgba(52,211,153,.05)" stroke="#34d399"/>
|
||||
<text x="665" y="136" text-anchor="middle" fill="#fff" font-size="13" font-weight="600" class="mono">SidebarV2.tsx (new, beta)</text>
|
||||
<text x="665" y="156" text-anchor="middle" fill="#9ca3af" font-size="11">flat virtualized list · card/slim rows · settle</text>
|
||||
<text x="665" y="174" text-anchor="middle" fill="#6b7280" font-size="11">no imports from Sidebar.tsx, ever</text>
|
||||
<path d="M235 190 L 235 232" stroke="#6b7280" stroke-width="1.5" marker-end="url(#arr2)"/>
|
||||
<path d="M665 190 L 665 232" stroke="#6b7280" stroke-width="1.5" marker-end="url(#arr2)"/>
|
||||
<rect x="70" y="236" width="760" height="72" rx="10" fill="#0d0d0f" stroke="#26262c"/>
|
||||
<text x="450" y="260" text-anchor="middle" fill="#fff" font-size="13" font-weight="600">Shared — both components call the same modules</text>
|
||||
<text x="450" y="282" text-anchor="middle" fill="#9ca3af" font-size="11" class="mono">Sidebar.logic.ts · ThreadStatusIndicators · useThreadActions · threadSelectionStore · uiStateStore · threadSort.ts · keybindings</text>
|
||||
<text x="450" y="300" text-anchor="middle" fill="#6b7280" font-size="11">anything both need moves here first — never cross-imported</text>
|
||||
</svg>
|
||||
|
||||
<ul>
|
||||
<li>The settled <strong>data model ships dark and is flag-independent</strong> — v1 simply ignores the new fields. The toggle is a pure view swap: flipping it never migrates data, so switching back and forth is always safe.</li>
|
||||
<li>Toggle lives in a new <strong>“Beta features”</strong> settings panel: <code>sidebarV2Enabled</code> (default false) + <code>sidebarAutoSettleAfterDays</code> (default 3, nullable = never) in <code>ClientSettingsSchema</code>.</li>
|
||||
<li>Inherited for free via shared hooks: click-to-open, multi-select, context menu, inline rename, thread-jump ⌘1–9, archive, PR link, port/terminal/remote indicators.</li>
|
||||
</ul>
|
||||
|
||||
<h2><span class="num">05</span>Phases</h2>
|
||||
|
||||
<div class="phase">
|
||||
<div class="phase-h"><span class="n">P1</span><span class="t">Settled data model</span><span class="d">ships dark · no UI change</span></div>
|
||||
<div class="phase-b">
|
||||
<ul>
|
||||
<li><code>contracts/settings.ts</code> — add <code>sidebarV2Enabled</code>, <code>sidebarAutoSettleAfterDays</code>.</li>
|
||||
<li><code>contracts/orchestration.ts</code> — <code>settledOverride</code> + <code>settledAt</code> on the thread (decoding defaults → old data decodes unchanged); <code>thread.settled</code> / <code>thread.unsettled</code> events; <code>thread.settle</code> / <code>thread.unsettle</code> commands.</li>
|
||||
<li><code>server/orchestration/decider.ts</code> — handle both commands (settle is idempotent for bulk); activity paths (user message, session start, approval request) emit <code>thread.unsettled</code> when an override is set.</li>
|
||||
<li><code>client-runtime/threadReducer.ts</code> — reduce both events (archive cases at :87–101 are the template).</li>
|
||||
<li>Pure <code>effectiveSettled(shell, {now, autoSettleAfterDays})</code> in client-runtime; unit-test the full truth table (override × PR state × inactivity).</li>
|
||||
</ul>
|
||||
<p class="kv"><b>Verify:</b> typecheck · reducer + predicate tests · zero visible change.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="phase">
|
||||
<div class="phase-h"><span class="n">P2</span><span class="t">SidebarV2 component + beta toggle</span><span class="d">the visible feature</span></div>
|
||||
<div class="phase-b">
|
||||
<ul>
|
||||
<li>“Beta features” settings panel + route; swap seam in <code>AppSidebarLayout.tsx</code>.</li>
|
||||
<li><code>SidebarV2.tsx</code>: flat virtualized list, sort = needs-approval (by wait) → recency; single <code>SidebarV2Row</code> with <code>card</code> / <code>slim</code> variants from the same shell data. Rows lead with the existing <code>ProjectFavicon</code> component (environmentId + cwd are already on the shell).</li>
|
||||
<li>Consolidate status derivation in <code>Sidebar.logic.ts</code> to four visual states: <strong>Needs approval</strong>, <strong>Working</strong> (incl. connecting), <strong>Ready</strong> (merges today's Awaiting Input / Plan Ready / Completed-unseen — same user action, so one unlabeled state), and new <strong>Failed</strong> (<code>session.lastError</code>, non-running) — kept shared so v1 can adopt Failed later.</li>
|
||||
<li>Meta line: harness glyph + model from the shell's provider/model selection; machine label from the thread's environment vs. the current one (render only when they differ). Both are display-only lookups, no new data plumbing.</li>
|
||||
<li>Unread = bold-until-visited from existing <code>uiStateStore.threadLastVisitedAtById</code>.</li>
|
||||
<li>Height changes <strong>only</strong> on settle/unsettle transitions (auto-animate); streaming never resizes rows.</li>
|
||||
<li><code>useThreadActions</code>: <code>settleThread</code> / <code>unsettleThread</code> mirroring <code>archiveThread</code>, minus navigation — settling never navigates away. Affordances: row hover button, context menu, bulk multi-select. No keyboard shortcut yet.</li>
|
||||
</ul>
|
||||
<p class="kv"><b>Verify:</b> toggle on → v2; toggle off → v1 pixel-identical to before · settle round-trips across a desktop+remote pair · killed session → Failed card.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="phase">
|
||||
<div class="phase-h"><span class="n">P3</span><span class="t">Worktree cleanup hook</span><span class="d">settle = reclaim disk</span></div>
|
||||
<div class="phase-b">
|
||||
<ul>
|
||||
<li>On <strong>manual settle</strong> where the worktree is orphaned (<code>getOrphanedWorktreePathForThread</code>): non-blocking “Worktree kept · Remove?” prompt → <code>vcsEnvironment.removeWorktree</code>. Never automatic, never blocks the settle.</li>
|
||||
<li>Skip the prompt when the worktree has uncommitted changes or unpushed commits (from vcs status the sidebar already has).</li>
|
||||
<li>Auto-settle never touches worktrees. Follow-up (tracked, out of scope): settings “Storage” view listing orphaned worktrees of settled threads with sizes + bulk remove.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="phase">
|
||||
<div class="phase-h"><span class="n">P4</span><span class="t">Telemetry & beta exit</span><span class="d">find the balance</span></div>
|
||||
<div class="phase-b">
|
||||
<ul>
|
||||
<li>Count settles by source: manual / auto-PR / auto-inactivity / bulk. Count un-settles: manual vs. activity-driven.</li>
|
||||
<li><strong>Activity-driven un-settles of manual settles</strong> = the model fighting users → retune threshold or triggers.</li>
|
||||
<li>Manual settling ≈ 0% → shrink the affordance, lean on auto rules. High → a habit worth building on (keyboard shortcut, etc.).</li>
|
||||
<li>Track toggle-off rate after trying v2.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2><span class="num">06</span>Open questions</h2>
|
||||
<table>
|
||||
<tr><th>Question</th><th>Current thinking</th></tr>
|
||||
<tr><td>Server-side activity observation</td><td>If decider activity paths are too scattered for unsettle-on-activity, fall back to client-side: compute with activity timestamps, override only stores manual state (activity newer than <code>settledAt</code> wins). Decide in P1.</td></tr>
|
||||
<tr><td>Shell projection</td><td><code>settledOverride</code>/<code>settledAt</code> <strong>must</strong> be in the thread shell stream — the sidebar never loads details. Verify first thing in P1.</td></tr>
|
||||
<tr><td>Diff stats on cards</td><td>Requires checkpoint data in the shell; if absent, defer diff stats rather than loading details per row.</td></tr>
|
||||
<tr><td>Project grouping in v2</td><td>Not planned; v1 stays available for users who want groups. Revisit only if beta feedback demands it.</td></tr>
|
||||
</table>
|
||||
|
||||
<div class="foot">T3 Code · Sidebar v2 beta · plan doc pair: <code>.plans/21-sidebar-v2-beta.md</code> (implementation detail) + this page (design + rationale). Mock data mirrors the original concepts page (from live state.sqlite, Jul 13).</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function settle(btn, showToast) {
|
||||
const row = btn.closest('.row');
|
||||
if (!row) return;
|
||||
row.classList.add('settling');
|
||||
setTimeout(() => {
|
||||
row.classList.remove('settling');
|
||||
row.removeAttribute('data-card');
|
||||
row.style.maxHeight = '';
|
||||
const title = row.querySelector('.title').textContent;
|
||||
const time = row.querySelector('.time').textContent.replace('waiting ', '');
|
||||
const fav = row.querySelector('.fav').outerHTML;
|
||||
row.classList.remove('unread');
|
||||
row.innerHTML = '<div class="slim">' + fav + '<span class="title">' + title +
|
||||
'</span><span class="time">' + time + '</span></div>';
|
||||
const rows = document.getElementById('rows');
|
||||
const firstSlim = Array.from(rows.children).find(r => !r.hasAttribute('data-card'));
|
||||
rows.insertBefore(row, firstSlim ?? null);
|
||||
row.style.opacity = '0';
|
||||
requestAnimationFrame(() => { row.style.transition = 'opacity .3s'; row.style.opacity = '1'; });
|
||||
if (showToast) document.getElementById('toast').classList.add('show');
|
||||
}, 360);
|
||||
}
|
||||
function hideToast() { document.getElementById('toast').classList.remove('show'); }
|
||||
document.querySelectorAll('[data-settle]').forEach((btn) => {
|
||||
btn.addEventListener('click', () => settle(btn, btn.hasAttribute('data-toast')));
|
||||
});
|
||||
document.getElementById('toast-remove').addEventListener('click', hideToast);
|
||||
document.getElementById('reset-mock').addEventListener('click', () => location.reload());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,285 @@
|
||||
# Sidebar v2 (beta): flat adaptive-density list with settled threads
|
||||
|
||||
Status: planned
|
||||
Mocks: https://hsyscdqldmk5.postplan.dev/ (concept 4 base + concept 1 card layout + concept 3 needs-you pinning)
|
||||
|
||||
## Summary
|
||||
|
||||
A new thread sidebar behind a client-settings beta toggle. Core changes vs. the
|
||||
current sidebar:
|
||||
|
||||
- **Flat recency list.** Project group headers are gone; project identity moves
|
||||
onto the row as the existing `ProjectFavicon` (environmentId + cwd). This
|
||||
matches the session lists users know from Claude Code, Codex, and Cursor.
|
||||
- **Adaptive density via a "settled" lifecycle state.** Active threads render
|
||||
as two-line cards: favicon + title + time, then a structured meta line
|
||||
(status word · branch · harness glyph + model · machine). Settled threads
|
||||
collapse to slim one-liners, roughly today's row height. No generated or
|
||||
free-text summaries anywhere — every field on a card is data the shell
|
||||
already carries.
|
||||
- **Settled is an explicit state**, not a derived one: users settle threads
|
||||
manually, or threads auto-settle (PR merged/closed, inactivity). Any real
|
||||
activity auto-unsettles. Settled is a lifecycle stage between active and
|
||||
archived — it stays in the list, just quiet.
|
||||
- **Four visual states, three colors.** Needs approval (amber, pinned above
|
||||
the recency flow with "waiting Xm"), Working (sky, pulsing, elapsed timer),
|
||||
**Ready** (uncolored and unlabeled — the normal resting state: the agent
|
||||
stopped and is waiting on you, whether it finished, asked a question, or
|
||||
proposed a plan; bold title until visited is the only signal), Failed (red,
|
||||
`session.lastError` — a dead session shows nothing today). Today's Awaiting
|
||||
Input / Plan Ready / Completed-unseen pills all collapse into Ready: they
|
||||
differ in detail, not in what the user should do (look at the thread).
|
||||
Color is reserved for "act now" (amber), "in motion" (sky), "broken" (red).
|
||||
- **Harness / model / machine as quiet metadata.** A tinted glyph before the
|
||||
model name distinguishes Claude Code / Codex / other; a machine label
|
||||
renders only when the thread lives on a different computer than the one
|
||||
you're looking at. Display-only lookups from shell data, no new plumbing.
|
||||
- **Settled feeds cleanup.** Settling a thread offers/permits worktree cleanup;
|
||||
long-settled threads are candidates for future auto-archive.
|
||||
|
||||
The v2 component is a sibling of the current sidebar, swapped at a single mount
|
||||
point. The current sidebar is untouched except for the swap seam.
|
||||
|
||||
## Rationale
|
||||
|
||||
Full design discussion lives in the session that produced the mocks; the short
|
||||
version:
|
||||
|
||||
- We aren't in a position to teach users a new interaction model. Every v2
|
||||
mechanic maps to an existing habit: flat recency list (Claude Code / Codex /
|
||||
Cursor), settle (Gmail archive / GitHub notifications "Done"), unread-bold
|
||||
(email). Zero new gestures.
|
||||
- "Settled" makes the adaptive-density row-height rule *stable*: height changes
|
||||
only at real lifecycle transitions, never from ambient re-rendering. This
|
||||
kills concept 4's "jumpy list" risk.
|
||||
- Viewing a thread does **not** settle it. Visiting clears unseen (existing
|
||||
`lastVisitedAt` mechanics); settling asserts "this work is concluded." If
|
||||
viewing settled, auto-unsettle would fight the user and the state would stop
|
||||
meaning anything.
|
||||
- Settling is optional by design. The auto rules are the hedge against
|
||||
inbox-zero fatigue: a user who never touches the affordance still gets a
|
||||
naturally tidy list. Beta telemetry question: what fraction of settles are
|
||||
manual vs. auto?
|
||||
|
||||
## The settled model
|
||||
|
||||
```
|
||||
Active ──(user settles | PR merged/closed | inactivity ≥ threshold)──▶ Settled
|
||||
Settled ──(new user message | session starts | approval requested |
|
||||
PR reopened | user un-settles)──▶ Active
|
||||
Settled ──(existing archive flow, or future auto-archive)──▶ Archived
|
||||
```
|
||||
|
||||
Settled is a **computed property with one stored override**:
|
||||
|
||||
```
|
||||
effectiveSettled(thread) =
|
||||
override === "settled" → true (manual settle)
|
||||
override === "active" → false (manual keep-active)
|
||||
pr.state ∈ {merged, closed} → true (auto)
|
||||
lastActivityAt < now − inactivityThreshold → true (auto)
|
||||
otherwise → false
|
||||
```
|
||||
|
||||
- The stored field is a tri-state: `settledOverride: "settled" | "active" | null`
|
||||
plus `settledAt: IsoDateTime | null` (set when override becomes "settled",
|
||||
used for display and future auto-archive aging).
|
||||
- The auto cases need no background job and no events — they fall out of data
|
||||
the sidebar already streams (`vcs.status` change request state,
|
||||
`latestUserMessageAt` / turn timestamps). Auto-unsettle for the time-based
|
||||
case is free: activity moves the timestamp, the predicate flips.
|
||||
- **Activity clears the override.** Any thread activity event (new user
|
||||
message, session start, approval request) resets `settledOverride` to null
|
||||
server-side, so a manually settled thread that wakes up becomes active again
|
||||
and later auto-rules apply fresh. Likewise, manually un-settling a merged-PR
|
||||
thread sets `settledOverride: "active"`, which beats the PR auto-rule.
|
||||
- Inactivity threshold: default 3 days, client setting, `null` = never
|
||||
auto-settle by time.
|
||||
|
||||
Server-side storage (next to `archivedAt` on the thread) rather than
|
||||
client-local: settled must sync across desktop/remote environments, and the
|
||||
worktree-cleanup hook needs the server to know. This mirrors the
|
||||
`archivedAt` / `thread.archived` / `thread.unarchived` pattern exactly.
|
||||
|
||||
Consequences of being settled:
|
||||
|
||||
- Row collapses to the slim one-liner.
|
||||
- Excluded from status rollups (any badge counts, aggregate status dots).
|
||||
- Eligible for worktree cleanup prompting (see below).
|
||||
- Future: settled ≥ 30 days → auto-archive candidate (not in this phase).
|
||||
|
||||
## Swap strategy: component swap at the mount point
|
||||
|
||||
Decision: **swap the whole sidebar component**, not internals.
|
||||
|
||||
The current `Sidebar.tsx` (~3750 lines) takes no props — it reads everything
|
||||
from hooks/atoms/stores — and `AppSidebarLayout.tsx:93` is its single mount
|
||||
point. The truly shared behavior (thread-jump keybindings, selection store,
|
||||
uiStateStore, `useThreadActions`, context-menu via `readLocalApi()`) already
|
||||
lives *outside* the component in hooks and stores, so a sibling component
|
||||
inherits all of it by calling the same hooks. What lives inside Sidebar.tsx
|
||||
(project grouping, drag-and-drop, show-more, per-project collapse) is exactly
|
||||
the stuff v2 deletes — threading a variant flag through it would mean touching
|
||||
hundreds of conditional branches for no benefit.
|
||||
|
||||
```tsx
|
||||
// AppSidebarLayout.tsx — the entire seam
|
||||
const sidebarV2 = useClientSettings((s) => s.sidebarV2Enabled);
|
||||
...
|
||||
{sidebarV2 ? <ThreadSidebarV2 /> : <ThreadSidebar />}
|
||||
```
|
||||
|
||||
Rules for the seam:
|
||||
|
||||
- `SidebarV2.tsx` imports freely from `Sidebar.logic.ts`,
|
||||
`ThreadStatusIndicators.tsx`, `useThreadActions`, `threadSelectionStore`,
|
||||
`uiStateStore` — shared logic stays shared.
|
||||
- `SidebarV2.tsx` must not import from `Sidebar.tsx`, and vice versa. Anything
|
||||
both need moves into `Sidebar.logic.ts` (or a new shared module) first.
|
||||
- The settled *data model* (contracts, server, reducer) is flag-independent —
|
||||
it ships dark and is simply unused by the v1 component. Only the *UI* is
|
||||
gated. This keeps the toggle a pure view swap: flipping it never migrates
|
||||
data, so switching back and forth is always safe.
|
||||
- v1 remains the default. Deleting v1 is a separate future decision once beta
|
||||
feedback lands.
|
||||
|
||||
## Implementation phases
|
||||
|
||||
### Phase 1 — Settled data model (ships dark, no UI)
|
||||
|
||||
Mirror the archived pattern end-to-end:
|
||||
|
||||
1. `packages/contracts/src/settings.ts`: add to `ClientSettingsSchema`:
|
||||
- `sidebarV2Enabled: boolean` (default false)
|
||||
- `sidebarAutoSettleAfterDays: number | null` (default 3)
|
||||
2. `packages/contracts/src/orchestration.ts`:
|
||||
- Thread shell: `settledOverride: "settled" | "active" | null`,
|
||||
`settledAt: IsoDateTime | null` (both with decoding defaults of null —
|
||||
old persisted threads decode unchanged).
|
||||
- Events: `thread.settled` (threadId, settledAt, updatedAt),
|
||||
`thread.unsettled` (threadId, updatedAt). Payload schemas alongside
|
||||
`ThreadArchivedPayload` / `ThreadUnarchivedPayload`.
|
||||
- Commands: `thread.settle`, `thread.unsettle`.
|
||||
3. `apps/server/src/orchestration/decider.ts`: handle both commands, mirroring
|
||||
archive/unarchive. Invariants in `commandInvariants.ts`
|
||||
(`requireThreadNotArchived` applies; settle of an already-settled thread is
|
||||
a no-op rather than an error — idempotent for bulk operations).
|
||||
In the decider paths that record thread activity (user message appended,
|
||||
session started, approval requested): if `settledOverride !== null`, also
|
||||
emit `thread.unsettled` to clear it.
|
||||
4. `packages/client-runtime/src/state/threadReducer.ts`: reduce both events
|
||||
(`threadReducer.ts:87-101` is the archive template). Tests alongside the
|
||||
archive reducer tests.
|
||||
5. `packages/client-runtime` (new `threadSettled.ts` or in `threadSort.ts`):
|
||||
pure `effectiveSettled(shell, { now, autoSettleAfterDays })` implementing
|
||||
the predicate above, plus `lastActivityAt(shell)` (max of
|
||||
latestUserMessageAt, latest turn completion, session start). Unit-test the
|
||||
truth table: each override state × PR state × inactivity.
|
||||
|
||||
Verification: `bun run typecheck`, reducer + predicate unit tests. No visible
|
||||
change anywhere.
|
||||
|
||||
### Phase 2 — SidebarV2 component + beta toggle
|
||||
|
||||
1. Settings UI: "Beta features" section (new panel in
|
||||
`apps/web/src/components/settings/SettingsPanels.tsx` + route, matching the
|
||||
existing settings-page pattern) with the v2 toggle and, indented under it,
|
||||
the auto-settle threshold control.
|
||||
2. Swap seam in `AppSidebarLayout.tsx` as above.
|
||||
3. `apps/web/src/components/SidebarV2.tsx`, reusing shared modules. Structure:
|
||||
- **One flat virtualized list** of all non-archived threads across
|
||||
projects. Sort key: (needs-approval first, by wait time) → then recency
|
||||
(`latestUserMessageAt`, reusing `threadSort.ts`). No show-more, no
|
||||
project collapse, no dnd.
|
||||
- **Row variants** (single `SidebarV2Row` with a `variant` prop, both
|
||||
variants rendered from the same shell data):
|
||||
- `card` (~52px, threads where `effectiveSettled` is false): line 1
|
||||
`ProjectFavicon` + title (+ diff stats when present) + time ("waiting
|
||||
Xm" in amber when approval-blocked, live elapsed for working); line 2
|
||||
structured meta — status word (only for the colored states) · branch ·
|
||||
harness glyph + model · machine (only when the thread's environment is
|
||||
not the current machine). Left rail color only for approval (amber),
|
||||
working (sky, pulsing), failed (red) — Ready rows carry no color or
|
||||
label, just a bold title while unread. No free-text/generated content.
|
||||
- `slim` (~28px, settled): `ProjectFavicon` · title · PR badge when
|
||||
notable · time. Visually close to today's v1 row.
|
||||
- **Status derivation** consolidates `Sidebar.logic.ts`'s pill logic into
|
||||
four visual states: Needs Approval, Working (incl. connecting), Ready
|
||||
(today's Awaiting Input + Plan Ready + Completed-unseen — same user
|
||||
action, different payload), and new Failed (`session.lastError` on a
|
||||
non-running session). Keep it in `Sidebar.logic.ts` so v1 can adopt
|
||||
Failed later too.
|
||||
- **Unread**: bold title until visited, from existing
|
||||
`uiStateStore.threadLastVisitedAtById` — same mechanics as today's
|
||||
Completed-unseen pill.
|
||||
- **Row height changes only on lifecycle transitions** (settle/unsettle),
|
||||
animated with the existing auto-animate pattern. Streaming/status
|
||||
updates within a variant never change height.
|
||||
- Preserved v1 behaviors, via the shared hooks: click-to-open, multi-select
|
||||
(threadSelectionStore), context menu (add Settle/Un-settle entries),
|
||||
inline rename, thread-jump shortcut labels, archive affordance, PR icon
|
||||
link, port/terminal/remote indicators (moved into line 3 / slim row
|
||||
trailing icons).
|
||||
4. Settle affordances:
|
||||
- Hover action on the row (next to today's archive hover button) +
|
||||
context-menu entry + bulk via multi-select.
|
||||
- `useThreadActions`: add `settleThread` / `unsettleThread` mirroring
|
||||
`archiveThread` (`useThreadActions.ts:91-134`), minus the navigation
|
||||
dance — settling never navigates away.
|
||||
- No keyboard shortcut in the first cut; add via keybindings once the
|
||||
affordance proves out.
|
||||
|
||||
Verification: typecheck/lint; toggle on → v2 renders, toggle off → v1
|
||||
identical to before; settle/unsettle round-trips including across a
|
||||
desktop+remote pair; kill a session mid-run → Failed card appears.
|
||||
|
||||
### Phase 3 — Worktree cleanup hook
|
||||
|
||||
Settling is the natural moment to reclaim disk:
|
||||
|
||||
1. On **manual settle** of a thread whose worktree is orphaned
|
||||
(`getOrphanedWorktreePathForThread`, `worktreeCleanup.ts:11-33`): show a
|
||||
non-blocking inline prompt/toast — "Worktree kept · Remove?" — that calls
|
||||
`vcsEnvironment.removeWorktree`. Never remove without an explicit click;
|
||||
never block the settle on the answer. Skip the prompt entirely when the
|
||||
worktree has uncommitted changes or unpushed commits (check via the
|
||||
existing vcs status the sidebar already has).
|
||||
2. **Auto-settle does not touch worktrees** in this phase. A settings-page
|
||||
"Storage" affordance listing orphaned worktrees of settled threads (with
|
||||
sizes, bulk-remove) is the follow-up; tracked but not in scope.
|
||||
|
||||
### Phase 4 — Beta telemetry & exit criteria
|
||||
|
||||
Instrument (whatever the existing analytics path is — if none, a lightweight
|
||||
local counter surfaced in diagnostics is enough for the beta):
|
||||
|
||||
- settle events by source: manual / auto-PR / auto-inactivity / bulk
|
||||
- un-settle events: manual vs. activity-driven (activity-driven un-settles of
|
||||
*manual* settles = the model fighting users)
|
||||
- toggle-off rate after trying v2
|
||||
|
||||
Decision inputs for exiting beta: if manual settling is ~0%, shrink the
|
||||
affordance and lean on auto rules; if activity-unsettle-of-manual-settle is
|
||||
high, the inactivity threshold or unsettle triggers need retuning.
|
||||
|
||||
## Explicitly out of scope
|
||||
|
||||
- Inline approve/reject in the sidebar (concept 3) — needs a safety story.
|
||||
- Message snippets in rows (concept 2) — streaming churn unsolved.
|
||||
- Ops-grid density mode (concept 5).
|
||||
- Auto-archive of long-settled threads.
|
||||
- Removing v1 / making v2 the default.
|
||||
- Project grouping inside v2 (v1 remains available for users who want groups).
|
||||
|
||||
## Open questions
|
||||
|
||||
- Where thread "activity" is centrally observable server-side for the
|
||||
unsettle-on-activity rule — if the decider paths are too scattered, an
|
||||
acceptable fallback is client-side: compute `effectiveSettled` with the
|
||||
activity timestamps and only use the override for manual state (activity
|
||||
newer than `settledAt` wins). Decide during Phase 1 once in the decider.
|
||||
- Whether `settledAt` belongs in the thread *shell* stream (sidebar reads
|
||||
shells only) — it must, or v2 can't sort/collapse without detail loads.
|
||||
Verify shell projection includes it.
|
||||
- Diff stats on cards require checkpoint data in the shell; if absent, defer
|
||||
diff stats rather than loading details for every row.
|
||||
@@ -20,6 +20,7 @@ const clientSettings: ClientSettings = {
|
||||
diffIgnoreWhitespace: true,
|
||||
favorites: [],
|
||||
providerModelPreferences: {},
|
||||
sidebarAutoSettleAfterDays: 3,
|
||||
sidebarProjectGroupingMode: "repository_path",
|
||||
sidebarProjectGroupingOverrides: {
|
||||
"environment-1:/tmp/project-a": "separate",
|
||||
@@ -27,6 +28,7 @@ const clientSettings: ClientSettings = {
|
||||
sidebarProjectSortOrder: "manual",
|
||||
sidebarThreadSortOrder: "created_at",
|
||||
sidebarThreadPreviewCount: 6,
|
||||
sidebarV2Enabled: false,
|
||||
timestampFormat: "24-hour",
|
||||
wordWrap: true,
|
||||
};
|
||||
|
||||
@@ -23,46 +23,54 @@ if (
|
||||
);
|
||||
}
|
||||
|
||||
const VARIANT_CONFIG: Record<
|
||||
AppVariant,
|
||||
{
|
||||
readonly appName: string;
|
||||
readonly scheme: string;
|
||||
readonly iosIcon: string;
|
||||
readonly splashIcon: string;
|
||||
readonly iosBundleIdentifier: string;
|
||||
readonly androidPackage: string;
|
||||
readonly relyingParty?: string;
|
||||
}
|
||||
> = {
|
||||
const DEVELOPMENT_ASSETS = {
|
||||
appIcon: "./assets/splash-icon-dev.png",
|
||||
iosIcon: "./assets/icon-composer-dev.icon",
|
||||
splashIcon: "./assets/splash-icon-dev.png",
|
||||
androidAdaptiveForeground: "./assets/android-icon-dev-foreground.png",
|
||||
androidAdaptiveBackgroundColor: "#00639B",
|
||||
androidMonochromeIcon: "./assets/android-icon-mark.png",
|
||||
androidNotificationIcon: "./assets/android-notification-icon.png",
|
||||
androidNotificationColor: "#00639B",
|
||||
} as const;
|
||||
|
||||
const RELEASE_ASSETS = {
|
||||
appIcon: "./assets/splash-icon-prod.png",
|
||||
iosIcon: "./assets/icon-composer-prod.icon",
|
||||
splashIcon: "./assets/splash-icon-prod.png",
|
||||
androidAdaptiveForeground: "./assets/android-icon-mark.png",
|
||||
androidAdaptiveBackgroundColor: "#000000",
|
||||
androidMonochromeIcon: "./assets/android-icon-mark.png",
|
||||
androidNotificationIcon: "./assets/android-notification-icon.png",
|
||||
androidNotificationColor: "#FFFFFF",
|
||||
} as const;
|
||||
|
||||
const VARIANT_CONFIG = {
|
||||
development: {
|
||||
appName: "T3 Code Dev",
|
||||
scheme: "t3code-dev",
|
||||
iosIcon: "./assets/icon-composer-dev.icon",
|
||||
splashIcon: "./assets/splash-icon-dev.png",
|
||||
iosBundleIdentifier: "com.t3tools.t3code.dev",
|
||||
androidPackage: "com.t3tools.t3code.dev",
|
||||
relyingParty: "clerk.t3.codes",
|
||||
assets: DEVELOPMENT_ASSETS,
|
||||
},
|
||||
preview: {
|
||||
appName: "T3 Code Preview",
|
||||
scheme: "t3code-preview",
|
||||
iosIcon: "./assets/icon-composer-prod.icon",
|
||||
splashIcon: "./assets/splash-icon-prod.png",
|
||||
iosBundleIdentifier: "com.t3tools.t3code.preview",
|
||||
androidPackage: "com.t3tools.t3code.preview",
|
||||
relyingParty: "clerk.t3.codes",
|
||||
assets: RELEASE_ASSETS,
|
||||
},
|
||||
production: {
|
||||
appName: "T3 Code",
|
||||
scheme: "t3code",
|
||||
iosIcon: "./assets/icon-composer-prod.icon",
|
||||
splashIcon: "./assets/splash-icon-prod.png",
|
||||
iosBundleIdentifier: "com.t3tools.t3code",
|
||||
androidPackage: "com.t3tools.t3code",
|
||||
relyingParty: "clerk.t3.codes",
|
||||
assets: RELEASE_ASSETS,
|
||||
},
|
||||
};
|
||||
} as const;
|
||||
|
||||
function resolveAppVariant(value: string | undefined): AppVariant {
|
||||
switch (value) {
|
||||
@@ -121,7 +129,7 @@ const config: ExpoConfig = {
|
||||
policy: process.env.MOBILE_VERSION_POLICY ?? "fingerprint",
|
||||
},
|
||||
orientation: "portrait",
|
||||
icon: "./assets/icon.png",
|
||||
icon: variant.assets.appIcon,
|
||||
userInterfaceStyle: "automatic",
|
||||
updates: {
|
||||
enabled: true,
|
||||
@@ -130,7 +138,7 @@ const config: ExpoConfig = {
|
||||
fallbackToCacheTimeout: 0,
|
||||
},
|
||||
ios: {
|
||||
icon: variant.iosIcon,
|
||||
icon: variant.assets.iosIcon,
|
||||
supportsTablet: true,
|
||||
bundleIdentifier: variant.iosBundleIdentifier,
|
||||
// Pin code signing to the T3 Tools team so non-interactive `expo run:ios`
|
||||
@@ -151,13 +159,12 @@ const config: ExpoConfig = {
|
||||
},
|
||||
},
|
||||
android: {
|
||||
icon: "./assets/icon.png",
|
||||
icon: variant.assets.appIcon,
|
||||
package: variant.androidPackage,
|
||||
adaptiveIcon: {
|
||||
backgroundColor: "#E6F4FE",
|
||||
foregroundImage: "./assets/android-icon-foreground.png",
|
||||
backgroundImage: "./assets/android-icon-background.png",
|
||||
monochromeImage: "./assets/android-icon-monochrome.png",
|
||||
backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
|
||||
foregroundImage: variant.assets.androidAdaptiveForeground,
|
||||
monochromeImage: variant.assets.androidMonochromeIcon,
|
||||
},
|
||||
// Opts into OnBackInvokedCallback-based back dispatch (Android 13+).
|
||||
// JS back handling survives it via react-native's Android 16 shim plus
|
||||
@@ -165,7 +172,7 @@ const config: ExpoConfig = {
|
||||
predictiveBackGestureEnabled: true,
|
||||
},
|
||||
web: {
|
||||
favicon: "./assets/favicon.png",
|
||||
favicon: variant.assets.appIcon,
|
||||
},
|
||||
plugins: [
|
||||
"expo-asset",
|
||||
@@ -195,6 +202,14 @@ const config: ExpoConfig = {
|
||||
],
|
||||
"expo-secure-store",
|
||||
"expo-sqlite",
|
||||
[
|
||||
"expo-notifications",
|
||||
{
|
||||
icon: variant.assets.androidNotificationIcon,
|
||||
color: variant.assets.androidNotificationColor,
|
||||
mode: APP_VARIANT === "development" ? "development" : "production",
|
||||
},
|
||||
],
|
||||
// appleSignIn must be gated here: withoutIosPersonalTeamCapabilities.cjs runs before
|
||||
// plugins earlier in this array, so it cannot strip the entitlement Clerk would add.
|
||||
["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
|
||||
@@ -206,8 +221,8 @@ const config: ExpoConfig = {
|
||||
// the shortcut items set in src/features/shortcuts.
|
||||
androidIcons: {
|
||||
shortcut_icon: {
|
||||
foregroundImage: "./assets/android-icon-foreground.png",
|
||||
backgroundColor: "#E6F4FE",
|
||||
foregroundImage: variant.assets.androidAdaptiveForeground,
|
||||
backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -217,17 +232,18 @@ const config: ExpoConfig = {
|
||||
{
|
||||
cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
|
||||
barcodeScannerEnabled: true,
|
||||
recordAudioAndroid: false,
|
||||
},
|
||||
],
|
||||
[
|
||||
"expo-splash-screen",
|
||||
{
|
||||
image: variant.splashIcon,
|
||||
image: variant.assets.splashIcon,
|
||||
resizeMode: "contain",
|
||||
backgroundColor: "#ffffff",
|
||||
imageWidth: 220,
|
||||
dark: {
|
||||
image: variant.splashIcon,
|
||||
image: variant.assets.splashIcon,
|
||||
backgroundColor: "#0a0a0a",
|
||||
},
|
||||
},
|
||||
|
||||
|
Before Width: | Height: | Size: 323 KiB After Width: | Height: | Size: 323 KiB |
|
Before Width: | Height: | Size: 323 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 323 KiB |
|
After Width: | Height: | Size: 733 B |
|
Before Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
@@ -0,0 +1,315 @@
|
||||
package expo.modules.t3reviewdiff
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.LinearGradient
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Path
|
||||
import android.graphics.RectF
|
||||
import android.graphics.Shader
|
||||
import android.graphics.Typeface
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
internal class ReviewDiffCanvasDrawing(context: Context) {
|
||||
private val density = context.resources.displayMetrics.density
|
||||
var theme: DiffTheme = DiffTheme.fallback("light")
|
||||
|
||||
val backgroundPaint = Paint()
|
||||
val borderPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||
val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||
hinting = Paint.HINTING_ON
|
||||
isSubpixelText = false
|
||||
clearShadowLayer()
|
||||
}
|
||||
val uiPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||
hinting = Paint.HINTING_ON
|
||||
isSubpixelText = false
|
||||
clearShadowLayer()
|
||||
}
|
||||
|
||||
private val italicCodeTypeface by lazy {
|
||||
Typeface.create(ReviewDiffTypefaces.regular, Typeface.ITALIC)
|
||||
}
|
||||
private val boldItalicCodeTypeface by lazy {
|
||||
Typeface.create(ReviewDiffTypefaces.bold, Typeface.ITALIC)
|
||||
}
|
||||
|
||||
init {
|
||||
textPaint.typeface = ReviewDiffTypefaces.regular
|
||||
uiPaint.typeface = Typeface.DEFAULT_BOLD
|
||||
}
|
||||
|
||||
fun fileHeaderChevronRect(top: Int, bottom: Int, style: DiffStyle): RectF {
|
||||
val centerY = (top + bottom) / 2f
|
||||
val left = style.fileHeaderHorizontalPaddingPx
|
||||
return RectF(left, centerY - 10f * density, left + 20f * density, centerY + 10f * density)
|
||||
}
|
||||
|
||||
fun fileHeaderIconRect(top: Int, bottom: Int, style: DiffStyle): RectF {
|
||||
val chevron = fileHeaderChevronRect(top, bottom, style)
|
||||
return RectF(
|
||||
chevron.right + 8f * density,
|
||||
chevron.top,
|
||||
chevron.right + 28f * density,
|
||||
chevron.bottom,
|
||||
)
|
||||
}
|
||||
|
||||
fun fileHeaderCheckboxRect(top: Int, bottom: Int, width: Int, style: DiffStyle): RectF {
|
||||
val centerY = (top + bottom) / 2f
|
||||
val right = width - style.fileHeaderHorizontalPaddingPx
|
||||
return RectF(
|
||||
right - 20f * density,
|
||||
centerY - 10f * density,
|
||||
right,
|
||||
centerY + 10f * density,
|
||||
)
|
||||
}
|
||||
|
||||
fun drawDisclosureChevron(
|
||||
canvas: Canvas,
|
||||
rect: RectF,
|
||||
color: Int,
|
||||
collapsed: Boolean
|
||||
) {
|
||||
borderPaint.style = Paint.Style.STROKE
|
||||
borderPaint.color = color
|
||||
borderPaint.strokeWidth = 2f * density
|
||||
borderPaint.strokeCap = Paint.Cap.ROUND
|
||||
borderPaint.strokeJoin = Paint.Join.ROUND
|
||||
val path = Path()
|
||||
if (collapsed) {
|
||||
path.moveTo(rect.left + rect.width() * 0.4f, rect.top + rect.height() * 0.28f)
|
||||
path.lineTo(rect.left + rect.width() * 0.6f, rect.centerY())
|
||||
path.lineTo(rect.left + rect.width() * 0.4f, rect.bottom - rect.height() * 0.28f)
|
||||
} else {
|
||||
path.moveTo(rect.left + rect.width() * 0.28f, rect.top + rect.height() * 0.42f)
|
||||
path.lineTo(rect.centerX(), rect.top + rect.height() * 0.62f)
|
||||
path.lineTo(rect.right - rect.width() * 0.28f, rect.top + rect.height() * 0.42f)
|
||||
}
|
||||
canvas.drawPath(path, borderPaint)
|
||||
borderPaint.style = Paint.Style.FILL
|
||||
}
|
||||
|
||||
fun drawFileIcon(canvas: Canvas, rect: RectF, changeType: String) {
|
||||
val color = when (changeType) {
|
||||
"new" -> theme.addText
|
||||
"deleted" -> theme.deleteText
|
||||
else -> theme.hunkText
|
||||
}
|
||||
borderPaint.style = Paint.Style.STROKE
|
||||
borderPaint.color = color
|
||||
borderPaint.strokeWidth = 2f * density
|
||||
canvas.drawRoundRect(rect, 6f * density, 6f * density, borderPaint)
|
||||
|
||||
if (changeType == "rename-pure" || changeType == "rename-changed" || changeType == "renamed") {
|
||||
drawRenameChevronIcon(canvas, rect, color)
|
||||
} else {
|
||||
backgroundPaint.color = color
|
||||
canvas.drawCircle(rect.centerX(), rect.centerY(), 3f * density, backgroundPaint)
|
||||
}
|
||||
borderPaint.style = Paint.Style.FILL
|
||||
}
|
||||
|
||||
fun drawViewedCheckbox(canvas: Canvas, rect: RectF, checked: Boolean) {
|
||||
if (checked) {
|
||||
backgroundPaint.color = theme.hunkText
|
||||
canvas.drawRoundRect(rect, 6f * density, 6f * density, backgroundPaint)
|
||||
}
|
||||
borderPaint.style = Paint.Style.STROKE
|
||||
borderPaint.color = if (checked) theme.hunkText else theme.mutedText
|
||||
borderPaint.strokeWidth = 1.8f * density
|
||||
canvas.drawRoundRect(rect, 6f * density, 6f * density, borderPaint)
|
||||
if (checked) {
|
||||
borderPaint.color = theme.background
|
||||
borderPaint.strokeWidth = 2f * density
|
||||
borderPaint.strokeCap = Paint.Cap.ROUND
|
||||
borderPaint.strokeJoin = Paint.Join.ROUND
|
||||
val path = Path().apply {
|
||||
moveTo(rect.left + rect.width() * 0.28f, rect.centerY())
|
||||
lineTo(rect.left + rect.width() * 0.44f, rect.bottom - rect.height() * 0.3f)
|
||||
lineTo(rect.right - rect.width() * 0.25f, rect.top + rect.height() * 0.3f)
|
||||
}
|
||||
canvas.drawPath(path, borderPaint)
|
||||
}
|
||||
borderPaint.style = Paint.Style.FILL
|
||||
}
|
||||
|
||||
fun drawNoticeIcon(canvas: Canvas, rect: RectF, color: Int) {
|
||||
borderPaint.style = Paint.Style.STROKE
|
||||
borderPaint.color = color
|
||||
borderPaint.strokeWidth = 1.7f * density
|
||||
borderPaint.strokeCap = Paint.Cap.ROUND
|
||||
canvas.drawOval(rect, borderPaint)
|
||||
canvas.drawLine(
|
||||
rect.centerX(),
|
||||
rect.top + rect.height() * 0.3f,
|
||||
rect.centerX(),
|
||||
rect.top + rect.height() * 0.58f,
|
||||
borderPaint,
|
||||
)
|
||||
borderPaint.style = Paint.Style.FILL
|
||||
canvas.drawCircle(rect.centerX(), rect.bottom - rect.height() * 0.24f, density, borderPaint)
|
||||
}
|
||||
|
||||
fun configureUiPaint(paint: Paint, color: Int, size: Float, weight: String) {
|
||||
paint.typeface = if (isBoldFontWeight(weight)) Typeface.DEFAULT_BOLD else Typeface.DEFAULT
|
||||
configureTextPaint(paint, color, size)
|
||||
}
|
||||
|
||||
fun configureMonospacePaint(color: Int, size: Float, weight: String) {
|
||||
textPaint.typeface = ReviewDiffTypefaces.forWeight(weight)
|
||||
configureTextPaint(textPaint, color, size)
|
||||
}
|
||||
|
||||
fun configureCodePaint(color: Int, fontStyle: Int, style: DiffStyle) {
|
||||
val tokenBold = fontStyle and 2 != 0
|
||||
val italic = fontStyle and 1 != 0
|
||||
textPaint.typeface = when {
|
||||
tokenBold && italic -> boldItalicCodeTypeface
|
||||
tokenBold -> ReviewDiffTypefaces.bold
|
||||
italic -> italicCodeTypeface
|
||||
else -> ReviewDiffTypefaces.forWeight(style.codeFontWeight)
|
||||
}
|
||||
configureTextPaint(textPaint, color, style.codeFontSizePx)
|
||||
textPaint.isUnderlineText = fontStyle and 4 != 0
|
||||
}
|
||||
|
||||
fun lineNumberColor(change: String): Int = when (change) {
|
||||
"add" -> theme.addText
|
||||
"delete" -> theme.deleteText
|
||||
else -> theme.mutedText
|
||||
}
|
||||
|
||||
fun drawDeleteStripes(
|
||||
canvas: Canvas,
|
||||
top: Int,
|
||||
bottom: Int,
|
||||
width: Float,
|
||||
color: Int
|
||||
) {
|
||||
backgroundPaint.color = color
|
||||
var y = top.toFloat()
|
||||
while (y < bottom) {
|
||||
canvas.drawRect(0f, y, width, min(bottom.toFloat(), y + density), backgroundPaint)
|
||||
y += 2f * density
|
||||
}
|
||||
}
|
||||
|
||||
fun drawWordDiffRanges(
|
||||
canvas: Canvas,
|
||||
row: DiffRow,
|
||||
codeX: Float,
|
||||
top: Int,
|
||||
bottom: Int
|
||||
) {
|
||||
if (row.wordDiffRanges.isEmpty() || (row.change != "add" && row.change != "delete")) return
|
||||
val color = if (row.change == "add") theme.addBar else theme.deleteBar
|
||||
backgroundPaint.color = withAlpha(color, 71)
|
||||
val characterWidth = textPaint.measureText("M")
|
||||
val fontHeight = textPaint.fontMetrics.run { descent - ascent }
|
||||
val highlightHeight = max(4f * density, min(bottom - top - 4f * density, fontHeight))
|
||||
val highlightTop = (top + bottom - highlightHeight) / 2f
|
||||
row.wordDiffRanges.forEach { range ->
|
||||
val left = codeX + range.start * characterWidth
|
||||
val right = max(left + 2f * density, codeX + range.end * characterWidth)
|
||||
canvas.drawRoundRect(
|
||||
RectF(left, highlightTop, right, highlightTop + highlightHeight),
|
||||
3f * density,
|
||||
3f * density,
|
||||
backgroundPaint,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun drawFileHeaderPathScrollFades(
|
||||
canvas: Canvas,
|
||||
pathRect: RectF,
|
||||
horizontalOffset: Int,
|
||||
maxOffset: Int
|
||||
) {
|
||||
if (maxOffset <= 0 || pathRect.width() <= 0f) return
|
||||
val fadeWidth = min(28f * density, pathRect.width() / 3f)
|
||||
if (horizontalOffset > 0) {
|
||||
drawHorizontalFade(
|
||||
canvas,
|
||||
RectF(pathRect.left, pathRect.top, pathRect.left + fadeWidth, pathRect.bottom),
|
||||
fadesToRight = false,
|
||||
)
|
||||
}
|
||||
if (horizontalOffset < maxOffset) {
|
||||
drawHorizontalFade(
|
||||
canvas,
|
||||
RectF(pathRect.right - fadeWidth, pathRect.top, pathRect.right, pathRect.bottom),
|
||||
fadesToRight = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawRenameChevronIcon(canvas: Canvas, rect: RectF, color: Int) {
|
||||
borderPaint.style = Paint.Style.STROKE
|
||||
borderPaint.color = color
|
||||
borderPaint.strokeWidth = 1.8f * density
|
||||
borderPaint.strokeCap = Paint.Cap.ROUND
|
||||
borderPaint.strokeJoin = Paint.Join.ROUND
|
||||
val chevronWidth = 3.6f * density
|
||||
val chevronHeight = 8f * density
|
||||
val gap = 2.4f * density
|
||||
val startX = rect.centerX() - (chevronWidth * 2f + gap) / 2f
|
||||
val path = Path()
|
||||
for (x in listOf(startX, startX + chevronWidth + gap)) {
|
||||
path.moveTo(x, rect.centerY() - chevronHeight / 2f)
|
||||
path.lineTo(x + chevronWidth, rect.centerY())
|
||||
path.lineTo(x, rect.centerY() + chevronHeight / 2f)
|
||||
}
|
||||
canvas.drawPath(path, borderPaint)
|
||||
}
|
||||
|
||||
private fun configureTextPaint(paint: Paint, color: Int, size: Float) {
|
||||
paint.textSize = size
|
||||
paint.color = color
|
||||
paint.style = Paint.Style.FILL
|
||||
paint.textAlign = Paint.Align.LEFT
|
||||
paint.isUnderlineText = false
|
||||
paint.isFakeBoldText = false
|
||||
paint.clearShadowLayer()
|
||||
}
|
||||
|
||||
private fun drawHorizontalFade(canvas: Canvas, rect: RectF, fadesToRight: Boolean) {
|
||||
val opaque = theme.headerBackground
|
||||
val transparent = Color.argb(0, Color.red(opaque), Color.green(opaque), Color.blue(opaque))
|
||||
backgroundPaint.shader = LinearGradient(
|
||||
rect.left,
|
||||
rect.centerY(),
|
||||
rect.right,
|
||||
rect.centerY(),
|
||||
if (fadesToRight) transparent else opaque,
|
||||
if (fadesToRight) opaque else transparent,
|
||||
Shader.TileMode.CLAMP,
|
||||
)
|
||||
canvas.drawRect(rect, backgroundPaint)
|
||||
backgroundPaint.shader = null
|
||||
}
|
||||
|
||||
private fun isBoldFontWeight(weight: String): Boolean = when (weight.lowercase()) {
|
||||
"medium", "semibold", "semi-bold", "bold", "heavy", "black" -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
private fun withAlpha(color: Int, alpha: Int): Int =
|
||||
Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color))
|
||||
}
|
||||
|
||||
private object ReviewDiffTypefaces {
|
||||
val regular: Typeface = Typeface.create("monospace", Typeface.NORMAL)
|
||||
private val medium: Typeface = Typeface.create("monospace-medium", Typeface.NORMAL)
|
||||
val bold: Typeface = Typeface.create("monospace", Typeface.BOLD)
|
||||
|
||||
fun forWeight(weight: String): Typeface = when (weight.lowercase()) {
|
||||
"medium", "semibold", "semi-bold" -> medium
|
||||
"bold", "heavy", "black" -> bold
|
||||
else -> regular
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.RectF
|
||||
import android.view.GestureDetector
|
||||
import android.view.MotionEvent
|
||||
import android.view.VelocityTracker
|
||||
@@ -19,6 +19,7 @@ import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
@@ -49,12 +50,13 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
private val verticalScroller = OverScroller(context)
|
||||
private val horizontalScroller = OverScroller(context)
|
||||
private var dragAxis: DragAxis? = null
|
||||
private var horizontalDragTarget: HorizontalPanTarget? = null
|
||||
private var lastTouchX = 0f
|
||||
private var lastTouchY = 0f
|
||||
private var velocityTracker: VelocityTracker? = null
|
||||
|
||||
init {
|
||||
canvasView.onRowTap = { row, gesture -> handleRowTap(row, gesture) }
|
||||
canvasView.onRowTap = { row, gesture, target -> handleRowTap(row, gesture, target) }
|
||||
canvasView.onVisibleRowsChanged = { first, last ->
|
||||
onDebug(
|
||||
mapOf(
|
||||
@@ -86,12 +88,13 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
lastVisibleFileId = null
|
||||
pendingInitialScroll = true
|
||||
canvasView.setVerticalOffset(0)
|
||||
canvasView.setHorizontalOffset(0)
|
||||
canvasView.resetHorizontalOffsets()
|
||||
applyPendingInitialScroll()
|
||||
}
|
||||
|
||||
fun setCollapsedFileIdsJson(value: String) {
|
||||
collapsedFileIds = parseStringSet(value)
|
||||
canvasView.collapsedFileIds = collapsedFileIds
|
||||
rebuildVisibleRows()
|
||||
}
|
||||
|
||||
@@ -107,6 +110,7 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
|
||||
fun setCollapsedCommentIdsJson(value: String) {
|
||||
collapsedCommentIds = parseStringSet(value)
|
||||
canvasView.collapsedCommentIds = collapsedCommentIds
|
||||
rebuildVisibleRows()
|
||||
}
|
||||
|
||||
@@ -202,6 +206,7 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
verticalScroller.forceFinished(true)
|
||||
horizontalScroller.forceFinished(true)
|
||||
dragAxis = null
|
||||
horizontalDragTarget = canvasView.horizontalPanTarget(event.y)
|
||||
lastTouchX = event.x
|
||||
lastTouchY = event.y
|
||||
parent?.requestDisallowInterceptTouchEvent(true)
|
||||
@@ -212,7 +217,13 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
val deltaX = event.x - lastTouchX
|
||||
val deltaY = event.y - lastTouchY
|
||||
if (max(abs(deltaX), abs(deltaY)) > touchSlop) {
|
||||
dragAxis = if (abs(deltaY) >= abs(deltaX)) DragAxis.VERTICAL else DragAxis.HORIZONTAL
|
||||
dragAxis = if (abs(deltaY) >= abs(deltaX)) {
|
||||
DragAxis.VERTICAL
|
||||
} else {
|
||||
horizontalDragTarget
|
||||
?.takeIf { canvasView.maxHorizontalOffset(it) > 0 }
|
||||
?.let { DragAxis.HORIZONTAL }
|
||||
}
|
||||
}
|
||||
}
|
||||
return dragAxis != null
|
||||
@@ -238,6 +249,7 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
) {
|
||||
velocityTracker?.recycle()
|
||||
velocityTracker = null
|
||||
horizontalDragTarget = null
|
||||
parent?.requestDisallowInterceptTouchEvent(false)
|
||||
}
|
||||
return handled
|
||||
@@ -253,7 +265,7 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
if (axis == DragAxis.VERTICAL) {
|
||||
canvasView.scrollByVertical(deltaY)
|
||||
} else {
|
||||
canvasView.scrollByHorizontal(deltaX)
|
||||
horizontalDragTarget?.let { canvasView.scrollByHorizontal(deltaX, it) }
|
||||
}
|
||||
lastTouchX = event.x
|
||||
lastTouchY = event.y
|
||||
@@ -276,7 +288,7 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
)
|
||||
postInvalidateOnAnimation()
|
||||
}
|
||||
} else {
|
||||
} else if (horizontalDragTarget?.kind == HorizontalPanKind.CODE) {
|
||||
val velocity = -(velocityTracker?.xVelocity ?: 0f).toInt()
|
||||
if (abs(velocity) >= minimumFlingVelocity) {
|
||||
horizontalScroller.fling(
|
||||
@@ -294,6 +306,7 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
}
|
||||
}
|
||||
dragAxis = null
|
||||
horizontalDragTarget = null
|
||||
velocityTracker?.recycle()
|
||||
velocityTracker = null
|
||||
parent?.requestDisallowInterceptTouchEvent(false)
|
||||
@@ -325,11 +338,7 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
currentFileCollapsed = collapsedFileIds.contains(row.resolvedFileId)
|
||||
filtered.add(row)
|
||||
} else if (!currentFileCollapsed) {
|
||||
if (row.kind != "comment" || !collapsedCommentIds.contains(row.id)) {
|
||||
filtered.add(row)
|
||||
} else {
|
||||
filtered.add(row.copy(commentText = "Comment collapsed"))
|
||||
}
|
||||
filtered.add(row)
|
||||
}
|
||||
}
|
||||
visibleRows = filtered
|
||||
@@ -339,10 +348,11 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
applyPendingInitialScroll()
|
||||
}
|
||||
|
||||
private fun handleRowTap(row: DiffRow, gesture: String) {
|
||||
private fun handleRowTap(row: DiffRow, gesture: String, target: RowTapTarget) {
|
||||
when (row.kind) {
|
||||
"file" -> {
|
||||
if (gesture == "longPress") {
|
||||
if (gesture != "tap") return
|
||||
if (target == RowTapTarget.VIEWED_CHECKBOX) {
|
||||
onToggleViewedFile(mapOf("fileId" to row.resolvedFileId))
|
||||
} else {
|
||||
onToggleFile(mapOf("fileId" to row.resolvedFileId))
|
||||
@@ -408,7 +418,22 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
}
|
||||
}
|
||||
|
||||
private data class DiffRow(
|
||||
private enum class RowTapTarget {
|
||||
ROW,
|
||||
VIEWED_CHECKBOX
|
||||
}
|
||||
|
||||
private enum class HorizontalPanKind {
|
||||
CODE,
|
||||
FILE_HEADER_PATH
|
||||
}
|
||||
|
||||
private data class HorizontalPanTarget(
|
||||
val fileId: String,
|
||||
val kind: HorizontalPanKind
|
||||
)
|
||||
|
||||
internal data class DiffRow(
|
||||
val kind: String,
|
||||
val id: String,
|
||||
val fileId: String,
|
||||
@@ -422,6 +447,7 @@ private data class DiffRow(
|
||||
val change: String,
|
||||
val oldLineNumber: Int?,
|
||||
val newLineNumber: Int?,
|
||||
val wordDiffRanges: List<DiffWordDiffRange>,
|
||||
val commentText: String,
|
||||
val commentRangeLabel: String,
|
||||
val commentSectionTitle: String
|
||||
@@ -429,13 +455,18 @@ private data class DiffRow(
|
||||
val resolvedFileId: String get() = fileId.ifEmpty { id }
|
||||
}
|
||||
|
||||
internal data class DiffWordDiffRange(
|
||||
val start: Int,
|
||||
val end: Int
|
||||
)
|
||||
|
||||
private data class DiffToken(
|
||||
val content: String,
|
||||
val color: Int?,
|
||||
val fontStyle: Int
|
||||
)
|
||||
|
||||
private data class DiffTheme(
|
||||
internal data class DiffTheme(
|
||||
val background: Int,
|
||||
val text: Int,
|
||||
val mutedText: Int,
|
||||
@@ -511,14 +542,25 @@ private data class DiffTheme(
|
||||
}
|
||||
}
|
||||
|
||||
private data class DiffStyle(
|
||||
internal data class DiffStyle(
|
||||
val rowHeightPx: Float,
|
||||
val gutterWidthPx: Float,
|
||||
val codePaddingPx: Float,
|
||||
val changeBarWidthPx: Float,
|
||||
val fileHeaderHeightPx: Float,
|
||||
val fileHeaderHorizontalPaddingPx: Float,
|
||||
val codeFontSizePx: Float,
|
||||
val lineNumberFontSizePx: Float
|
||||
val codeFontWeight: String,
|
||||
val lineNumberFontSizePx: Float,
|
||||
val lineNumberFontWeight: String,
|
||||
val hunkFontSizePx: Float,
|
||||
val hunkFontWeight: String,
|
||||
val fileHeaderFontSizePx: Float,
|
||||
val fileHeaderFontWeight: String,
|
||||
val fileHeaderMetaFontSizePx: Float,
|
||||
val fileHeaderMetaFontWeight: String,
|
||||
val fileHeaderSubtextFontSizePx: Float,
|
||||
val fileHeaderSubtextFontWeight: String
|
||||
) {
|
||||
companion object {
|
||||
fun defaults(density: Float): DiffStyle = DiffStyle(
|
||||
@@ -527,8 +569,19 @@ private data class DiffStyle(
|
||||
codePaddingPx = 10f * density,
|
||||
changeBarWidthPx = 3f * density,
|
||||
fileHeaderHeightPx = 44f * density,
|
||||
fileHeaderHorizontalPaddingPx = 10f * density,
|
||||
codeFontSizePx = 12f * density,
|
||||
codeFontWeight = "regular",
|
||||
lineNumberFontSizePx = 10f * density,
|
||||
lineNumberFontWeight = "regular",
|
||||
hunkFontSizePx = 11f * density,
|
||||
hunkFontWeight = "medium",
|
||||
fileHeaderFontSizePx = 11f * density,
|
||||
fileHeaderFontWeight = "semibold",
|
||||
fileHeaderMetaFontSizePx = 10f * density,
|
||||
fileHeaderMetaFontWeight = "semibold",
|
||||
fileHeaderSubtextFontSizePx = 11f * density,
|
||||
fileHeaderSubtextFontWeight = "medium",
|
||||
)
|
||||
|
||||
fun fromJson(value: String, fallback: DiffStyle, density: Float): DiffStyle = try {
|
||||
@@ -539,11 +592,50 @@ private data class DiffStyle(
|
||||
codePaddingPx = json.floatDp("codePadding", fallback.codePaddingPx, density),
|
||||
changeBarWidthPx = json.floatDp("changeBarWidth", fallback.changeBarWidthPx, density),
|
||||
fileHeaderHeightPx = json.floatDp("fileHeaderHeight", fallback.fileHeaderHeightPx, density),
|
||||
fileHeaderHorizontalPaddingPx = json.floatDp(
|
||||
"fileHeaderHorizontalPadding",
|
||||
fallback.fileHeaderHorizontalPaddingPx,
|
||||
density,
|
||||
),
|
||||
codeFontSizePx = json.floatSp("codeFontSize", fallback.codeFontSizePx, density),
|
||||
codeFontWeight = json.optString("codeFontWeight", fallback.codeFontWeight),
|
||||
lineNumberFontSizePx = json.floatSp(
|
||||
"lineNumberFontSize",
|
||||
fallback.lineNumberFontSizePx,
|
||||
density
|
||||
density,
|
||||
),
|
||||
lineNumberFontWeight = json.optString(
|
||||
"lineNumberFontWeight",
|
||||
fallback.lineNumberFontWeight,
|
||||
),
|
||||
hunkFontSizePx = json.floatSp("hunkFontSize", fallback.hunkFontSizePx, density),
|
||||
hunkFontWeight = json.optString("hunkFontWeight", fallback.hunkFontWeight),
|
||||
fileHeaderFontSizePx = json.floatSp(
|
||||
"fileHeaderFontSize",
|
||||
fallback.fileHeaderFontSizePx,
|
||||
density,
|
||||
),
|
||||
fileHeaderFontWeight = json.optString(
|
||||
"fileHeaderFontWeight",
|
||||
fallback.fileHeaderFontWeight,
|
||||
),
|
||||
fileHeaderMetaFontSizePx = json.floatSp(
|
||||
"fileHeaderMetaFontSize",
|
||||
fallback.fileHeaderMetaFontSizePx,
|
||||
density,
|
||||
),
|
||||
fileHeaderMetaFontWeight = json.optString(
|
||||
"fileHeaderMetaFontWeight",
|
||||
fallback.fileHeaderMetaFontWeight,
|
||||
),
|
||||
fileHeaderSubtextFontSizePx = json.floatSp(
|
||||
"fileHeaderSubtextFontSize",
|
||||
fallback.fileHeaderSubtextFontSizePx,
|
||||
density,
|
||||
),
|
||||
fileHeaderSubtextFontWeight = json.optString(
|
||||
"fileHeaderSubtextFontWeight",
|
||||
fallback.fileHeaderSubtextFontWeight,
|
||||
),
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
@@ -554,35 +646,54 @@ private data class DiffStyle(
|
||||
|
||||
private class DiffCanvasView(context: Context) : View(context) {
|
||||
private val density = resources.displayMetrics.density
|
||||
private val backgroundPaint = Paint()
|
||||
private val borderPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||
private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { typeface = Typeface.MONOSPACE }
|
||||
private val boldTextPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||
typeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD)
|
||||
}
|
||||
private val drawing = ReviewDiffCanvasDrawing(context)
|
||||
private val backgroundPaint = drawing.backgroundPaint
|
||||
private val borderPaint = drawing.borderPaint
|
||||
private val textPaint = drawing.textPaint
|
||||
private val boldTextPaint = drawing.uiPaint
|
||||
private val gestureDetector = GestureDetector(
|
||||
context,
|
||||
object : GestureDetector.SimpleOnGestureListener() {
|
||||
override fun onDown(event: MotionEvent): Boolean = true
|
||||
|
||||
override fun onSingleTapUp(event: MotionEvent): Boolean {
|
||||
rowAt(event.y)?.let { onRowTap?.invoke(it, "tap") }
|
||||
rowHitAt(event.y)?.let { hit ->
|
||||
val target = if (
|
||||
hit.row.kind == "file" &&
|
||||
drawing.fileHeaderCheckboxRect(
|
||||
hit.top,
|
||||
hit.bottom,
|
||||
width,
|
||||
style
|
||||
).contains(event.x, event.y)
|
||||
) {
|
||||
RowTapTarget.VIEWED_CHECKBOX
|
||||
} else {
|
||||
RowTapTarget.ROW
|
||||
}
|
||||
onRowTap?.invoke(hit.row, "tap", target)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onLongPress(event: MotionEvent) {
|
||||
rowAt(event.y)?.let { onRowTap?.invoke(it, "longPress") }
|
||||
rowHitAt(event.y)?.row
|
||||
?.takeIf { it.kind == "line" }
|
||||
?.let { onRowTap?.invoke(it, "longPress", RowTapTarget.ROW) }
|
||||
}
|
||||
},
|
||||
)
|
||||
private var rowOffsets = intArrayOf(0)
|
||||
private var verticalOffset = 0
|
||||
private var horizontalOffset = 0
|
||||
private val headerPathOffsetsByFileId = mutableMapOf<String, Int>()
|
||||
private var lastVisibleRange: Pair<Int, Int>? = null
|
||||
|
||||
var rows: List<DiffRow> = emptyList()
|
||||
set(value) {
|
||||
field = value
|
||||
headerPathOffsetsByFileId.keys.retainAll(
|
||||
value.asSequence().filter { it.kind == "file" }.map { it.resolvedFileId }.toSet(),
|
||||
)
|
||||
rebuildOffsets()
|
||||
}
|
||||
var tokensByRowId: Map<String, List<DiffToken>> = emptyMap()
|
||||
@@ -595,6 +706,16 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
field = value
|
||||
invalidate()
|
||||
}
|
||||
var collapsedFileIds: Set<String> = emptySet()
|
||||
set(value) {
|
||||
field = value
|
||||
invalidate()
|
||||
}
|
||||
var collapsedCommentIds: Set<String> = emptySet()
|
||||
set(value) {
|
||||
field = value
|
||||
rebuildOffsets()
|
||||
}
|
||||
var selectedRowIds: Set<String> = emptySet()
|
||||
set(value) {
|
||||
field = value
|
||||
@@ -603,6 +724,7 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
var theme: DiffTheme = DiffTheme.fallback("light")
|
||||
set(value) {
|
||||
field = value
|
||||
drawing.theme = value
|
||||
invalidate()
|
||||
}
|
||||
var style: DiffStyle = DiffStyle.defaults(density)
|
||||
@@ -614,9 +736,10 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
set(value) {
|
||||
field = max(value, suggestedMinimumWidth)
|
||||
setHorizontalOffset(horizontalOffset)
|
||||
clampHeaderPathOffsets()
|
||||
invalidate()
|
||||
}
|
||||
var onRowTap: ((DiffRow, String) -> Unit)? = null
|
||||
var onRowTap: ((DiffRow, String, RowTapTarget) -> Unit)? = null
|
||||
var onVisibleRowsChanged: ((Int, Int) -> Unit)? = null
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
@@ -630,6 +753,7 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
super.onSizeChanged(width, height, oldWidth, oldHeight)
|
||||
setVerticalOffset(verticalOffset)
|
||||
setHorizontalOffset(horizontalOffset)
|
||||
clampHeaderPathOffsets()
|
||||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
@@ -681,27 +805,63 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
invalidate()
|
||||
}
|
||||
|
||||
fun scrollByHorizontal(delta: Int) {
|
||||
setHorizontalOffset(horizontalOffset + delta)
|
||||
fun scrollByHorizontal(delta: Int, target: HorizontalPanTarget) {
|
||||
if (target.kind == HorizontalPanKind.FILE_HEADER_PATH) {
|
||||
setHeaderPathOffset(
|
||||
target.fileId,
|
||||
(headerPathOffsetsByFileId[target.fileId] ?: 0) + delta,
|
||||
)
|
||||
} else {
|
||||
setHorizontalOffset(horizontalOffset + delta)
|
||||
}
|
||||
}
|
||||
|
||||
fun horizontalOffset(): Int = horizontalOffset
|
||||
|
||||
fun maxHorizontalOffset(): Int = max(0, contentWidthPx - width)
|
||||
|
||||
fun maxHorizontalOffset(target: HorizontalPanTarget): Int =
|
||||
if (target.kind == HorizontalPanKind.FILE_HEADER_PATH) {
|
||||
maxHeaderPathOffset(target.fileId)
|
||||
} else {
|
||||
maxHorizontalOffset()
|
||||
}
|
||||
|
||||
fun horizontalPanTarget(y: Float): HorizontalPanTarget? {
|
||||
val row = rowHitAt(y)?.row ?: return null
|
||||
return HorizontalPanTarget(
|
||||
fileId = row.resolvedFileId,
|
||||
kind = if (row.kind == "file") HorizontalPanKind.FILE_HEADER_PATH else HorizontalPanKind.CODE,
|
||||
)
|
||||
}
|
||||
|
||||
fun resetHorizontalOffsets() {
|
||||
setHorizontalOffset(0)
|
||||
if (headerPathOffsetsByFileId.isNotEmpty()) {
|
||||
headerPathOffsetsByFileId.clear()
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
|
||||
private fun rebuildOffsets() {
|
||||
rowOffsets = IntArray(rows.size + 1)
|
||||
rows.forEachIndexed { index, row ->
|
||||
rowOffsets[index + 1] = rowOffsets[index] + rowHeight(row)
|
||||
}
|
||||
setVerticalOffset(verticalOffset)
|
||||
clampHeaderPathOffsets()
|
||||
requestLayout()
|
||||
invalidate()
|
||||
}
|
||||
|
||||
private fun rowHeight(row: DiffRow): Int = when (row.kind) {
|
||||
"file" -> style.fileHeaderHeightPx.toInt()
|
||||
"comment" -> max((style.rowHeightPx * 3.2f).toInt(), (56 * density).toInt())
|
||||
"notice" -> max((style.rowHeightPx * 2f).toInt(), (44 * density).toInt())
|
||||
"comment" -> if (collapsedCommentIds.contains(row.id)) {
|
||||
(44 * density).toInt()
|
||||
} else {
|
||||
(124 * density).toInt()
|
||||
}
|
||||
else -> style.rowHeightPx.toInt()
|
||||
}.coerceAtLeast(1)
|
||||
|
||||
@@ -721,13 +881,20 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
return low.coerceIn(0, rows.lastIndex)
|
||||
}
|
||||
|
||||
private fun rowAt(y: Float): DiffRow? {
|
||||
private fun rowHitAt(y: Float): RowHit? {
|
||||
stickyFileHeader(firstVisibleRow())?.let { sticky ->
|
||||
if (y >= max(0, sticky.top).toFloat() && y < sticky.bottom.toFloat()) {
|
||||
return rows.getOrNull(sticky.index)
|
||||
return rows.getOrNull(sticky.index)?.let { RowHit(it, sticky.top, sticky.bottom) }
|
||||
}
|
||||
}
|
||||
return rows.getOrNull(rowIndexAt(verticalOffset + y.toInt()))
|
||||
val index = rowIndexAt(verticalOffset + y.toInt())
|
||||
return rows.getOrNull(index)?.let {
|
||||
RowHit(
|
||||
row = it,
|
||||
top = rowOffsets[index] - verticalOffset,
|
||||
bottom = rowOffsets[index + 1] - verticalOffset,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun firstVisibleRow(): Int = rowIndexAt(verticalOffset)
|
||||
@@ -754,23 +921,140 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
|
||||
private fun drawFileRow(canvas: Canvas, row: DiffRow, top: Int, bottom: Int) {
|
||||
fill(canvas, theme.headerBackground, 0f, top.toFloat(), width.toFloat(), bottom.toFloat())
|
||||
val baseline = centeredBaseline(top, bottom, boldTextPaint.apply { textSize = 13f * density })
|
||||
boldTextPaint.color = theme.text
|
||||
val marker = if (viewedFileIds.contains(row.resolvedFileId)) "[x] " else "[ ] "
|
||||
textPaint.color = theme.mutedText
|
||||
textPaint.textSize = 11f * density
|
||||
val stats = "+${row.additions} -${row.deletions}"
|
||||
val statsX = max(12f * density, width - textPaint.measureText(stats) - 16f * density)
|
||||
val title = ellipsize(marker + row.filePath, boldTextPaint, statsX - 28f * density)
|
||||
canvas.drawText(title, 12f * density, baseline, boldTextPaint)
|
||||
canvas.drawText(stats, statsX, baseline, textPaint)
|
||||
|
||||
val chevronRect = drawing.fileHeaderChevronRect(top, bottom, style)
|
||||
val iconRect = drawing.fileHeaderIconRect(top, bottom, style)
|
||||
val checkboxRect = drawing.fileHeaderCheckboxRect(top, bottom, width, style)
|
||||
drawing.drawDisclosureChevron(
|
||||
canvas,
|
||||
chevronRect,
|
||||
theme.mutedText,
|
||||
collapsed = collapsedFileIds.contains(row.resolvedFileId),
|
||||
)
|
||||
drawing.drawFileIcon(canvas, iconRect, row.changeType)
|
||||
drawing.drawViewedCheckbox(
|
||||
canvas,
|
||||
checkboxRect,
|
||||
viewedFileIds.contains(row.resolvedFileId),
|
||||
)
|
||||
|
||||
drawing.configureUiPaint(
|
||||
paint = boldTextPaint,
|
||||
color = theme.deleteText,
|
||||
size = style.fileHeaderMetaFontSizePx,
|
||||
weight = style.fileHeaderMetaFontWeight,
|
||||
)
|
||||
val deleteText = "-${row.deletions}"
|
||||
val deleteWidth = boldTextPaint.measureText(deleteText)
|
||||
val addText = "+${row.additions}"
|
||||
val addWidth = boldTextPaint.measureText(addText)
|
||||
val countGap = 4f * density
|
||||
val countsX = checkboxRect.left - 10f * density - deleteWidth - countGap - addWidth
|
||||
val baseline = centeredBaseline(top, bottom, boldTextPaint)
|
||||
canvas.drawText(deleteText, countsX, baseline, boldTextPaint)
|
||||
boldTextPaint.color = theme.addText
|
||||
canvas.drawText(addText, countsX + deleteWidth + countGap, baseline, boldTextPaint)
|
||||
|
||||
val pathLayout = fileHeaderPathLayout(row, top, bottom, iconRect, countsX)
|
||||
val maxPathOffset = maxHeaderPathOffset(pathLayout)
|
||||
val pathOffset = (headerPathOffsetsByFileId[row.resolvedFileId] ?: 0)
|
||||
.coerceIn(0, maxPathOffset)
|
||||
canvas.save()
|
||||
canvas.clipRect(pathLayout.rect)
|
||||
canvas.drawText(
|
||||
pathLayout.displayPath,
|
||||
pathLayout.rect.left - pathOffset,
|
||||
centeredBaseline(top, bottom, boldTextPaint),
|
||||
boldTextPaint,
|
||||
)
|
||||
canvas.restore()
|
||||
drawing.drawFileHeaderPathScrollFades(
|
||||
canvas,
|
||||
pathLayout.rect,
|
||||
pathOffset,
|
||||
maxPathOffset,
|
||||
)
|
||||
drawBottomBorder(canvas, bottom)
|
||||
}
|
||||
|
||||
private fun fileHeaderPathLayout(
|
||||
row: DiffRow,
|
||||
top: Int,
|
||||
bottom: Int,
|
||||
iconRect: RectF,
|
||||
countsX: Float
|
||||
): FileHeaderPathLayout {
|
||||
drawing.configureUiPaint(
|
||||
paint = boldTextPaint,
|
||||
color = theme.text,
|
||||
size = style.fileHeaderFontSizePx,
|
||||
weight = style.fileHeaderFontWeight,
|
||||
)
|
||||
val pathX = iconRect.right + 10f * density
|
||||
val pathWidth = max(24f * density, countsX - pathX - 12f * density)
|
||||
val centerY = (top + bottom) / 2f
|
||||
val displayPath = if (
|
||||
!row.previousPath.isNullOrEmpty() && row.previousPath != row.filePath
|
||||
) {
|
||||
"${row.previousPath} -> ${row.filePath}"
|
||||
} else {
|
||||
row.filePath
|
||||
}
|
||||
return FileHeaderPathLayout(
|
||||
displayPath = displayPath,
|
||||
rect = RectF(pathX, centerY - 10f * density, pathX + pathWidth, centerY + 10f * density),
|
||||
)
|
||||
}
|
||||
|
||||
private fun maxHeaderPathOffset(fileId: String): Int {
|
||||
val row = rows.firstOrNull { it.kind == "file" && it.resolvedFileId == fileId } ?: return 0
|
||||
val top = 0
|
||||
val bottom = rowHeight(row)
|
||||
val iconRect = drawing.fileHeaderIconRect(top, bottom, style)
|
||||
val checkboxRect = drawing.fileHeaderCheckboxRect(top, bottom, width, style)
|
||||
drawing.configureUiPaint(
|
||||
paint = boldTextPaint,
|
||||
color = theme.deleteText,
|
||||
size = style.fileHeaderMetaFontSizePx,
|
||||
weight = style.fileHeaderMetaFontWeight,
|
||||
)
|
||||
val countsX = checkboxRect.left - 10f * density -
|
||||
boldTextPaint.measureText("-${row.deletions}") - 4f * density -
|
||||
boldTextPaint.measureText("+${row.additions}")
|
||||
return maxHeaderPathOffset(fileHeaderPathLayout(row, top, bottom, iconRect, countsX))
|
||||
}
|
||||
|
||||
private fun maxHeaderPathOffset(layout: FileHeaderPathLayout): Int = max(
|
||||
0,
|
||||
ceil(boldTextPaint.measureText(layout.displayPath) - layout.rect.width()).toInt(),
|
||||
)
|
||||
|
||||
private fun setHeaderPathOffset(fileId: String, value: Int) {
|
||||
val nextOffset = value.coerceIn(0, maxHeaderPathOffset(fileId))
|
||||
if ((headerPathOffsetsByFileId[fileId] ?: 0) == nextOffset) return
|
||||
headerPathOffsetsByFileId[fileId] = nextOffset
|
||||
invalidate()
|
||||
}
|
||||
|
||||
private fun clampHeaderPathOffsets() {
|
||||
headerPathOffsetsByFileId.keys.toList().forEach { fileId ->
|
||||
val nextOffset = (headerPathOffsetsByFileId[fileId] ?: 0)
|
||||
.coerceIn(0, maxHeaderPathOffset(fileId))
|
||||
if (nextOffset == 0) {
|
||||
headerPathOffsetsByFileId.remove(fileId)
|
||||
} else {
|
||||
headerPathOffsetsByFileId[fileId] = nextOffset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawHunkRow(canvas: Canvas, row: DiffRow, top: Int, bottom: Int) {
|
||||
fill(canvas, theme.hunkBackground, 0f, top.toFloat(), width.toFloat(), bottom.toFloat())
|
||||
textPaint.color = theme.hunkText
|
||||
textPaint.textSize = style.codeFontSizePx
|
||||
drawing.configureMonospacePaint(
|
||||
color = theme.hunkText,
|
||||
size = style.hunkFontSizePx,
|
||||
weight = style.hunkFontWeight,
|
||||
)
|
||||
drawScrollableCode(canvas, top, bottom) { codeX ->
|
||||
canvas.drawText(
|
||||
row.text.ifEmpty { row.content },
|
||||
@@ -782,36 +1066,82 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
}
|
||||
|
||||
private fun drawNoticeRow(canvas: Canvas, row: DiffRow, top: Int, bottom: Int) {
|
||||
textPaint.color = theme.mutedText
|
||||
textPaint.textSize = style.codeFontSizePx
|
||||
drawScrollableCode(canvas, top, bottom) { codeX ->
|
||||
canvas.drawText(row.text, codeX, centeredBaseline(top, bottom, textPaint), textPaint)
|
||||
}
|
||||
fill(canvas, theme.background, 0f, top.toFloat(), width.toFloat(), bottom.toFloat())
|
||||
val iconSize = 16f * density
|
||||
val iconRect = RectF(
|
||||
style.fileHeaderHorizontalPaddingPx + 2f * density,
|
||||
(top + bottom - iconSize) / 2f,
|
||||
style.fileHeaderHorizontalPaddingPx + 2f * density + iconSize,
|
||||
(top + bottom + iconSize) / 2f,
|
||||
)
|
||||
drawing.drawNoticeIcon(canvas, iconRect, theme.mutedText)
|
||||
drawing.configureUiPaint(
|
||||
paint = textPaint,
|
||||
color = theme.mutedText,
|
||||
size = style.fileHeaderSubtextFontSizePx,
|
||||
weight = style.fileHeaderSubtextFontWeight,
|
||||
)
|
||||
val textX = iconRect.right + 10f * density
|
||||
canvas.drawText(
|
||||
ellipsize(row.text, textPaint, width - textX - style.fileHeaderHorizontalPaddingPx),
|
||||
textX,
|
||||
centeredBaseline(top, bottom, textPaint),
|
||||
textPaint,
|
||||
)
|
||||
drawBottomBorder(canvas, bottom)
|
||||
}
|
||||
|
||||
private fun drawCommentRow(canvas: Canvas, row: DiffRow, top: Int, bottom: Int) {
|
||||
fill(
|
||||
canvas,
|
||||
theme.headerBackground,
|
||||
style.gutterWidthPx,
|
||||
top.toFloat(),
|
||||
width.toFloat(),
|
||||
bottom.toFloat()
|
||||
fill(canvas, theme.background, 0f, top.toFloat(), width.toFloat(), bottom.toFloat())
|
||||
val cardRect = RectF(
|
||||
8f * density,
|
||||
top + 5f * density,
|
||||
width - 8f * density,
|
||||
bottom - 5f * density,
|
||||
)
|
||||
boldTextPaint.color = theme.text
|
||||
boldTextPaint.textSize = 12f * density
|
||||
drawScrollableCode(canvas, top, bottom) { codeX ->
|
||||
backgroundPaint.color = theme.headerBackground
|
||||
canvas.drawRoundRect(cardRect, 10f * density, 10f * density, backgroundPaint)
|
||||
borderPaint.style = Paint.Style.STROKE
|
||||
borderPaint.color = withAlpha(theme.border, 217)
|
||||
borderPaint.strokeWidth = density
|
||||
canvas.drawRoundRect(cardRect, 10f * density, 10f * density, borderPaint)
|
||||
borderPaint.style = Paint.Style.FILL
|
||||
|
||||
val collapsed = collapsedCommentIds.contains(row.id)
|
||||
val chevronRect = RectF(
|
||||
cardRect.left + 10f * density,
|
||||
cardRect.top + 11f * density,
|
||||
cardRect.left + 26f * density,
|
||||
cardRect.top + 27f * density,
|
||||
)
|
||||
drawing.drawDisclosureChevron(canvas, chevronRect, theme.mutedText, collapsed)
|
||||
drawing.configureUiPaint(
|
||||
paint = textPaint,
|
||||
color = theme.mutedText,
|
||||
size = style.fileHeaderSubtextFontSizePx,
|
||||
weight = style.fileHeaderSubtextFontWeight,
|
||||
)
|
||||
val title = "Comment on ${row.commentRangeLabel.ifEmpty { "line" }}"
|
||||
canvas.drawText(
|
||||
ellipsize(title, textPaint, cardRect.right - chevronRect.right - 20f * density),
|
||||
chevronRect.right + 10f * density,
|
||||
cardRect.top + 22f * density,
|
||||
textPaint,
|
||||
)
|
||||
if (!collapsed) {
|
||||
textPaint.color = theme.text
|
||||
val bodyX = cardRect.left + 18f * density
|
||||
canvas.drawText(
|
||||
row.commentSectionTitle.ifEmpty { row.commentRangeLabel.ifEmpty { "Comment" } },
|
||||
codeX,
|
||||
top + 20f * density,
|
||||
boldTextPaint,
|
||||
ellipsize(
|
||||
row.commentText.ifEmpty { "Comment" },
|
||||
textPaint,
|
||||
cardRect.right - bodyX - 18f * density
|
||||
),
|
||||
bodyX,
|
||||
cardRect.top + 58f * density,
|
||||
textPaint,
|
||||
)
|
||||
textPaint.color = theme.mutedText
|
||||
textPaint.textSize = 12f * density
|
||||
canvas.drawText(row.commentText, codeX, top + 42f * density, textPaint)
|
||||
}
|
||||
drawBottomBorder(canvas, bottom)
|
||||
}
|
||||
|
||||
@Suppress("CyclomaticComplexMethod")
|
||||
@@ -822,65 +1152,79 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
else -> theme.background
|
||||
}
|
||||
fill(canvas, background, 0f, top.toFloat(), width.toFloat(), bottom.toFloat())
|
||||
if (style.changeBarWidthPx > 0) {
|
||||
when (row.change) {
|
||||
"add" -> fill(
|
||||
canvas,
|
||||
theme.addBar,
|
||||
0f,
|
||||
top.toFloat(),
|
||||
style.changeBarWidthPx,
|
||||
bottom.toFloat()
|
||||
)
|
||||
"delete" -> drawing.drawDeleteStripes(
|
||||
canvas,
|
||||
top,
|
||||
bottom,
|
||||
style.changeBarWidthPx,
|
||||
theme.deleteBar,
|
||||
)
|
||||
}
|
||||
}
|
||||
val selected = selectedRowIds.contains(row.id)
|
||||
if (selected) {
|
||||
fill(
|
||||
canvas,
|
||||
withAlpha(theme.hunkText, if (theme.background == Color.WHITE) 54 else 76),
|
||||
withAlpha(theme.hunkText, 56),
|
||||
0f,
|
||||
top.toFloat(),
|
||||
width.toFloat(),
|
||||
bottom.toFloat(),
|
||||
)
|
||||
}
|
||||
val barColor = when (row.change) {
|
||||
"add" -> theme.addBar
|
||||
"delete" -> theme.deleteBar
|
||||
else -> Color.TRANSPARENT
|
||||
}
|
||||
if (barColor != Color.TRANSPARENT && style.changeBarWidthPx > 0) {
|
||||
fill(canvas, barColor, 0f, top.toFloat(), style.changeBarWidthPx, bottom.toFloat())
|
||||
fill(
|
||||
canvas,
|
||||
withAlpha(theme.hunkText, 242),
|
||||
0f,
|
||||
top.toFloat(),
|
||||
style.changeBarWidthPx,
|
||||
bottom.toFloat()
|
||||
)
|
||||
}
|
||||
|
||||
val tokens = tokensByRowId[row.id]
|
||||
drawScrollableCode(canvas, top, bottom) { codeX ->
|
||||
drawing.configureCodePaint(theme.text, 0, style)
|
||||
drawing.drawWordDiffRanges(canvas, row, codeX, top, bottom)
|
||||
if (tokens.isNullOrEmpty()) {
|
||||
textPaint.textSize = style.codeFontSizePx
|
||||
textPaint.color = when (row.change) {
|
||||
"add" -> theme.addText
|
||||
"delete" -> theme.deleteText
|
||||
else -> theme.text
|
||||
}
|
||||
canvas.drawText(row.content, codeX, centeredBaseline(top, bottom, textPaint), textPaint)
|
||||
} else {
|
||||
var x = codeX
|
||||
tokens.forEach { token ->
|
||||
textPaint.textSize = style.codeFontSizePx
|
||||
textPaint.color = token.color ?: theme.text
|
||||
textPaint.typeface = when {
|
||||
token.fontStyle and 1 != 0 -> Typeface.create(Typeface.MONOSPACE, Typeface.ITALIC)
|
||||
token.fontStyle and 2 != 0 -> Typeface.create(Typeface.MONOSPACE, Typeface.BOLD)
|
||||
else -> Typeface.MONOSPACE
|
||||
}
|
||||
drawing.configureCodePaint(token.color ?: theme.text, token.fontStyle, style)
|
||||
canvas.drawText(token.content, x, centeredBaseline(top, bottom, textPaint), textPaint)
|
||||
x += textPaint.measureText(token.content)
|
||||
}
|
||||
textPaint.typeface = Typeface.MONOSPACE
|
||||
}
|
||||
}
|
||||
|
||||
textPaint.textSize = style.lineNumberFontSizePx
|
||||
textPaint.color = if (selected) theme.text else theme.mutedText
|
||||
val oldNumber = row.oldLineNumber?.toString().orEmpty()
|
||||
val newNumber = row.newLineNumber?.toString().orEmpty()
|
||||
val baseline = centeredBaseline(top, bottom, textPaint)
|
||||
canvas.drawText(oldNumber, style.changeBarWidthPx + 6f * density, baseline, textPaint)
|
||||
canvas.drawText(
|
||||
newNumber,
|
||||
style.changeBarWidthPx + style.gutterWidthPx / 2f,
|
||||
baseline,
|
||||
textPaint
|
||||
drawLineNumber(canvas, row, top, bottom)
|
||||
}
|
||||
|
||||
private fun drawLineNumber(canvas: Canvas, row: DiffRow, top: Int, bottom: Int) {
|
||||
val lineNumber = row.newLineNumber ?: row.oldLineNumber ?: return
|
||||
drawing.configureMonospacePaint(
|
||||
color = drawing.lineNumberColor(row.change),
|
||||
size = style.lineNumberFontSizePx,
|
||||
weight = style.lineNumberFontWeight,
|
||||
)
|
||||
textPaint.textAlign = Paint.Align.RIGHT
|
||||
canvas.drawText(
|
||||
lineNumber.toString(),
|
||||
style.changeBarWidthPx + style.gutterWidthPx - style.codePaddingPx,
|
||||
centeredBaseline(top, bottom, textPaint),
|
||||
textPaint,
|
||||
)
|
||||
textPaint.textAlign = Paint.Align.LEFT
|
||||
}
|
||||
|
||||
private fun drawScrollableCode(
|
||||
@@ -972,6 +1316,17 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
val top: Int,
|
||||
val bottom: Int
|
||||
)
|
||||
|
||||
private data class RowHit(
|
||||
val row: DiffRow,
|
||||
val top: Int,
|
||||
val bottom: Int
|
||||
)
|
||||
|
||||
private data class FileHeaderPathLayout(
|
||||
val displayPath: String,
|
||||
val rect: RectF
|
||||
)
|
||||
}
|
||||
|
||||
private fun withAlpha(color: Int, alpha: Int): Int =
|
||||
@@ -995,6 +1350,7 @@ private fun parseRows(value: String): List<DiffRow> = try {
|
||||
change = row.optString("change", "context"),
|
||||
oldLineNumber = row.optNullableInt("oldLineNumber"),
|
||||
newLineNumber = row.optNullableInt("newLineNumber"),
|
||||
wordDiffRanges = row.optJSONArray("wordDiffRanges")?.let(::parseWordDiffRanges).orEmpty(),
|
||||
commentText = row.optString("commentText"),
|
||||
commentRangeLabel = row.optString("commentRangeLabel"),
|
||||
commentSectionTitle = row.optString("commentSectionTitle"),
|
||||
@@ -1004,6 +1360,17 @@ private fun parseRows(value: String): List<DiffRow> = try {
|
||||
emptyList()
|
||||
}
|
||||
|
||||
private fun parseWordDiffRanges(value: JSONArray): List<DiffWordDiffRange> = buildList {
|
||||
for (index in 0 until value.length()) {
|
||||
val range = value.optJSONObject(index) ?: continue
|
||||
val start = range.optInt("start", -1)
|
||||
val end = range.optInt("end", -1)
|
||||
if (start >= 0 && end > start) {
|
||||
add(DiffWordDiffRange(start = start, end = end))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseTokensObject(value: String): Map<String, List<DiffToken>> = try {
|
||||
parseTokensObject(JSONObject(value))
|
||||
} catch (_: Exception) {
|
||||
@@ -1020,7 +1387,7 @@ private fun parseTokensObject(value: JSONObject): Map<String, List<DiffToken>> {
|
||||
val token = array.getJSONObject(index)
|
||||
DiffToken(
|
||||
content = token.optString("content"),
|
||||
color = token.optNullableString("color")?.let { parseColor(it, Color.TRANSPARENT) },
|
||||
color = token.optNullableString("color")?.let(::parseColorOrNull),
|
||||
fontStyle = token.optInt("fontStyle"),
|
||||
)
|
||||
}
|
||||
@@ -1043,6 +1410,12 @@ private fun parseColor(value: String, fallback: Int): Int = try {
|
||||
fallback
|
||||
}
|
||||
|
||||
private fun parseColorOrNull(value: String): Int? = try {
|
||||
Color.parseColor(value)
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
|
||||
private fun JSONObject.optNullableString(key: String): String? =
|
||||
if (isNull(key)) null else optString(key).takeIf { it.isNotEmpty() }
|
||||
|
||||
|
||||
@@ -440,9 +440,9 @@ export const RootStack = createNativeStackNavigator({
|
||||
screen: ConnectOnboardingRouteScreen,
|
||||
linking: "connect-onboarding",
|
||||
options: {
|
||||
// Root screenOptions hide headers; formSheets that want the native
|
||||
// title bar opt back in with the sheet header preset.
|
||||
...SHEET_SOLID_HEADER_OPTIONS,
|
||||
// A root-level Android formSheet does not host the native stack bar;
|
||||
// the route renders an embedded AndroidSheetHeader instead.
|
||||
...(Platform.OS === "android" ? { headerShown: false } : SHEET_SOLID_HEADER_OPTIONS),
|
||||
title: "Set up T3 Connect",
|
||||
gestureEnabled: true,
|
||||
presentation: "formSheet",
|
||||
|
||||
@@ -51,6 +51,7 @@ export function AndroidScreenHeader(props: {
|
||||
readonly actions?: ReadonlyArray<AndroidHeaderAction>;
|
||||
readonly trailing?: ReactNode;
|
||||
readonly onBack?: () => void;
|
||||
readonly embedded?: boolean;
|
||||
}) {
|
||||
const insets = useSafeAreaInsets();
|
||||
const foregroundColor = useThemeColor("--color-foreground");
|
||||
@@ -59,7 +60,7 @@ export function AndroidScreenHeader(props: {
|
||||
<View
|
||||
className="border-b border-header-border bg-header px-3 pb-2.5"
|
||||
style={{
|
||||
paddingTop: Math.max(insets.top, 12),
|
||||
paddingTop: props.embedded ? 8 : Math.max(insets.top, 12),
|
||||
}}
|
||||
>
|
||||
<View className="min-h-12 flex-row items-center gap-2">
|
||||
@@ -108,3 +109,9 @@ export function AndroidScreenHeader(props: {
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export function AndroidSheetHeader(
|
||||
props: Omit<Parameters<typeof AndroidScreenHeader>[0], "embedded">,
|
||||
) {
|
||||
return <AndroidScreenHeader {...props} embedded />;
|
||||
}
|
||||
@@ -41,6 +41,8 @@ function makeThread(
|
||||
hasPendingUserInput: false,
|
||||
hasActionableProposedPlan: false,
|
||||
...input,
|
||||
settledOverride: input.settledOverride ?? null,
|
||||
settledAt: input.settledAt ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,11 @@ import { NativeHeaderToolbar } from "../../native/StackHeader";
|
||||
import { useAuth } from "@clerk/expo";
|
||||
import { StackActions, useNavigation } from "@react-navigation/native";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { Pressable, RefreshControl, ScrollView, View } from "react-native";
|
||||
import { Platform, Pressable, RefreshControl, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { reportAtomCommandResult, settlePromise } from "@t3tools/client-runtime/state/runtime";
|
||||
import { AndroidSheetHeader } from "../../components/AndroidScreenHeader";
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
|
||||
import { CloudEnvironmentRows } from "../connection/CloudEnvironmentRows";
|
||||
@@ -81,9 +82,16 @@ function ConfiguredConnectOnboardingRouteScreen() {
|
||||
|
||||
return (
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
<NativeHeaderToolbar placement="right">
|
||||
<NativeHeaderToolbar.Button icon="xmark" onPress={handleClose} separateBackground />
|
||||
</NativeHeaderToolbar>
|
||||
{Platform.OS === "android" ? (
|
||||
<AndroidSheetHeader
|
||||
title="Set up T3 Connect"
|
||||
actions={[{ accessibilityLabel: "Close", icon: "xmark", onPress: handleClose }]}
|
||||
/>
|
||||
) : (
|
||||
<NativeHeaderToolbar placement="right">
|
||||
<NativeHeaderToolbar.Button icon="xmark" onPress={handleClose} separateBackground />
|
||||
</NativeHeaderToolbar>
|
||||
)}
|
||||
<ScrollView
|
||||
alwaysBounceVertical
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
|
||||
@@ -47,6 +47,8 @@ function makeThread(id: string, projectId: ProjectId): EnvironmentThreadShell {
|
||||
createdAt: "2026-06-01T00:00:00.000Z",
|
||||
updatedAt: "2026-06-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
session: null,
|
||||
latestUserMessageAt: null,
|
||||
hasPendingApprovals: false,
|
||||
|
||||
@@ -41,6 +41,8 @@ function makeThread(
|
||||
hasPendingUserInput: false,
|
||||
hasActionableProposedPlan: false,
|
||||
...input,
|
||||
settledOverride: input.settledOverride ?? null,
|
||||
settledAt: input.settledAt ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { sanitizeFeatureBranchName } from "@t3tools/shared/git";
|
||||
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
|
||||
import { useState } from "react";
|
||||
import { Pressable, ScrollView, View } from "react-native";
|
||||
import { Platform, Pressable, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { AndroidSheetHeader } from "../../../components/AndroidScreenHeader";
|
||||
import { AppText as Text, AppTextInput as TextInput } from "../../../components/AppText";
|
||||
import { cn } from "../../../lib/cn";
|
||||
import { useEnvironmentQuery } from "../../../state/query";
|
||||
@@ -57,115 +58,125 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {
|
||||
const disabledExistingBranches = new Set(disabledExistingBranchNames);
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}
|
||||
contentContainerClassName="gap-4 px-5 pt-2"
|
||||
>
|
||||
<View className="gap-2 rounded-[18px] border border-border bg-card px-4 py-4">
|
||||
<Text className="text-foreground-secondary text-2xs font-t3-bold tracking-[1px] uppercase">
|
||||
New branch
|
||||
</Text>
|
||||
<TextInput
|
||||
value={newBranchName}
|
||||
onChangeText={setNewBranchName}
|
||||
placeholder="feature/mobile-polish"
|
||||
className="rounded-[18px]"
|
||||
/>
|
||||
<SheetActionButton
|
||||
icon="plus"
|
||||
label="Create & checkout"
|
||||
tone="primary"
|
||||
disabled={busy || newBranchName.trim().length === 0}
|
||||
onPress={() => {
|
||||
const branch = sanitizeFeatureBranchName(newBranchName.trim());
|
||||
if (branch.length === 0) return;
|
||||
void gitActions.onCreateSelectedThreadBranch(branch).then(() => {
|
||||
setNewBranchName("");
|
||||
navigation.goBack();
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View className="gap-2 rounded-[18px] border border-border bg-card px-4 py-4">
|
||||
<Text className="text-foreground-secondary text-2xs font-t3-bold tracking-[1px] uppercase">
|
||||
New worktree
|
||||
</Text>
|
||||
<TextInput
|
||||
value={worktreeBaseBranch}
|
||||
onChangeText={setWorktreeBaseBranch}
|
||||
placeholder="main"
|
||||
className="rounded-[18px]"
|
||||
/>
|
||||
<TextInput
|
||||
value={worktreeBranchName}
|
||||
onChangeText={setWorktreeBranchName}
|
||||
placeholder="feature/mobile-thread"
|
||||
className="rounded-[18px]"
|
||||
/>
|
||||
<SheetActionButton
|
||||
icon="square.split.2x1"
|
||||
label="Create worktree"
|
||||
tone="primary"
|
||||
disabled={
|
||||
busy || worktreeBaseBranch.trim().length === 0 || worktreeBranchName.trim().length === 0
|
||||
}
|
||||
onPress={() => {
|
||||
const baseBranch = worktreeBaseBranch.trim();
|
||||
const newBranch = worktreeBranchName.trim();
|
||||
if (baseBranch.length === 0 || newBranch.length === 0) return;
|
||||
void gitActions.onCreateSelectedThreadWorktree({ baseBranch, newBranch }).then(() => {
|
||||
setWorktreeBranchName("");
|
||||
navigation.goBack();
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View className="gap-2">
|
||||
<Text className="text-foreground-secondary text-2xs font-t3-bold tracking-[1px] uppercase">
|
||||
Existing branches
|
||||
</Text>
|
||||
{branchesLoading ? (
|
||||
<Text className="text-foreground-secondary text-sm font-medium">Loading branches...</Text>
|
||||
) : null}
|
||||
{!branchesLoading && availableBranches.length === 0 ? (
|
||||
<Text className="text-foreground-secondary text-sm font-medium">
|
||||
No local branches found.
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
{Platform.OS === "android" ? (
|
||||
<AndroidSheetHeader title="Branches & worktrees" onBack={() => navigation.goBack()} />
|
||||
) : null}
|
||||
<ScrollView
|
||||
className="flex-1"
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}
|
||||
contentContainerClassName="gap-4 px-5 pt-2"
|
||||
>
|
||||
<View className="gap-2 rounded-[18px] border border-border bg-card px-4 py-4">
|
||||
<Text className="text-foreground-secondary text-2xs font-t3-bold tracking-[1px] uppercase">
|
||||
New branch
|
||||
</Text>
|
||||
) : null}
|
||||
{availableBranches.map((branch) => {
|
||||
const disabled = disabledExistingBranches.has(branch.name);
|
||||
const subtitle = branch.worktreePath
|
||||
? branch.worktreePath === currentWorktreePath
|
||||
? "Checked out in this thread"
|
||||
: "Checked out in another worktree"
|
||||
: branch.isDefault
|
||||
? "Default branch"
|
||||
: "Local branch";
|
||||
<TextInput
|
||||
value={newBranchName}
|
||||
onChangeText={setNewBranchName}
|
||||
placeholder="feature/mobile-polish"
|
||||
className="rounded-[18px]"
|
||||
/>
|
||||
<SheetActionButton
|
||||
icon="plus"
|
||||
label="Create & checkout"
|
||||
tone="primary"
|
||||
disabled={busy || newBranchName.trim().length === 0}
|
||||
onPress={() => {
|
||||
const branch = sanitizeFeatureBranchName(newBranchName.trim());
|
||||
if (branch.length === 0) return;
|
||||
void gitActions.onCreateSelectedThreadBranch(branch).then(() => {
|
||||
setNewBranchName("");
|
||||
navigation.goBack();
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
key={branch.name}
|
||||
className={cn(
|
||||
"gap-1 rounded-[18px] border px-4 py-3 disabled:opacity-[0.45]",
|
||||
branch.current ? "border-subtle-strong" : "border-border",
|
||||
)}
|
||||
disabled={busy || disabled}
|
||||
onPress={() => {
|
||||
void gitActions.onCheckoutSelectedThreadBranch(branch.name).then(() => {
|
||||
navigation.goBack();
|
||||
});
|
||||
}}
|
||||
>
|
||||
<View className="absolute inset-0 rounded-[18px] bg-card" />
|
||||
<Text className="text-foreground text-base font-t3-bold">{branch.name}</Text>
|
||||
<Text className="text-foreground-secondary text-xs font-medium">{subtitle}</Text>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</ScrollView>
|
||||
<View className="gap-2 rounded-[18px] border border-border bg-card px-4 py-4">
|
||||
<Text className="text-foreground-secondary text-2xs font-t3-bold tracking-[1px] uppercase">
|
||||
New worktree
|
||||
</Text>
|
||||
<TextInput
|
||||
value={worktreeBaseBranch}
|
||||
onChangeText={setWorktreeBaseBranch}
|
||||
placeholder="main"
|
||||
className="rounded-[18px]"
|
||||
/>
|
||||
<TextInput
|
||||
value={worktreeBranchName}
|
||||
onChangeText={setWorktreeBranchName}
|
||||
placeholder="feature/mobile-thread"
|
||||
className="rounded-[18px]"
|
||||
/>
|
||||
<SheetActionButton
|
||||
icon="square.split.2x1"
|
||||
label="Create worktree"
|
||||
tone="primary"
|
||||
disabled={
|
||||
busy ||
|
||||
worktreeBaseBranch.trim().length === 0 ||
|
||||
worktreeBranchName.trim().length === 0
|
||||
}
|
||||
onPress={() => {
|
||||
const baseBranch = worktreeBaseBranch.trim();
|
||||
const newBranch = worktreeBranchName.trim();
|
||||
if (baseBranch.length === 0 || newBranch.length === 0) return;
|
||||
void gitActions.onCreateSelectedThreadWorktree({ baseBranch, newBranch }).then(() => {
|
||||
setWorktreeBranchName("");
|
||||
navigation.goBack();
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View className="gap-2">
|
||||
<Text className="text-foreground-secondary text-2xs font-t3-bold tracking-[1px] uppercase">
|
||||
Existing branches
|
||||
</Text>
|
||||
{branchesLoading ? (
|
||||
<Text className="text-foreground-secondary text-sm font-medium">
|
||||
Loading branches...
|
||||
</Text>
|
||||
) : null}
|
||||
{!branchesLoading && availableBranches.length === 0 ? (
|
||||
<Text className="text-foreground-secondary text-sm font-medium">
|
||||
No local branches found.
|
||||
</Text>
|
||||
) : null}
|
||||
{availableBranches.map((branch) => {
|
||||
const disabled = disabledExistingBranches.has(branch.name);
|
||||
const subtitle = branch.worktreePath
|
||||
? branch.worktreePath === currentWorktreePath
|
||||
? "Checked out in this thread"
|
||||
: "Checked out in another worktree"
|
||||
: branch.isDefault
|
||||
? "Default branch"
|
||||
: "Local branch";
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
key={branch.name}
|
||||
className={cn(
|
||||
"gap-1 rounded-[18px] border px-4 py-3 disabled:opacity-[0.45]",
|
||||
branch.current ? "border-subtle-strong" : "border-border",
|
||||
)}
|
||||
disabled={busy || disabled}
|
||||
onPress={() => {
|
||||
void gitActions.onCheckoutSelectedThreadBranch(branch.name).then(() => {
|
||||
navigation.goBack();
|
||||
});
|
||||
}}
|
||||
>
|
||||
<View className="absolute inset-0 rounded-[18px] bg-card" />
|
||||
<Text className="text-foreground text-base font-t3-bold">{branch.name}</Text>
|
||||
<Text className="text-foreground-secondary text-xs font-medium">{subtitle}</Text>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
|
||||
import { useCallback, useState } from "react";
|
||||
import { Pressable, ScrollView, View } from "react-native";
|
||||
import { Platform, Pressable, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { AndroidSheetHeader } from "../../../components/AndroidScreenHeader";
|
||||
import { AppText as Text, AppTextInput as TextInput } from "../../../components/AppText";
|
||||
import { cn } from "../../../lib/cn";
|
||||
import { useEnvironmentQuery } from "../../../state/query";
|
||||
@@ -65,160 +66,168 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
|
||||
);
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
keyboardShouldPersistTaps="handled"
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}
|
||||
contentContainerClassName="gap-4 px-5 pt-2"
|
||||
>
|
||||
<View className="gap-3 rounded-[22px] border border-border bg-card px-4 py-4">
|
||||
<View className="flex-row items-center justify-between gap-3">
|
||||
<Text className="text-foreground-muted text-sm font-medium">Branch</Text>
|
||||
<Text className="text-foreground text-base font-t3-bold">
|
||||
{gitStatus.data?.refName ?? "(detached HEAD)"}
|
||||
</Text>
|
||||
</View>
|
||||
{isDefaultRef ? (
|
||||
<Text className="text-xs leading-normal text-amber-700 dark:text-amber-400">
|
||||
Warning: this is the default branch.
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
<View className="gap-3 rounded-[22px] border border-border bg-card px-4 py-4">
|
||||
<View className="flex-row items-center justify-between gap-3">
|
||||
<View className="gap-1">
|
||||
<Text className="text-foreground text-base font-t3-bold">Files</Text>
|
||||
<Text className="text-foreground-muted text-xs leading-normal">
|
||||
{selectedFiles.length} selected · +{selectedInsertions} / -{selectedDeletions}
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
{Platform.OS === "android" ? (
|
||||
<AndroidSheetHeader title="Commit changes" onBack={() => navigation.goBack()} />
|
||||
) : null}
|
||||
<ScrollView
|
||||
className="flex-1"
|
||||
keyboardShouldPersistTaps="handled"
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}
|
||||
contentContainerClassName="gap-4 px-5 pt-2"
|
||||
>
|
||||
<View className="gap-3 rounded-[22px] border border-border bg-card px-4 py-4">
|
||||
<View className="flex-row items-center justify-between gap-3">
|
||||
<Text className="text-foreground-muted text-sm font-medium">Branch</Text>
|
||||
<Text className="text-foreground text-base font-t3-bold">
|
||||
{gitStatus.data?.refName ?? "(detached HEAD)"}
|
||||
</Text>
|
||||
</View>
|
||||
<View className="flex-row items-center gap-2">
|
||||
{!allSelected && isEditingFiles ? (
|
||||
{isDefaultRef ? (
|
||||
<Text className="text-xs leading-normal text-amber-700 dark:text-amber-400">
|
||||
Warning: this is the default branch.
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
<View className="gap-3 rounded-[22px] border border-border bg-card px-4 py-4">
|
||||
<View className="flex-row items-center justify-between gap-3">
|
||||
<View className="gap-1">
|
||||
<Text className="text-foreground text-base font-t3-bold">Files</Text>
|
||||
<Text className="text-foreground-muted text-xs leading-normal">
|
||||
{selectedFiles.length} selected · +{selectedInsertions} / -{selectedDeletions}
|
||||
</Text>
|
||||
</View>
|
||||
<View className="flex-row items-center gap-2">
|
||||
{!allSelected && isEditingFiles ? (
|
||||
<Pressable
|
||||
className="bg-subtle rounded-full px-3 py-2"
|
||||
onPress={() => setExcludedFiles(new Set())}
|
||||
>
|
||||
<Text className="text-foreground text-2xs font-t3-bold uppercase">Reset</Text>
|
||||
</Pressable>
|
||||
) : null}
|
||||
<Pressable
|
||||
className="bg-subtle rounded-full px-3 py-2"
|
||||
onPress={() => setExcludedFiles(new Set())}
|
||||
onPress={() => setIsEditingFiles((current) => !current)}
|
||||
>
|
||||
<Text className="text-foreground text-2xs font-t3-bold uppercase">Reset</Text>
|
||||
</Pressable>
|
||||
) : null}
|
||||
<Pressable
|
||||
className="bg-subtle rounded-full px-3 py-2"
|
||||
onPress={() => setIsEditingFiles((current) => !current)}
|
||||
>
|
||||
<Text className="text-foreground text-2xs font-t3-bold uppercase">
|
||||
{isEditingFiles ? "Done" : "Edit"}
|
||||
</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{allFiles.length === 0 ? (
|
||||
<Text className="text-foreground-secondary text-sm leading-normal">
|
||||
No changed files are available to commit.
|
||||
</Text>
|
||||
) : !isEditingFiles ? (
|
||||
<View className="gap-2">
|
||||
{selectedFilePreview.map((file) => (
|
||||
<View key={file.path} className="flex-row items-center justify-between gap-3">
|
||||
<Text className="text-foreground flex-1 text-sm font-medium" numberOfLines={1}>
|
||||
{file.path}
|
||||
<Text className="text-foreground text-2xs font-t3-bold uppercase">
|
||||
{isEditingFiles ? "Done" : "Edit"}
|
||||
</Text>
|
||||
<Text className="text-xs font-t3-bold text-emerald-500">+{file.insertions}</Text>
|
||||
<Text className="text-xs font-t3-bold text-rose-500">-{file.deletions}</Text>
|
||||
</View>
|
||||
))}
|
||||
{selectedFiles.length > selectedFilePreview.length ? (
|
||||
<Text className="text-foreground-muted text-xs leading-snug">
|
||||
+{selectedFiles.length - selectedFilePreview.length} more files
|
||||
</Text>
|
||||
) : null}
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
) : (
|
||||
<View className="gap-2">
|
||||
{allFiles.map((file) => {
|
||||
const included = !excludedFiles.has(file.path);
|
||||
return (
|
||||
<Pressable
|
||||
key={file.path}
|
||||
className={cn(
|
||||
"rounded-[18px] border px-4 py-3",
|
||||
included ? "border-border" : "border-border-subtle",
|
||||
)}
|
||||
onPress={() => {
|
||||
setExcludedFiles((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(file.path)) {
|
||||
next.delete(file.path);
|
||||
} else {
|
||||
next.add(file.path);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<View
|
||||
className={`absolute inset-0 rounded-[18px] ${included ? "bg-card" : "bg-subtle"}`}
|
||||
/>
|
||||
<View className="flex-row items-start justify-between gap-3">
|
||||
<View className="flex-1 gap-1">
|
||||
<Text
|
||||
selectable
|
||||
className={`text-sm font-t3-bold ${included ? "text-foreground" : "text-foreground-muted"}`}
|
||||
>
|
||||
{file.path}
|
||||
</Text>
|
||||
{!included ? (
|
||||
<Text className="text-foreground-muted text-2xs leading-normal">
|
||||
Excluded from this commit
|
||||
|
||||
{allFiles.length === 0 ? (
|
||||
<Text className="text-foreground-secondary text-sm leading-normal">
|
||||
No changed files are available to commit.
|
||||
</Text>
|
||||
) : !isEditingFiles ? (
|
||||
<View className="gap-2">
|
||||
{selectedFilePreview.map((file) => (
|
||||
<View key={file.path} className="flex-row items-center justify-between gap-3">
|
||||
<Text className="text-foreground flex-1 text-sm font-medium" numberOfLines={1}>
|
||||
{file.path}
|
||||
</Text>
|
||||
<Text className="text-xs font-t3-bold text-emerald-500">+{file.insertions}</Text>
|
||||
<Text className="text-xs font-t3-bold text-rose-500">-{file.deletions}</Text>
|
||||
</View>
|
||||
))}
|
||||
{selectedFiles.length > selectedFilePreview.length ? (
|
||||
<Text className="text-foreground-muted text-xs leading-snug">
|
||||
+{selectedFiles.length - selectedFilePreview.length} more files
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
) : (
|
||||
<View className="gap-2">
|
||||
{allFiles.map((file) => {
|
||||
const included = !excludedFiles.has(file.path);
|
||||
return (
|
||||
<Pressable
|
||||
key={file.path}
|
||||
className={cn(
|
||||
"rounded-[18px] border px-4 py-3",
|
||||
included ? "border-border" : "border-border-subtle",
|
||||
)}
|
||||
onPress={() => {
|
||||
setExcludedFiles((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(file.path)) {
|
||||
next.delete(file.path);
|
||||
} else {
|
||||
next.add(file.path);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<View
|
||||
className={`absolute inset-0 rounded-[18px] ${included ? "bg-card" : "bg-subtle"}`}
|
||||
/>
|
||||
<View className="flex-row items-start justify-between gap-3">
|
||||
<View className="flex-1 gap-1">
|
||||
<Text
|
||||
selectable
|
||||
className={`text-sm font-t3-bold ${included ? "text-foreground" : "text-foreground-muted"}`}
|
||||
>
|
||||
{file.path}
|
||||
</Text>
|
||||
) : null}
|
||||
{!included ? (
|
||||
<Text className="text-foreground-muted text-2xs leading-normal">
|
||||
Excluded from this commit
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
<View className="items-end gap-1">
|
||||
<Text className="text-xs font-t3-bold text-emerald-500">
|
||||
+{file.insertions}
|
||||
</Text>
|
||||
<Text className="text-xs font-t3-bold text-rose-500">
|
||||
-{file.deletions}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className="items-end gap-1">
|
||||
<Text className="text-xs font-t3-bold text-emerald-500">
|
||||
+{file.insertions}
|
||||
</Text>
|
||||
<Text className="text-xs font-t3-bold text-rose-500">-{file.deletions}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<View className="gap-2">
|
||||
<Text className="text-foreground text-sm font-t3-bold">Commit message</Text>
|
||||
<TextInput
|
||||
multiline
|
||||
value={dialogCommitMessage}
|
||||
onChangeText={setDialogCommitMessage}
|
||||
placeholder="Leave empty to auto-generate"
|
||||
textAlignVertical="top"
|
||||
className="min-h-[128px] rounded-[20px] px-4 py-3.5"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View className="flex-row gap-3">
|
||||
<View className="flex-1">
|
||||
<SheetActionButton
|
||||
icon="arrow.branch"
|
||||
label="Commit on new branch"
|
||||
disabled={noneSelected || busy}
|
||||
onPress={() => void runCommitAction(true)}
|
||||
/>
|
||||
</View>
|
||||
<View className="flex-1">
|
||||
<SheetActionButton
|
||||
icon="checkmark.circle"
|
||||
label="Commit"
|
||||
tone="primary"
|
||||
disabled={noneSelected || busy}
|
||||
onPress={() => void runCommitAction(false)}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<View className="gap-2">
|
||||
<Text className="text-foreground text-sm font-t3-bold">Commit message</Text>
|
||||
<TextInput
|
||||
multiline
|
||||
value={dialogCommitMessage}
|
||||
onChangeText={setDialogCommitMessage}
|
||||
placeholder="Leave empty to auto-generate"
|
||||
textAlignVertical="top"
|
||||
className="min-h-[128px] rounded-[20px] px-4 py-3.5"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View className="flex-row gap-3">
|
||||
<View className="flex-1">
|
||||
<SheetActionButton
|
||||
icon="arrow.branch"
|
||||
label="Commit on new branch"
|
||||
disabled={noneSelected || busy}
|
||||
onPress={() => void runCommitAction(true)}
|
||||
/>
|
||||
</View>
|
||||
<View className="flex-1">
|
||||
<SheetActionButton
|
||||
icon="checkmark.circle"
|
||||
label="Commit"
|
||||
tone="primary"
|
||||
disabled={noneSelected || busy}
|
||||
onPress={() => void runCommitAction(false)}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -4,10 +4,11 @@ import * as Arr from "effect/Array";
|
||||
import * as Result from "effect/Result";
|
||||
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { View } from "react-native";
|
||||
import { Platform, View } from "react-native";
|
||||
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { AndroidSheetHeader } from "../../../components/AndroidScreenHeader";
|
||||
import { AppText as Text } from "../../../components/AppText";
|
||||
import { useSelectedThreadGitActions } from "../../../state/use-selected-thread-git-actions";
|
||||
import { useSelectedThreadGitState } from "../../../state/use-selected-thread-git-state";
|
||||
@@ -102,7 +103,11 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
|
||||
|
||||
return (
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
<View className="min-h-4 pt-2" />
|
||||
{Platform.OS === "android" ? (
|
||||
<AndroidSheetHeader title="Confirm action" onBack={() => navigation.goBack()} />
|
||||
) : (
|
||||
<View className="min-h-4 pt-2" />
|
||||
)}
|
||||
|
||||
<View className="items-center gap-1 px-5 pb-3 pt-4">
|
||||
<Text className="text-xs font-t3-bold tracking-[1px] uppercase text-foreground-muted">
|
||||
|
||||
@@ -5,7 +5,12 @@ import {
|
||||
requiresDefaultBranchConfirmation,
|
||||
} from "@t3tools/client-runtime/state/vcs";
|
||||
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
|
||||
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
|
||||
import {
|
||||
CommonActions,
|
||||
StackActions,
|
||||
useNavigation,
|
||||
type StaticScreenProps,
|
||||
} from "@react-navigation/native";
|
||||
import { SymbolView } from "../../../components/AppSymbol";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { Alert, Platform, Pressable, RefreshControl, ScrollView, View } from "react-native";
|
||||
@@ -14,6 +19,7 @@ import { Screen, ScreenStack, ScreenStackHeaderConfig } from "react-native-scree
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useThemeColor } from "../../../lib/useThemeColor";
|
||||
|
||||
import { AndroidSheetHeader } from "../../../components/AndroidScreenHeader";
|
||||
import { AppText as Text } from "../../../components/AppText";
|
||||
import { nativeHeaderScrollEdgeEffects } from "../../../native/StackHeader";
|
||||
import { tryOpenExternalUrl } from "../../../lib/openExternalUrl";
|
||||
@@ -23,6 +29,7 @@ import { useSelectedThreadGitActions } from "../../../state/use-selected-thread-
|
||||
import { useSelectedThreadGitState } from "../../../state/use-selected-thread-git-state";
|
||||
import { useSelectedThreadWorktree } from "../../../state/use-selected-thread-worktree";
|
||||
import { vcsEnvironment } from "../../../state/vcs";
|
||||
import { resolveGitOverviewReviewNavigationAction } from "./git-overview-navigation";
|
||||
import { MetaCard, SheetListRow, menuItemIconName, statusSummary } from "./gitSheetComponents";
|
||||
|
||||
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
|
||||
@@ -255,7 +262,14 @@ export function GitOverviewSheet(props: GitOverviewSheetProps) {
|
||||
title="Review changes"
|
||||
subtitle="Inspect turn diffs, worktree changes, and base branch diff"
|
||||
disabled={busy || !isRepo}
|
||||
onPress={() => navigation.navigate("ThreadReview", { environmentId, threadId })}
|
||||
onPress={() => {
|
||||
const params = { environmentId, threadId };
|
||||
navigation.dispatch(
|
||||
resolveGitOverviewReviewNavigationAction(presentation) === "replace"
|
||||
? StackActions.replace("ThreadReview", params)
|
||||
: CommonActions.navigate("ThreadReview", params),
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<View className="ml-12 h-px bg-border" />
|
||||
<SheetListRow
|
||||
@@ -348,12 +362,14 @@ export function GitOverviewSheet(props: GitOverviewSheetProps) {
|
||||
collapsable={false}
|
||||
className={isInspector ? "flex-1 border-l border-border bg-sheet" : "flex-1 bg-sheet"}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
minHeight: isInspector ? (props.headerInset ?? 0) : 16,
|
||||
paddingTop: isInspector ? (props.headerInset ?? 0) : 8,
|
||||
}}
|
||||
/>
|
||||
{isInspector ? (
|
||||
<View
|
||||
style={{
|
||||
minHeight: props.headerInset ?? 0,
|
||||
paddingTop: props.headerInset ?? 0,
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{isInspector ? (
|
||||
<View className="gap-1 border-b border-border px-4 pb-4 pt-3">
|
||||
@@ -383,24 +399,19 @@ export function GitOverviewSheet(props: GitOverviewSheetProps) {
|
||||
</Text>
|
||||
</View>
|
||||
) : (
|
||||
// Compact header row: labeled branch on the left, status summary at
|
||||
// the trailing end. Horizontal padding lines the text up with the
|
||||
// rows' icon column inside the card below (20 screen + 16 card + 4
|
||||
// row). The sheet relies on pull-to-refresh instead of a corner
|
||||
// refresh button.
|
||||
<View className="flex-row items-end justify-between gap-3 px-10 pb-4 pt-4">
|
||||
<View className="shrink gap-0.5">
|
||||
<Text className="text-xs font-t3-bold tracking-[1px] uppercase text-foreground-muted">
|
||||
Branch
|
||||
</Text>
|
||||
<Text className="text-xl font-t3-bold" numberOfLines={1}>
|
||||
{currentBranchLabel}
|
||||
</Text>
|
||||
</View>
|
||||
<Text className="text-foreground-secondary pb-0.5 text-sm font-medium" numberOfLines={1}>
|
||||
{currentStatusSummary}
|
||||
</Text>
|
||||
</View>
|
||||
<AndroidSheetHeader
|
||||
title={currentBranchLabel}
|
||||
subtitle={currentStatusSummary}
|
||||
onBack={() => navigation.goBack()}
|
||||
actions={[
|
||||
{
|
||||
accessibilityLabel: "Refresh repository status",
|
||||
disabled: busy,
|
||||
icon: "arrow.clockwise",
|
||||
onPress: () => void gitActions.refreshSelectedThreadGitStatus(),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
|
||||
{content}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { resolveGitOverviewReviewNavigationAction } from "./git-overview-navigation";
|
||||
|
||||
describe("resolveGitOverviewReviewNavigationAction", () => {
|
||||
it("replaces the sheet so Back returns directly to the thread", () => {
|
||||
expect(resolveGitOverviewReviewNavigationAction("sheet")).toBe("replace");
|
||||
});
|
||||
|
||||
it("pushes Review normally when Git is a persistent inspector", () => {
|
||||
expect(resolveGitOverviewReviewNavigationAction("inspector")).toBe("navigate");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
export function resolveGitOverviewReviewNavigationAction(
|
||||
presentation: "sheet" | "inspector",
|
||||
): "replace" | "navigate" {
|
||||
return presentation === "sheet" ? "replace" : "navigate";
|
||||
}
|
||||
@@ -38,6 +38,8 @@ function makeThread(
|
||||
hasPendingUserInput: false,
|
||||
hasActionableProposedPlan: false,
|
||||
...input,
|
||||
settledOverride: input.settledOverride ?? null,
|
||||
settledAt: input.settledAt ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ function makeThread(
|
||||
checkpoints: [],
|
||||
session: null,
|
||||
...input,
|
||||
settledOverride: input.settledOverride ?? null,
|
||||
settledAt: input.settledAt ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ function threadDetailToShell(
|
||||
createdAt: thread.createdAt,
|
||||
updatedAt: thread.updatedAt,
|
||||
archivedAt: thread.archivedAt,
|
||||
settledOverride: thread.settledOverride,
|
||||
settledAt: thread.settledAt,
|
||||
session: thread.session,
|
||||
latestUserMessageAt: latestUserMessageAt(thread),
|
||||
hasPendingApprovals: false,
|
||||
|
||||
@@ -146,6 +146,8 @@ describe("OrchestrationEngine", () => {
|
||||
createdAt: "2026-03-03T00:00:02.000Z",
|
||||
updatedAt: "2026-03-03T00:00:03.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
|
||||
@@ -607,6 +607,8 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
createdAt: event.payload.createdAt,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
latestUserMessageAt: null,
|
||||
pendingApprovalCount: 0,
|
||||
pendingUserInputCount: 0,
|
||||
@@ -645,6 +647,38 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
||||
return;
|
||||
}
|
||||
|
||||
case "thread.settled": {
|
||||
const existingRow = yield* projectionThreadRepository.getById({
|
||||
threadId: event.payload.threadId,
|
||||
});
|
||||
if (Option.isNone(existingRow)) {
|
||||
return;
|
||||
}
|
||||
yield* projectionThreadRepository.upsert({
|
||||
...existingRow.value,
|
||||
settledOverride: "settled",
|
||||
settledAt: event.payload.settledAt,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
case "thread.unsettled": {
|
||||
const existingRow = yield* projectionThreadRepository.getById({
|
||||
threadId: event.payload.threadId,
|
||||
});
|
||||
if (Option.isNone(existingRow)) {
|
||||
return;
|
||||
}
|
||||
yield* projectionThreadRepository.upsert({
|
||||
...existingRow.value,
|
||||
settledOverride: event.payload.reason === "user" ? "active" : null,
|
||||
settledAt: null,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
case "thread.meta-updated": {
|
||||
const existingRow = yield* projectionThreadRepository.getById({
|
||||
threadId: event.payload.threadId,
|
||||
|
||||
@@ -308,6 +308,8 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
createdAt: "2026-02-24T00:00:02.000Z",
|
||||
updatedAt: "2026-02-24T00:00:03.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
messages: [
|
||||
{
|
||||
@@ -418,6 +420,8 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
createdAt: "2026-02-24T00:00:02.000Z",
|
||||
updatedAt: "2026-02-24T00:00:03.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
session: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
status: "running",
|
||||
|
||||
@@ -334,6 +334,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
created_at AS "createdAt",
|
||||
updated_at AS "updatedAt",
|
||||
archived_at AS "archivedAt",
|
||||
settled_override AS "settledOverride",
|
||||
settled_at AS "settledAt",
|
||||
latest_user_message_at AS "latestUserMessageAt",
|
||||
pending_approval_count AS "pendingApprovalCount",
|
||||
pending_user_input_count AS "pendingUserInputCount",
|
||||
@@ -362,6 +364,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
created_at AS "createdAt",
|
||||
updated_at AS "updatedAt",
|
||||
archived_at AS "archivedAt",
|
||||
settled_override AS "settledOverride",
|
||||
settled_at AS "settledAt",
|
||||
latest_user_message_at AS "latestUserMessageAt",
|
||||
pending_approval_count AS "pendingApprovalCount",
|
||||
pending_user_input_count AS "pendingUserInputCount",
|
||||
@@ -392,6 +396,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
created_at AS "createdAt",
|
||||
updated_at AS "updatedAt",
|
||||
archived_at AS "archivedAt",
|
||||
settled_override AS "settledOverride",
|
||||
settled_at AS "settledAt",
|
||||
latest_user_message_at AS "latestUserMessageAt",
|
||||
pending_approval_count AS "pendingApprovalCount",
|
||||
pending_user_input_count AS "pendingUserInputCount",
|
||||
@@ -754,6 +760,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
created_at AS "createdAt",
|
||||
updated_at AS "updatedAt",
|
||||
archived_at AS "archivedAt",
|
||||
settled_override AS "settledOverride",
|
||||
settled_at AS "settledAt",
|
||||
latest_user_message_at AS "latestUserMessageAt",
|
||||
pending_approval_count AS "pendingApprovalCount",
|
||||
pending_user_input_count AS "pendingUserInputCount",
|
||||
@@ -1186,6 +1194,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
createdAt: row.createdAt,
|
||||
updatedAt: row.updatedAt,
|
||||
archivedAt: row.archivedAt,
|
||||
settledOverride: row.settledOverride,
|
||||
settledAt: row.settledAt,
|
||||
deletedAt: row.deletedAt,
|
||||
messages: messagesByThread.get(row.threadId) ?? [],
|
||||
proposedPlans: proposedPlansByThread.get(row.threadId) ?? [],
|
||||
@@ -1384,6 +1394,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
createdAt: row.createdAt,
|
||||
updatedAt: row.updatedAt,
|
||||
archivedAt: row.archivedAt,
|
||||
settledOverride: row.settledOverride,
|
||||
settledAt: row.settledAt,
|
||||
deletedAt: row.deletedAt,
|
||||
messages: [],
|
||||
proposedPlans: proposedPlansByThread.get(row.threadId) ?? [],
|
||||
@@ -1513,6 +1525,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
createdAt: row.createdAt,
|
||||
updatedAt: row.updatedAt,
|
||||
archivedAt: row.archivedAt,
|
||||
settledOverride: row.settledOverride,
|
||||
settledAt: row.settledAt,
|
||||
session: sessionByThread.get(row.threadId) ?? null,
|
||||
latestUserMessageAt: row.latestUserMessageAt,
|
||||
hasPendingApprovals: row.pendingApprovalCount > 0,
|
||||
@@ -1647,6 +1661,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
createdAt: row.createdAt,
|
||||
updatedAt: row.updatedAt,
|
||||
archivedAt: row.archivedAt,
|
||||
settledOverride: row.settledOverride,
|
||||
settledAt: row.settledAt,
|
||||
session: sessionByThread.get(row.threadId) ?? null,
|
||||
latestUserMessageAt: row.latestUserMessageAt,
|
||||
hasPendingApprovals: row.pendingApprovalCount > 0,
|
||||
@@ -1887,6 +1903,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
createdAt: threadRow.value.createdAt,
|
||||
updatedAt: threadRow.value.updatedAt,
|
||||
archivedAt: threadRow.value.archivedAt,
|
||||
settledOverride: threadRow.value.settledOverride,
|
||||
settledAt: threadRow.value.settledAt,
|
||||
session: Option.isSome(sessionRow) ? mapSessionRow(sessionRow.value) : null,
|
||||
latestUserMessageAt: threadRow.value.latestUserMessageAt,
|
||||
hasPendingApprovals: threadRow.value.pendingApprovalCount > 0,
|
||||
@@ -1981,6 +1999,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
createdAt: threadRow.value.createdAt,
|
||||
updatedAt: threadRow.value.updatedAt,
|
||||
archivedAt: threadRow.value.archivedAt,
|
||||
settledOverride: threadRow.value.settledOverride,
|
||||
settledAt: threadRow.value.settledAt,
|
||||
deletedAt: null,
|
||||
messages: messageRows.map((row) => {
|
||||
const message = {
|
||||
|
||||
@@ -4,11 +4,13 @@ import {
|
||||
ProjectDeletedPayload as ContractsProjectDeletedPayloadSchema,
|
||||
ThreadCreatedPayload as ContractsThreadCreatedPayloadSchema,
|
||||
ThreadArchivedPayload as ContractsThreadArchivedPayloadSchema,
|
||||
ThreadSettledPayload as ContractsThreadSettledPayloadSchema,
|
||||
ThreadMetaUpdatedPayload as ContractsThreadMetaUpdatedPayloadSchema,
|
||||
ThreadRuntimeModeSetPayload as ContractsThreadRuntimeModeSetPayloadSchema,
|
||||
ThreadInteractionModeSetPayload as ContractsThreadInteractionModeSetPayloadSchema,
|
||||
ThreadDeletedPayload as ContractsThreadDeletedPayloadSchema,
|
||||
ThreadUnarchivedPayload as ContractsThreadUnarchivedPayloadSchema,
|
||||
ThreadUnsettledPayload as ContractsThreadUnsettledPayloadSchema,
|
||||
ThreadMessageSentPayload as ContractsThreadMessageSentPayloadSchema,
|
||||
ThreadProposedPlanUpsertedPayload as ContractsThreadProposedPlanUpsertedPayloadSchema,
|
||||
ThreadSessionSetPayload as ContractsThreadSessionSetPayloadSchema,
|
||||
@@ -29,11 +31,13 @@ export const ProjectDeletedPayload = ContractsProjectDeletedPayloadSchema;
|
||||
|
||||
export const ThreadCreatedPayload = ContractsThreadCreatedPayloadSchema;
|
||||
export const ThreadArchivedPayload = ContractsThreadArchivedPayloadSchema;
|
||||
export const ThreadSettledPayload = ContractsThreadSettledPayloadSchema;
|
||||
export const ThreadMetaUpdatedPayload = ContractsThreadMetaUpdatedPayloadSchema;
|
||||
export const ThreadRuntimeModeSetPayload = ContractsThreadRuntimeModeSetPayloadSchema;
|
||||
export const ThreadInteractionModeSetPayload = ContractsThreadInteractionModeSetPayloadSchema;
|
||||
export const ThreadDeletedPayload = ContractsThreadDeletedPayloadSchema;
|
||||
export const ThreadUnarchivedPayload = ContractsThreadUnarchivedPayloadSchema;
|
||||
export const ThreadUnsettledPayload = ContractsThreadUnsettledPayloadSchema;
|
||||
|
||||
export const MessageSentPayloadSchema = ContractsThreadMessageSentPayloadSchema;
|
||||
export const ThreadProposedPlanUpsertedPayload = ContractsThreadProposedPlanUpsertedPayloadSchema;
|
||||
|
||||
@@ -68,6 +68,8 @@ const readModel: OrchestrationReadModel = {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
latestTurn: null,
|
||||
messages: [],
|
||||
session: null,
|
||||
@@ -91,6 +93,8 @@ const readModel: OrchestrationReadModel = {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
latestTurn: null,
|
||||
messages: [],
|
||||
session: null,
|
||||
|
||||
@@ -0,0 +1,322 @@
|
||||
import {
|
||||
CommandId,
|
||||
EventId,
|
||||
MessageId,
|
||||
ProjectId,
|
||||
ProviderInstanceId,
|
||||
ThreadId,
|
||||
type OrchestrationReadModel,
|
||||
type OrchestrationSession,
|
||||
type OrchestrationThread,
|
||||
} from "@t3tools/contracts";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { expect, it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
|
||||
import { decideOrchestrationCommand } from "./decider.ts";
|
||||
|
||||
const NOW = "2026-01-01T00:00:00.000Z";
|
||||
const SETTLED_AT = "2025-12-30T00:00:00.000Z";
|
||||
|
||||
function makeReadModel(
|
||||
settledOverride: OrchestrationThread["settledOverride"],
|
||||
archivedAt: string | null = null,
|
||||
): OrchestrationReadModel {
|
||||
return {
|
||||
snapshotSequence: 0,
|
||||
projects: [],
|
||||
threads: [
|
||||
{
|
||||
id: ThreadId.make("thread-1"),
|
||||
projectId: ProjectId.make("project-1"),
|
||||
title: "Thread",
|
||||
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
latestTurn: null,
|
||||
createdAt: NOW,
|
||||
updatedAt: NOW,
|
||||
archivedAt,
|
||||
settledOverride,
|
||||
settledAt: settledOverride === "settled" ? SETTLED_AT : null,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
activities: [],
|
||||
checkpoints: [],
|
||||
session: null,
|
||||
},
|
||||
],
|
||||
updatedAt: NOW,
|
||||
};
|
||||
}
|
||||
|
||||
function makeSession(status: OrchestrationSession["status"]): OrchestrationSession {
|
||||
return {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
status,
|
||||
providerName: "Codex",
|
||||
runtimeMode: "full-access",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: NOW,
|
||||
};
|
||||
}
|
||||
|
||||
it.layer(NodeServices.layer)("settled thread decider", (it) => {
|
||||
it.effect("settles active threads and re-emits idempotently for settled ones", () =>
|
||||
Effect.gen(function* () {
|
||||
const event = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.settle",
|
||||
commandId: CommandId.make("cmd-settle"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
},
|
||||
readModel: makeReadModel(null),
|
||||
});
|
||||
const events = Array.isArray(event) ? event : [event];
|
||||
expect(events).toHaveLength(1);
|
||||
expect(events[0]?.type).toBe("thread.settled");
|
||||
if (events[0]?.type === "thread.settled") {
|
||||
expect(events[0].payload.settledAt).toBe(events[0].payload.updatedAt);
|
||||
}
|
||||
|
||||
// Already settled: the engine rejects zero-event commands, so idempotency
|
||||
// is by re-emission — preserving the original settledAt.
|
||||
const reEmit = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.settle",
|
||||
commandId: CommandId.make("cmd-settle-again"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
},
|
||||
readModel: makeReadModel("settled"),
|
||||
});
|
||||
const reEmitEvents = Array.isArray(reEmit) ? reEmit : [reEmit];
|
||||
expect(reEmitEvents).toHaveLength(1);
|
||||
expect(reEmitEvents[0]?.type).toBe("thread.settled");
|
||||
if (reEmitEvents[0]?.type === "thread.settled") {
|
||||
expect(reEmitEvents[0].payload.settledAt).toBe(SETTLED_AT);
|
||||
expect(reEmitEvents[0].payload.updatedAt).toBe(SETTLED_AT);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("rejects settling and unsettling archived threads", () =>
|
||||
Effect.gen(function* () {
|
||||
const settleError = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.settle",
|
||||
commandId: CommandId.make("cmd-settle-archived"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
},
|
||||
readModel: makeReadModel(null, NOW),
|
||||
}).pipe(Effect.flip);
|
||||
expect(settleError._tag).toBe("OrchestrationCommandInvariantError");
|
||||
|
||||
const unsettleError = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.unsettle",
|
||||
commandId: CommandId.make("cmd-unsettle-archived"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
reason: "user",
|
||||
},
|
||||
readModel: makeReadModel("settled", NOW),
|
||||
}).pipe(Effect.flip);
|
||||
expect(unsettleError._tag).toBe("OrchestrationCommandInvariantError");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("maps unsettle reasons to overrides and re-emits idempotently", () =>
|
||||
Effect.gen(function* () {
|
||||
const userEvent = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.unsettle",
|
||||
commandId: CommandId.make("cmd-unsettle-user"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
reason: "user",
|
||||
},
|
||||
readModel: makeReadModel("settled"),
|
||||
});
|
||||
const userEvents = Array.isArray(userEvent) ? userEvent : [userEvent];
|
||||
expect(userEvents).toHaveLength(1);
|
||||
expect(userEvents[0]?.type).toBe("thread.unsettled");
|
||||
if (userEvents[0]?.type === "thread.unsettled") {
|
||||
expect(userEvents[0].payload.reason).toBe("user");
|
||||
}
|
||||
|
||||
// Re-dispatching against the already-reached state re-emits rather than
|
||||
// producing zero events (the engine rejects empty commands).
|
||||
const userAgain = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.unsettle",
|
||||
commandId: CommandId.make("cmd-unsettle-user-again"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
reason: "user",
|
||||
},
|
||||
readModel: makeReadModel("active"),
|
||||
});
|
||||
const userAgainEvents = Array.isArray(userAgain) ? userAgain : [userAgain];
|
||||
expect(userAgainEvents).toHaveLength(1);
|
||||
expect(userAgainEvents[0]?.type).toBe("thread.unsettled");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("prepends activity unsets for turn starts and live session updates", () =>
|
||||
Effect.gen(function* () {
|
||||
const turnResult = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.turn.start",
|
||||
commandId: CommandId.make("cmd-turn-start"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
message: {
|
||||
messageId: MessageId.make("message-1"),
|
||||
role: "user",
|
||||
text: "Continue",
|
||||
attachments: [],
|
||||
},
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
createdAt: NOW,
|
||||
},
|
||||
readModel: makeReadModel("settled"),
|
||||
});
|
||||
const turnEvents = Array.isArray(turnResult) ? turnResult : [turnResult];
|
||||
expect(turnEvents.map((event) => event.type)).toEqual([
|
||||
"thread.unsettled",
|
||||
"thread.message-sent",
|
||||
"thread.turn-start-requested",
|
||||
]);
|
||||
|
||||
const sessionResult = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.session.set",
|
||||
commandId: CommandId.make("cmd-session-set"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
session: makeSession("running"),
|
||||
createdAt: NOW,
|
||||
},
|
||||
readModel: makeReadModel("active"),
|
||||
});
|
||||
const sessionEvents = Array.isArray(sessionResult) ? sessionResult : [sessionResult];
|
||||
expect(sessionEvents.map((event) => event.type)).toEqual(["thread.session-set"]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("preserves an explicit active override during activity", () =>
|
||||
Effect.gen(function* () {
|
||||
const turnResult = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.turn.start",
|
||||
commandId: CommandId.make("cmd-active-turn-start"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
message: {
|
||||
messageId: MessageId.make("message-active"),
|
||||
role: "user",
|
||||
text: "Continue",
|
||||
attachments: [],
|
||||
},
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
createdAt: NOW,
|
||||
},
|
||||
readModel: makeReadModel("active"),
|
||||
});
|
||||
const turnEvents = Array.isArray(turnResult) ? turnResult : [turnResult];
|
||||
expect(turnEvents.map((event) => event.type)).toEqual([
|
||||
"thread.message-sent",
|
||||
"thread.turn-start-requested",
|
||||
]);
|
||||
|
||||
const activityResult = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.activity.append",
|
||||
commandId: CommandId.make("cmd-active-approval"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
activity: {
|
||||
id: EventId.make("activity-active"),
|
||||
tone: "approval",
|
||||
kind: "approval.requested",
|
||||
summary: "Command approval requested",
|
||||
payload: null,
|
||||
turnId: null,
|
||||
createdAt: NOW,
|
||||
},
|
||||
createdAt: NOW,
|
||||
},
|
||||
readModel: makeReadModel("active"),
|
||||
});
|
||||
const activityEvents = Array.isArray(activityResult) ? activityResult : [activityResult];
|
||||
expect(activityEvents.map((event) => event.type)).toEqual(["thread.activity-appended"]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("does not unsettle for session stop/error status writes", () =>
|
||||
Effect.gen(function* () {
|
||||
for (const status of ["stopped", "error", "ready", "idle"] as const) {
|
||||
const result = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.session.set",
|
||||
commandId: CommandId.make(`cmd-session-${status}`),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
session: makeSession(status),
|
||||
createdAt: NOW,
|
||||
},
|
||||
readModel: makeReadModel("settled"),
|
||||
});
|
||||
const events = Array.isArray(result) ? result : [result];
|
||||
expect(events.map((event) => event.type)).toEqual(["thread.session-set"]);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("unsettles for approval and user-input activities but not others", () =>
|
||||
Effect.gen(function* () {
|
||||
const approvalResult = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.activity.append",
|
||||
commandId: CommandId.make("cmd-activity-approval"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
activity: {
|
||||
id: EventId.make("activity-1"),
|
||||
tone: "approval",
|
||||
kind: "approval.requested",
|
||||
summary: "Command approval requested",
|
||||
payload: null,
|
||||
turnId: null,
|
||||
createdAt: NOW,
|
||||
},
|
||||
createdAt: NOW,
|
||||
},
|
||||
readModel: makeReadModel("settled"),
|
||||
});
|
||||
const approvalEvents = Array.isArray(approvalResult) ? approvalResult : [approvalResult];
|
||||
expect(approvalEvents.map((event) => event.type)).toEqual([
|
||||
"thread.unsettled",
|
||||
"thread.activity-appended",
|
||||
]);
|
||||
|
||||
const routineResult = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.activity.append",
|
||||
commandId: CommandId.make("cmd-activity-routine"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
activity: {
|
||||
id: EventId.make("activity-2"),
|
||||
tone: "info",
|
||||
kind: "tool.completed",
|
||||
summary: "Tool completed",
|
||||
payload: null,
|
||||
turnId: null,
|
||||
createdAt: NOW,
|
||||
},
|
||||
createdAt: NOW,
|
||||
},
|
||||
readModel: makeReadModel("settled"),
|
||||
});
|
||||
const routineEvents = Array.isArray(routineResult) ? routineResult : [routineResult];
|
||||
expect(routineEvents.map((event) => event.type)).toEqual(["thread.activity-appended"]);
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -312,6 +312,61 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
};
|
||||
}
|
||||
|
||||
case "thread.settle": {
|
||||
const thread = yield* requireThreadNotArchived({
|
||||
readModel,
|
||||
command,
|
||||
threadId: command.threadId,
|
||||
});
|
||||
const occurredAt = yield* nowIso;
|
||||
// Settling an already-settled thread re-emits with the original
|
||||
// settledAt: the engine rejects zero-event commands, and bulk-settle /
|
||||
// double-click must stay silent no-ops rather than surface errors.
|
||||
const settledAt =
|
||||
thread.settledOverride === "settled" && thread.settledAt !== null
|
||||
? thread.settledAt
|
||||
: occurredAt;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
type: "thread.settled",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
settledAt,
|
||||
updatedAt: settledAt,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
case "thread.unsettle": {
|
||||
yield* requireThreadNotArchived({
|
||||
readModel,
|
||||
command,
|
||||
threadId: command.threadId,
|
||||
});
|
||||
// Idempotent by re-emission (see thread.settle): reducing the event a
|
||||
// second time lands on the same override state.
|
||||
const occurredAt = yield* nowIso;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
type: "thread.unsettled",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
reason: command.reason,
|
||||
updatedAt: occurredAt,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
case "thread.meta.update": {
|
||||
const thread = yield* requireThread({
|
||||
readModel,
|
||||
@@ -464,7 +519,24 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
createdAt: command.createdAt,
|
||||
},
|
||||
};
|
||||
return [userMessageEvent, turnStartRequestedEvent];
|
||||
if (targetThread.settledOverride !== "settled") {
|
||||
return [userMessageEvent, turnStartRequestedEvent];
|
||||
}
|
||||
const unsettledEvent: Omit<OrchestrationEvent, "sequence"> = {
|
||||
...(yield* withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
type: "thread.unsettled",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
reason: "activity",
|
||||
updatedAt: command.createdAt,
|
||||
},
|
||||
};
|
||||
return [unsettledEvent, userMessageEvent, turnStartRequestedEvent];
|
||||
}
|
||||
|
||||
case "thread.turn.interrupt": {
|
||||
@@ -585,12 +657,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
}
|
||||
|
||||
case "thread.session.set": {
|
||||
yield* requireThread({
|
||||
const thread = yield* requireThread({
|
||||
readModel,
|
||||
command,
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
const sessionSetEvent: Omit<OrchestrationEvent, "sequence"> = {
|
||||
...(yield* withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
@@ -604,6 +676,29 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
session: command.session,
|
||||
},
|
||||
};
|
||||
// Only a session coming alive is activity worth waking a settled thread
|
||||
// for — status writes like ready/stopped/error arrive after the fact and
|
||||
// must not fight a user's explicit settle.
|
||||
const isSessionActivity =
|
||||
command.session.status === "starting" || command.session.status === "running";
|
||||
if (thread.settledOverride !== "settled" || !isSessionActivity) {
|
||||
return sessionSetEvent;
|
||||
}
|
||||
const unsettledEvent: Omit<OrchestrationEvent, "sequence"> = {
|
||||
...(yield* withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
type: "thread.unsettled",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
reason: "activity",
|
||||
updatedAt: command.createdAt,
|
||||
},
|
||||
};
|
||||
return [unsettledEvent, sessionSetEvent];
|
||||
}
|
||||
|
||||
case "thread.message.assistant.delta": {
|
||||
@@ -730,7 +825,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
}
|
||||
|
||||
case "thread.activity.append": {
|
||||
yield* requireThread({
|
||||
const thread = yield* requireThread({
|
||||
readModel,
|
||||
command,
|
||||
threadId: command.threadId,
|
||||
@@ -743,7 +838,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
? ((command.activity.payload as { requestId: string })
|
||||
.requestId as OrchestrationEvent["metadata"]["requestId"])
|
||||
: undefined;
|
||||
return {
|
||||
const activityAppendedEvent: Omit<OrchestrationEvent, "sequence"> = {
|
||||
...(yield* withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
@@ -757,6 +852,29 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
activity: command.activity,
|
||||
},
|
||||
};
|
||||
// An approval or user-input request is blocked-on-you work — it must
|
||||
// never stay hidden inside a settled slim row.
|
||||
const wakesSettledThread =
|
||||
command.activity.kind === "approval.requested" ||
|
||||
command.activity.kind === "user-input.requested";
|
||||
if (thread.settledOverride !== "settled" || !wakesSettledThread) {
|
||||
return activityAppendedEvent;
|
||||
}
|
||||
const unsettledEvent: Omit<OrchestrationEvent, "sequence"> = {
|
||||
...(yield* withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
type: "thread.unsettled",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
reason: "activity",
|
||||
updatedAt: command.createdAt,
|
||||
},
|
||||
};
|
||||
return [unsettledEvent, activityAppendedEvent];
|
||||
}
|
||||
|
||||
default: {
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import {
|
||||
CommandId,
|
||||
EventId,
|
||||
ProjectId,
|
||||
ThreadId,
|
||||
type OrchestrationEvent,
|
||||
} from "@t3tools/contracts";
|
||||
import { expect, it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
|
||||
import { createEmptyReadModel, projectEvent } from "./projector.ts";
|
||||
|
||||
function makeEvent(input: {
|
||||
readonly sequence: number;
|
||||
readonly type: OrchestrationEvent["type"];
|
||||
readonly payload: unknown;
|
||||
}): OrchestrationEvent {
|
||||
return {
|
||||
sequence: input.sequence,
|
||||
eventId: EventId.make(`event-${input.sequence}`),
|
||||
type: input.type,
|
||||
aggregateKind: "thread",
|
||||
aggregateId: ThreadId.make("thread-1"),
|
||||
occurredAt: "2026-01-01T00:00:00.000Z",
|
||||
commandId: CommandId.make(`command-${input.sequence}`),
|
||||
causationEventId: null,
|
||||
correlationId: null,
|
||||
metadata: {},
|
||||
payload: input.payload as never,
|
||||
} as OrchestrationEvent;
|
||||
}
|
||||
|
||||
it.effect("projects settled lifecycle events", () =>
|
||||
Effect.gen(function* () {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const created = yield* projectEvent(
|
||||
createEmptyReadModel(now),
|
||||
makeEvent({
|
||||
sequence: 1,
|
||||
type: "thread.created",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
projectId: ProjectId.make("project-1"),
|
||||
title: "Thread",
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
);
|
||||
const settled = yield* projectEvent(
|
||||
created,
|
||||
makeEvent({
|
||||
sequence: 2,
|
||||
type: "thread.settled",
|
||||
payload: { threadId: ThreadId.make("thread-1"), settledAt: now, updatedAt: now },
|
||||
}),
|
||||
);
|
||||
expect(settled.threads[0]?.settledOverride).toBe("settled");
|
||||
expect(settled.threads[0]?.settledAt).toBe(now);
|
||||
|
||||
const userUnsettled = yield* projectEvent(
|
||||
settled,
|
||||
makeEvent({
|
||||
sequence: 3,
|
||||
type: "thread.unsettled",
|
||||
payload: { threadId: ThreadId.make("thread-1"), reason: "user", updatedAt: now },
|
||||
}),
|
||||
);
|
||||
expect(userUnsettled.threads[0]?.settledOverride).toBe("active");
|
||||
expect(userUnsettled.threads[0]?.settledAt).toBeNull();
|
||||
|
||||
const activityUnsettled = yield* projectEvent(
|
||||
userUnsettled,
|
||||
makeEvent({
|
||||
sequence: 4,
|
||||
type: "thread.unsettled",
|
||||
payload: { threadId: ThreadId.make("thread-1"), reason: "activity", updatedAt: now },
|
||||
}),
|
||||
);
|
||||
expect(activityUnsettled.threads[0]?.settledOverride).toBeNull();
|
||||
expect(activityUnsettled.threads[0]?.settledAt).toBeNull();
|
||||
}),
|
||||
);
|
||||
@@ -89,6 +89,8 @@ describe("orchestration projector", () => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
|
||||
@@ -22,7 +22,9 @@ import {
|
||||
ThreadMetaUpdatedPayload,
|
||||
ThreadProposedPlanUpsertedPayload,
|
||||
ThreadRuntimeModeSetPayload,
|
||||
ThreadSettledPayload,
|
||||
ThreadUnarchivedPayload,
|
||||
ThreadUnsettledPayload,
|
||||
ThreadRevertedPayload,
|
||||
ThreadSessionSetPayload,
|
||||
ThreadTurnDiffCompletedPayload,
|
||||
@@ -286,6 +288,8 @@ export function projectEvent(
|
||||
createdAt: payload.createdAt,
|
||||
updatedAt: payload.updatedAt,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
activities: [],
|
||||
@@ -337,6 +341,30 @@ export function projectEvent(
|
||||
})),
|
||||
);
|
||||
|
||||
case "thread.settled":
|
||||
return decodeForEvent(ThreadSettledPayload, event.payload, event.type, "payload").pipe(
|
||||
Effect.map((payload) => ({
|
||||
...nextBase,
|
||||
threads: updateThread(nextBase.threads, payload.threadId, {
|
||||
settledOverride: "settled",
|
||||
settledAt: payload.settledAt,
|
||||
updatedAt: payload.updatedAt,
|
||||
}),
|
||||
})),
|
||||
);
|
||||
|
||||
case "thread.unsettled":
|
||||
return decodeForEvent(ThreadUnsettledPayload, event.payload, event.type, "payload").pipe(
|
||||
Effect.map((payload) => ({
|
||||
...nextBase,
|
||||
threads: updateThread(nextBase.threads, payload.threadId, {
|
||||
settledOverride: payload.reason === "user" ? "active" : null,
|
||||
settledAt: null,
|
||||
updatedAt: payload.updatedAt,
|
||||
}),
|
||||
})),
|
||||
);
|
||||
|
||||
case "thread.meta-updated":
|
||||
return decodeForEvent(ThreadMetaUpdatedPayload, event.payload, event.type, "payload").pipe(
|
||||
Effect.map((payload) => ({
|
||||
|
||||
@@ -91,6 +91,8 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
|
||||
createdAt: "2026-03-24T00:00:00.000Z",
|
||||
updatedAt: "2026-03-24T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
latestUserMessageAt: null,
|
||||
pendingApprovalCount: 0,
|
||||
pendingUserInputCount: 0,
|
||||
|
||||
@@ -43,6 +43,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
created_at,
|
||||
updated_at,
|
||||
archived_at,
|
||||
settled_override,
|
||||
settled_at,
|
||||
latest_user_message_at,
|
||||
pending_approval_count,
|
||||
pending_user_input_count,
|
||||
@@ -62,6 +64,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
${row.createdAt},
|
||||
${row.updatedAt},
|
||||
${row.archivedAt},
|
||||
${row.settledOverride},
|
||||
${row.settledAt},
|
||||
${row.latestUserMessageAt},
|
||||
${row.pendingApprovalCount},
|
||||
${row.pendingUserInputCount},
|
||||
@@ -81,6 +85,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
created_at = excluded.created_at,
|
||||
updated_at = excluded.updated_at,
|
||||
archived_at = excluded.archived_at,
|
||||
settled_override = excluded.settled_override,
|
||||
settled_at = excluded.settled_at,
|
||||
latest_user_message_at = excluded.latest_user_message_at,
|
||||
pending_approval_count = excluded.pending_approval_count,
|
||||
pending_user_input_count = excluded.pending_user_input_count,
|
||||
@@ -107,6 +113,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
created_at AS "createdAt",
|
||||
updated_at AS "updatedAt",
|
||||
archived_at AS "archivedAt",
|
||||
settled_override AS "settledOverride",
|
||||
settled_at AS "settledAt",
|
||||
latest_user_message_at AS "latestUserMessageAt",
|
||||
pending_approval_count AS "pendingApprovalCount",
|
||||
pending_user_input_count AS "pendingUserInputCount",
|
||||
@@ -135,6 +143,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
created_at AS "createdAt",
|
||||
updated_at AS "updatedAt",
|
||||
archived_at AS "archivedAt",
|
||||
settled_override AS "settledOverride",
|
||||
settled_at AS "settledAt",
|
||||
latest_user_message_at AS "latestUserMessageAt",
|
||||
pending_approval_count AS "pendingApprovalCount",
|
||||
pending_user_input_count AS "pendingUserInputCount",
|
||||
|
||||
@@ -45,6 +45,7 @@ import Migration0029 from "./Migrations/029_ProjectionThreadDetailOrderingIndexe
|
||||
import Migration0030 from "./Migrations/030_ProjectionThreadShellArchiveIndexes.ts";
|
||||
import Migration0031 from "./Migrations/031_AuthAuthorizationScopes.ts";
|
||||
import Migration0032 from "./Migrations/032_AuthPairingProofKeyThumbprint.ts";
|
||||
import Migration0033 from "./Migrations/033_ProjectionThreadsSettled.ts";
|
||||
|
||||
/**
|
||||
* Migration loader with all migrations defined inline.
|
||||
@@ -89,6 +90,7 @@ export const migrationEntries = [
|
||||
[30, "ProjectionThreadShellArchiveIndexes", Migration0030],
|
||||
[31, "AuthAuthorizationScopes", Migration0031],
|
||||
[32, "AuthPairingProofKeyThumbprint", Migration0032],
|
||||
[33, "ProjectionThreadsSettled", Migration0033],
|
||||
] as const;
|
||||
|
||||
export const makeMigrationLoader = (throughId?: number) =>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
|
||||
export default Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
const columns = yield* sql<{ readonly name: string }>`
|
||||
PRAGMA table_info(projection_threads)
|
||||
`;
|
||||
|
||||
if (!columns.some((column) => column.name === "settled_override")) {
|
||||
yield* sql`
|
||||
ALTER TABLE projection_threads
|
||||
ADD COLUMN settled_override TEXT
|
||||
`;
|
||||
}
|
||||
|
||||
if (!columns.some((column) => column.name === "settled_at")) {
|
||||
yield* sql`
|
||||
ALTER TABLE projection_threads
|
||||
ADD COLUMN settled_at TEXT
|
||||
`;
|
||||
}
|
||||
});
|
||||
@@ -36,6 +36,8 @@ export const ProjectionThread = Schema.Struct({
|
||||
createdAt: IsoDateTime,
|
||||
updatedAt: IsoDateTime,
|
||||
archivedAt: Schema.NullOr(IsoDateTime),
|
||||
settledOverride: Schema.NullOr(Schema.Literals(["settled", "active"])),
|
||||
settledAt: Schema.NullOr(IsoDateTime),
|
||||
latestUserMessageAt: Schema.NullOr(IsoDateTime),
|
||||
pendingApprovalCount: NonNegativeInt,
|
||||
pendingUserInputCount: NonNegativeInt,
|
||||
|
||||
@@ -100,6 +100,8 @@ function makeReadModel(
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
latestUserMessageAt: null,
|
||||
hasPendingApprovals: false,
|
||||
hasPendingUserInput: false,
|
||||
|
||||
@@ -305,6 +305,8 @@ describe.sequential("signRelayAgentActivityPublishProof", () => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
session: null,
|
||||
latestUserMessageAt: null,
|
||||
hasPendingApprovals: false,
|
||||
@@ -451,6 +453,8 @@ describe.sequential("signRelayAgentActivityPublishProof", () => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
session: {
|
||||
threadId,
|
||||
status: "running",
|
||||
@@ -606,6 +610,8 @@ describe.sequential("signRelayAgentActivityPublishProof", () => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
session: {
|
||||
threadId,
|
||||
status: "running",
|
||||
|
||||
@@ -163,6 +163,8 @@ const makeDefaultOrchestrationReadModel = () => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
latestTurn: null,
|
||||
messages: [],
|
||||
session: null,
|
||||
@@ -192,6 +194,8 @@ const makeDefaultOrchestrationThreadShell = (
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
session: null,
|
||||
latestUserMessageAt: null,
|
||||
hasPendingApprovals: false,
|
||||
@@ -5495,6 +5499,8 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
latestTurn: null,
|
||||
messages: [],
|
||||
session: null,
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { useEffect, type CSSProperties, type ReactNode } from "react";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
|
||||
import { isElectron } from "../env";
|
||||
import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings";
|
||||
import { isMacPlatform } from "../lib/utils";
|
||||
import { primaryServerKeybindingsAtom } from "../state/server";
|
||||
import { useClientSettings } from "../hooks/useSettings";
|
||||
import ThreadSidebar from "./Sidebar";
|
||||
import ThreadSidebarV2 from "./SidebarV2";
|
||||
import { Sidebar, SidebarProvider, SidebarRail, SidebarTrigger, useSidebar } from "./ui/sidebar";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
|
||||
|
||||
@@ -55,6 +57,12 @@ function SidebarControl() {
|
||||
|
||||
export function AppSidebarLayout({ children }: { children: ReactNode }) {
|
||||
const navigate = useNavigate();
|
||||
const sidebarV2Enabled = useClientSettings((settings) => settings.sidebarV2Enabled);
|
||||
// Settings routes render the settings nav, which lives in the v1 component
|
||||
// and is identical for both sidebars — so v1 stays mounted there.
|
||||
const pathname = useLocation({ select: (location) => location.pathname });
|
||||
const isOnSettings = pathname === "/settings" || pathname.startsWith("/settings/");
|
||||
const useSidebarV2 = sidebarV2Enabled && !isOnSettings;
|
||||
const macosWindowControlsStyle =
|
||||
isElectron && isMacPlatform(navigator.platform)
|
||||
? ({ "--workspace-controls-left": MACOS_TRAFFIC_LIGHTS_LEFT_INSET } as CSSProperties)
|
||||
@@ -82,7 +90,14 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
|
||||
<Sidebar
|
||||
side="left"
|
||||
collapsible="offcanvas"
|
||||
className="border-r border-border bg-card text-foreground"
|
||||
className={
|
||||
// v2 is a darker, higher-contrast panel: it sits below the main
|
||||
// surface instead of matching it, so its bordered cards read as
|
||||
// raised blocks.
|
||||
useSidebarV2
|
||||
? "border-r border-black/15 bg-neutral-100 text-foreground dark:border-white/10 dark:bg-neutral-950"
|
||||
: "border-r border-border bg-card text-foreground"
|
||||
}
|
||||
resizable={{
|
||||
minWidth: THREAD_SIDEBAR_MIN_WIDTH,
|
||||
shouldAcceptWidth: ({ nextWidth, wrapper }) =>
|
||||
@@ -90,7 +105,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
|
||||
storageKey: THREAD_SIDEBAR_WIDTH_STORAGE_KEY,
|
||||
}}
|
||||
>
|
||||
<ThreadSidebar />
|
||||
{useSidebarV2 ? <ThreadSidebarV2 /> : <ThreadSidebar />}
|
||||
<SidebarRail />
|
||||
</Sidebar>
|
||||
{children}
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
import { BranchToolbarBranchSelector } from "./BranchToolbarBranchSelector";
|
||||
import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector";
|
||||
import { BranchToolbarEnvModeSelector } from "./BranchToolbarEnvModeSelector";
|
||||
import { ProjectFavicon } from "./ProjectFavicon";
|
||||
import { Button } from "./ui/button";
|
||||
import {
|
||||
Menu,
|
||||
@@ -240,6 +241,21 @@ export const BranchToolbar = memo(function BranchToolbar({
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex w-full max-w-3xl items-center gap-2 px-2.5 pb-3 pt-1 sm:px-3">
|
||||
{/* The submit target leads the run-context strip: this is the one
|
||||
surface where "which project am I about to send this to" must be
|
||||
answered before the first keystroke, especially on drafts.
|
||||
Mirrors the sidebar cards' title bar — favicon + mono name. */}
|
||||
<span className="inline-flex shrink-0 items-center gap-1.5 border border-black/12 py-0.5 pl-1.5 pr-2 dark:border-white/12">
|
||||
<ProjectFavicon
|
||||
environmentId={activeProject.environmentId}
|
||||
cwd={activeProject.workspaceRoot}
|
||||
className="size-3"
|
||||
/>
|
||||
<span className="max-w-32 truncate font-mono text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">
|
||||
{activeProject.title}
|
||||
</span>
|
||||
</span>
|
||||
<Separator orientation="vertical" className="mx-0.5 h-3.5!" />
|
||||
{isMobile ? (
|
||||
<MobileRunContextSelector
|
||||
envLocked={envLocked}
|
||||
|
||||
@@ -42,6 +42,8 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
latestTurn: null,
|
||||
branch: null,
|
||||
|
||||
@@ -45,6 +45,8 @@ export function buildLocalDraftThread(
|
||||
createdAt: draftThread.createdAt,
|
||||
updatedAt: draftThread.createdAt,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
latestTurn: null,
|
||||
branch: draftThread.branch,
|
||||
|
||||
@@ -5040,6 +5040,7 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
{...(routeKind === "draft" && draftId ? { draftId } : {})}
|
||||
activeThreadTitle={activeThread.title}
|
||||
activeProjectName={activeProject?.title}
|
||||
activeProjectCwd={activeProject?.workspaceRoot ?? null}
|
||||
openInCwd={gitCwd}
|
||||
activeProjectScripts={activeProject?.scripts}
|
||||
preferredScriptId={
|
||||
|
||||
@@ -24,6 +24,8 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
proposedPlans: [],
|
||||
createdAt: "2026-03-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
updatedAt: "2026-03-01T00:00:00.000Z",
|
||||
latestTurn: null,
|
||||
|
||||
@@ -17,7 +17,7 @@ export function ConnectionStatusDot({
|
||||
{pingClassName ? (
|
||||
<span
|
||||
className={cn(
|
||||
"absolute inline-flex h-full w-full animate-ping rounded-full",
|
||||
"absolute inline-flex h-full w-full animate-status-ping rounded-full",
|
||||
pingClassName,
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -16,8 +16,10 @@ import {
|
||||
resolveSidebarNewThreadEnvMode,
|
||||
resolveSidebarStageBadgeLabel,
|
||||
resolveThreadRowClassName,
|
||||
resolveSidebarV2Status,
|
||||
resolveThreadStatusPill,
|
||||
shouldClearThreadSelectionOnMouseDown,
|
||||
sortThreadsForSidebarV2,
|
||||
sortProjectsForSidebar,
|
||||
THREAD_JUMP_HINT_SHOW_DELAY_MS,
|
||||
} from "./Sidebar.logic";
|
||||
@@ -564,6 +566,84 @@ describe("isContextMenuPointerDown", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveSidebarV2Status", () => {
|
||||
const session = {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
status: "running" as const,
|
||||
providerName: "Codex",
|
||||
providerInstanceId: ProviderInstanceId.make("codex"),
|
||||
runtimeMode: DEFAULT_RUNTIME_MODE,
|
||||
activeTurnId: "turn-1" as never,
|
||||
lastError: null,
|
||||
updatedAt: "2026-03-09T10:00:00.000Z",
|
||||
};
|
||||
|
||||
it("prioritizes approval over a running session", () => {
|
||||
expect(resolveSidebarV2Status({ hasPendingApprovals: true, session })).toBe("approval");
|
||||
});
|
||||
|
||||
it("reports working for running and starting sessions", () => {
|
||||
expect(resolveSidebarV2Status({ hasPendingApprovals: false, session })).toBe("working");
|
||||
expect(
|
||||
resolveSidebarV2Status({
|
||||
hasPendingApprovals: false,
|
||||
session: { ...session, status: "starting" as const },
|
||||
}),
|
||||
).toBe("working");
|
||||
});
|
||||
|
||||
it("reports failed only while the session status is error", () => {
|
||||
expect(
|
||||
resolveSidebarV2Status({
|
||||
hasPendingApprovals: false,
|
||||
session: { ...session, status: "error" as const, lastError: "boom" },
|
||||
}),
|
||||
).toBe("failed");
|
||||
expect(
|
||||
resolveSidebarV2Status({
|
||||
hasPendingApprovals: false,
|
||||
session: { ...session, status: "stopped" as const, lastError: "persisted" },
|
||||
}),
|
||||
).toBe("ready");
|
||||
expect(
|
||||
resolveSidebarV2Status({
|
||||
hasPendingApprovals: false,
|
||||
session: { ...session, status: "ready" as const, lastError: "persisted" },
|
||||
}),
|
||||
).toBe("ready");
|
||||
});
|
||||
|
||||
it("defaults to ready with no session", () => {
|
||||
expect(resolveSidebarV2Status({ hasPendingApprovals: false, session: null })).toBe("ready");
|
||||
});
|
||||
});
|
||||
|
||||
describe("sortThreadsForSidebarV2", () => {
|
||||
const sortable = (input: { id: string; createdAt: string }) => ({
|
||||
id: input.id,
|
||||
createdAt: input.createdAt,
|
||||
});
|
||||
|
||||
it("orders by creation time, newest first, ignoring activity", () => {
|
||||
const sorted = sortThreadsForSidebarV2([
|
||||
sortable({ id: "oldest", createdAt: "2026-03-09T08:00:00.000Z" }),
|
||||
sortable({ id: "newest", createdAt: "2026-03-09T12:00:00.000Z" }),
|
||||
sortable({ id: "middle", createdAt: "2026-03-09T10:00:00.000Z" }),
|
||||
]);
|
||||
|
||||
expect(sorted.map((thread) => thread.id)).toEqual(["newest", "middle", "oldest"]);
|
||||
});
|
||||
|
||||
it("breaks creation-time ties by id so the order is stable", () => {
|
||||
const sorted = sortThreadsForSidebarV2([
|
||||
sortable({ id: "b", createdAt: "2026-03-09T10:00:00.000Z" }),
|
||||
sortable({ id: "a", createdAt: "2026-03-09T10:00:00.000Z" }),
|
||||
]);
|
||||
|
||||
expect(sorted.map((thread) => thread.id)).toEqual(["a", "b"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveThreadStatusPill", () => {
|
||||
const baseThread = {
|
||||
hasActionableProposedPlan: false,
|
||||
@@ -830,6 +910,8 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
proposedPlans: [],
|
||||
createdAt: "2026-03-09T10:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
updatedAt: "2026-03-09T10:00:00.000Z",
|
||||
latestTurn: null,
|
||||
|
||||
@@ -357,6 +357,41 @@ export function resolveThreadRowClassName(input: {
|
||||
return cn(baseClassName, "text-muted-foreground hover:bg-accent hover:text-foreground");
|
||||
}
|
||||
|
||||
// ── Sidebar v2 status model ─────────────────────────────────────────
|
||||
// Four visual states, three colors: color is reserved for "act now"
|
||||
// (approval), "in motion" (working), and "broken" (failed). Ready is the
|
||||
// unlabeled resting state — the agent stopped and is waiting on the user,
|
||||
// whether it finished, asked a question, or proposed a plan.
|
||||
export type SidebarV2Status = "approval" | "working" | "failed" | "ready";
|
||||
|
||||
type SidebarV2StatusInput = Pick<SidebarThreadSummary, "hasPendingApprovals" | "session">;
|
||||
|
||||
export function resolveSidebarV2Status(thread: SidebarV2StatusInput): SidebarV2Status {
|
||||
if (thread.hasPendingApprovals) {
|
||||
return "approval";
|
||||
}
|
||||
if (thread.session?.status === "running" || thread.session?.status === "starting") {
|
||||
return "working";
|
||||
}
|
||||
if (thread.session?.status === "error") {
|
||||
return "failed";
|
||||
}
|
||||
return "ready";
|
||||
}
|
||||
|
||||
// v2 sort: static creation order, newest thread on top. Activity NEVER
|
||||
// reorders the list — a row holds its position from open until settled, so
|
||||
// the screen only moves at lifecycle transitions. Status (including pending
|
||||
// approval) is carried by each card's edge strip, not by position.
|
||||
export function sortThreadsForSidebarV2<
|
||||
T extends { readonly id: string; readonly createdAt: string },
|
||||
>(threads: readonly T[]): T[] {
|
||||
return [...threads].toSorted(
|
||||
(left, right) =>
|
||||
Date.parse(right.createdAt) - Date.parse(left.createdAt) || left.id.localeCompare(right.id),
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveThreadStatusPill(input: {
|
||||
thread: ThreadStatusInput;
|
||||
}): ThreadStatusPill | null {
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
Globe2Icon,
|
||||
LoaderIcon,
|
||||
SearchIcon,
|
||||
SettingsIcon,
|
||||
SquarePenIcon,
|
||||
TerminalIcon,
|
||||
TriangleAlertIcon,
|
||||
@@ -63,7 +62,7 @@ import {
|
||||
settlePromise,
|
||||
squashAtomCommandFailure,
|
||||
} from "@t3tools/client-runtime/state/runtime";
|
||||
import { Link, useLocation, useNavigate, useParams, useRouter } from "@tanstack/react-router";
|
||||
import { useLocation, useNavigate, useParams, useRouter } from "@tanstack/react-router";
|
||||
import {
|
||||
MAX_SIDEBAR_THREAD_PREVIEW_COUNT,
|
||||
MIN_SIDEBAR_THREAD_PREVIEW_COUNT,
|
||||
@@ -74,7 +73,6 @@ import {
|
||||
import { isDesktopLocalConnectionTarget } from "../connection/desktopLocal";
|
||||
import { useDesktopLocalBootstraps } from "../connection/useDesktopLocalBootstraps";
|
||||
import { isElectron } from "../env";
|
||||
import { APP_STAGE_LABEL } from "../branding";
|
||||
import { useOpenPrLink } from "../lib/openPullRequestLink";
|
||||
import { isTerminalFocused } from "../lib/terminalFocus";
|
||||
import { isMacPlatform } from "../lib/utils";
|
||||
@@ -168,9 +166,7 @@ import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./u
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
|
||||
import {
|
||||
SidebarContent,
|
||||
SidebarFooter,
|
||||
SidebarGroup,
|
||||
SidebarHeader,
|
||||
SidebarMenu,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
@@ -178,7 +174,6 @@ import {
|
||||
SidebarMenuSubButton,
|
||||
SidebarMenuSubItem,
|
||||
SidebarSeparator,
|
||||
SidebarTrigger,
|
||||
useSidebar,
|
||||
} from "./ui/sidebar";
|
||||
import { useThreadSelectionStore } from "../threadSelectionStore";
|
||||
@@ -191,7 +186,6 @@ import {
|
||||
resolveProjectStatusIndicator,
|
||||
resolveSidebarNewThreadSeedContext,
|
||||
resolveSidebarNewThreadEnvMode,
|
||||
resolveSidebarStageBadgeLabel,
|
||||
resolveThreadRowClassName,
|
||||
resolveThreadStatusPill,
|
||||
orderItemsByPreferredIds,
|
||||
@@ -201,12 +195,12 @@ import {
|
||||
ThreadStatusPill,
|
||||
} from "./Sidebar.logic";
|
||||
import { sortThreads } from "../lib/threadSort";
|
||||
import { SidebarUpdatePill } from "./sidebar/SidebarUpdatePill";
|
||||
import { SidebarChromeFooter, SidebarChromeHeader } from "./sidebar/SidebarChrome";
|
||||
import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
|
||||
import { useIsMobile } from "~/hooks/useMediaQuery";
|
||||
import { CommandDialogTrigger } from "./ui/command";
|
||||
import { useClientSettings, useUpdateClientSettings } from "~/hooks/useSettings";
|
||||
import { primaryServerConfigAtom, primaryServerKeybindingsAtom } from "../state/server";
|
||||
import { primaryServerKeybindingsAtom } from "../state/server";
|
||||
import {
|
||||
derivePhysicalProjectKey,
|
||||
deriveProjectGroupingOverrideKey,
|
||||
@@ -220,7 +214,6 @@ import {
|
||||
type SidebarProjectGroupMember,
|
||||
type SidebarProjectSnapshot,
|
||||
} from "../sidebarProjectGrouping";
|
||||
import { SidebarProviderUpdatePill } from "./sidebar/SidebarProviderUpdatePill";
|
||||
const SIDEBAR_SORT_LABELS: Record<SidebarProjectSortOrder, string> = {
|
||||
updated_at: "Last user message",
|
||||
created_at: "Created at",
|
||||
@@ -771,7 +764,9 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
|
||||
/>
|
||||
}
|
||||
>
|
||||
<TerminalIcon className={`size-3 ${terminalStatus.pulse ? "animate-pulse" : ""}`} />
|
||||
<TerminalIcon
|
||||
className={`size-3 ${terminalStatus.pulse ? "animate-status-pulse" : ""}`}
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">{terminalStatus.label}</TooltipPopup>
|
||||
</Tooltip>
|
||||
@@ -2226,7 +2221,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
||||
<span className="absolute inset-0 flex items-center justify-center transition-opacity duration-150 group-hover/project-header:opacity-0">
|
||||
<span
|
||||
className={`size-[9px] rounded-full ${projectStatus.dotClass} ${
|
||||
projectStatus.pulse ? "animate-pulse" : ""
|
||||
projectStatus.pulse ? "animate-status-pulse" : ""
|
||||
}`}
|
||||
/>
|
||||
</span>
|
||||
@@ -2737,100 +2732,6 @@ function SortableProjectItem({
|
||||
);
|
||||
}
|
||||
|
||||
const SidebarChromeHeader = memo(function SidebarChromeHeader({
|
||||
isElectron,
|
||||
}: {
|
||||
isElectron: boolean;
|
||||
}) {
|
||||
return isElectron ? (
|
||||
<SidebarHeader className="@container/sidebar-header drag-region h-[var(--workspace-topbar-height)] shrink-0 flex-row items-center px-3 py-0 md:px-0">
|
||||
<SidebarTrigger className="md:hidden" />
|
||||
<SidebarBrand />
|
||||
</SidebarHeader>
|
||||
) : (
|
||||
<SidebarHeader className="@container/sidebar-header h-[var(--workspace-topbar-height)] shrink-0 flex-row items-center px-3 py-0 md:px-0">
|
||||
<SidebarTrigger className="md:hidden" />
|
||||
<SidebarBrand />
|
||||
</SidebarHeader>
|
||||
);
|
||||
});
|
||||
|
||||
function SidebarBrand() {
|
||||
const stageLabel = useSidebarStageLabel();
|
||||
|
||||
return (
|
||||
<Link
|
||||
aria-label="Go to threads"
|
||||
className="sidebar-brand ml-[var(--workspace-titlebar-content-left)] h-7 w-fit min-w-0 shrink-0 items-center gap-1 overflow-hidden rounded-md text-foreground outline-hidden ring-ring focus-visible:ring-2"
|
||||
to="/"
|
||||
>
|
||||
<T3Wordmark />
|
||||
<span className="truncate text-sm font-medium tracking-tight text-muted-foreground">
|
||||
Code
|
||||
</span>
|
||||
<span className="sidebar-brand-stage shrink-0 items-center whitespace-nowrap rounded-full bg-muted/50 px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.18em] text-muted-foreground/60">
|
||||
{stageLabel}
|
||||
</span>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
function useSidebarStageLabel() {
|
||||
const primaryServerVersion =
|
||||
useAtomValue(primaryServerConfigAtom)?.environment.serverVersion ?? null;
|
||||
|
||||
return resolveSidebarStageBadgeLabel({
|
||||
primaryServerVersion,
|
||||
fallbackStageLabel: APP_STAGE_LABEL,
|
||||
});
|
||||
}
|
||||
|
||||
function T3Wordmark() {
|
||||
return (
|
||||
<svg
|
||||
aria-label="T3"
|
||||
className="h-2.5 w-auto shrink-0 text-foreground"
|
||||
viewBox="15.5309 37 94.3941 56.96"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M33.4509 93V47.56H15.5309V37H64.3309V47.56H46.4109V93H33.4509ZM86.7253 93.96C82.832 93.96 78.9653 93.4533 75.1253 92.44C71.2853 91.3733 68.032 89.88 65.3653 87.96L70.4053 78.04C72.5386 79.5867 75.0186 80.8133 77.8453 81.72C80.672 82.6267 83.5253 83.08 86.4053 83.08C89.6586 83.08 92.2186 82.44 94.0853 81.16C95.952 79.88 96.8853 78.12 96.8853 75.88C96.8853 73.7467 96.0586 72.0667 94.4053 70.84C92.752 69.6133 90.0853 69 86.4053 69H80.4853V60.44L96.0853 42.76L97.5253 47.4H68.1653V37H107.365V45.4L91.8453 63.08L85.2853 59.32H89.0453C95.9253 59.32 101.125 60.8667 104.645 63.96C108.165 67.0533 109.925 71.0267 109.925 75.88C109.925 79.0267 109.099 81.9867 107.445 84.76C105.792 87.48 103.259 89.6933 99.8453 91.4C96.432 93.1067 92.0586 93.96 86.7253 93.96Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
const SidebarChromeFooter = memo(function SidebarChromeFooter() {
|
||||
const navigate = useNavigate();
|
||||
const { isMobile, setOpenMobile } = useSidebar();
|
||||
const handleSettingsClick = useCallback(() => {
|
||||
if (isMobile) {
|
||||
setOpenMobile(false);
|
||||
}
|
||||
void navigate({ to: "/settings" });
|
||||
}, [isMobile, navigate, setOpenMobile]);
|
||||
|
||||
return (
|
||||
<SidebarFooter className="p-2">
|
||||
<SidebarProviderUpdatePill />
|
||||
<SidebarUpdatePill />
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton
|
||||
size="sm"
|
||||
className="gap-2 px-2 py-1.5 text-muted-foreground/70 hover:bg-accent hover:text-foreground"
|
||||
onClick={handleSettingsClick}
|
||||
>
|
||||
<SettingsIcon className="size-3.5" />
|
||||
<span className="text-xs">Settings</span>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
</SidebarFooter>
|
||||
);
|
||||
});
|
||||
|
||||
interface SidebarProjectsContentProps {
|
||||
showArm64IntelBuildWarning: boolean;
|
||||
arm64IntelBuildWarningDescription: string | null;
|
||||
|
||||
@@ -149,7 +149,7 @@ export function ThreadStatusLabel({
|
||||
>
|
||||
<span
|
||||
className={`size-[9px] rounded-full ${status.dotClass} ${
|
||||
status.pulse ? "animate-pulse" : ""
|
||||
status.pulse ? "animate-status-pulse" : ""
|
||||
}`}
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
@@ -170,7 +170,7 @@ export function ThreadStatusLabel({
|
||||
>
|
||||
<span
|
||||
className={`h-1.5 w-1.5 rounded-full ${status.dotClass} ${
|
||||
status.pulse ? "animate-pulse" : ""
|
||||
status.pulse ? "animate-status-pulse" : ""
|
||||
}`}
|
||||
/>
|
||||
<span className="hidden md:inline">{status.label}</span>
|
||||
@@ -276,7 +276,9 @@ export function ThreadRowTrailingStatus({ thread }: { thread: SidebarThreadSumma
|
||||
/>
|
||||
}
|
||||
>
|
||||
<TerminalIcon className={`size-3 ${terminalStatus.pulse ? "animate-pulse" : ""}`} />
|
||||
<TerminalIcon
|
||||
className={`size-3 ${terminalStatus.pulse ? "animate-status-pulse" : ""}`}
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">{terminalStatus.label}</TooltipPopup>
|
||||
</Tooltip>
|
||||
|
||||
@@ -2049,7 +2049,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"group rounded-[22px] p-px transition-colors duration-200",
|
||||
"group rounded-[13px] p-px transition-colors duration-200",
|
||||
composerProviderState.composerFrameClassName,
|
||||
)}
|
||||
onDragEnter={onComposerDragEnter}
|
||||
@@ -2061,8 +2061,10 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
ref={composerSurfaceRef}
|
||||
data-chat-composer-mobile-collapsed={isComposerCollapsedMobile ? "true" : "false"}
|
||||
className={cn(
|
||||
"chat-composer-glass rounded-[20px] border transition-colors duration-200 has-focus-visible:border-ring/45",
|
||||
isDragOverComposer ? "border-primary/70 bg-accent/45" : "border-border",
|
||||
"chat-composer-glass rounded-[12px] border transition-colors duration-200 has-focus-visible:border-foreground/40",
|
||||
isDragOverComposer
|
||||
? "border-primary/70 bg-accent/45"
|
||||
: "border-black/12 dark:border-white/12",
|
||||
environmentUnavailable ? "opacity-75" : null,
|
||||
composerProviderState.composerSurfaceClassName,
|
||||
)}
|
||||
@@ -2087,14 +2089,14 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
>
|
||||
{!isComposerCollapsedMobile &&
|
||||
(activePendingApproval ? (
|
||||
<div className="rounded-t-[19px] border-b border-border/65 bg-muted/20">
|
||||
<div className="rounded-t-[11px] border-b border-border/65 bg-muted/20">
|
||||
<ComposerPendingApprovalPanel
|
||||
approval={activePendingApproval}
|
||||
pendingCount={pendingApprovals.length}
|
||||
/>
|
||||
</div>
|
||||
) : pendingUserInputs.length > 0 ? (
|
||||
<div className="rounded-t-[19px] border-b border-border/65 bg-muted/20">
|
||||
<div className="rounded-t-[11px] border-b border-border/65 bg-muted/20">
|
||||
<ComposerPendingUserInputPanel
|
||||
pendingUserInputs={pendingUserInputs}
|
||||
respondingRequestIds={respondingRequestIds}
|
||||
@@ -2105,7 +2107,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
/>
|
||||
</div>
|
||||
) : showPlanFollowUpPrompt && activeProposedPlan ? (
|
||||
<div className="rounded-t-[19px] border-b border-border/65 bg-muted/20">
|
||||
<div className="rounded-t-[11px] border-b border-border/65 bg-muted/20">
|
||||
<ComposerPlanFollowUpBanner
|
||||
key={activeProposedPlan.id}
|
||||
planTitle={proposedPlanTitle(activeProposedPlan.planMarkdown) ?? null}
|
||||
@@ -2115,7 +2117,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
|
||||
{isComposerCollapsedMobile && activePendingApproval ? (
|
||||
<div
|
||||
className="rounded-t-[19px] border-b border-border/65 bg-muted/20"
|
||||
className="rounded-t-[11px] border-b border-border/65 bg-muted/20"
|
||||
data-chat-composer-collapsed-controls="true"
|
||||
>
|
||||
<ComposerPendingApprovalPanel
|
||||
@@ -2132,7 +2134,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
</div>
|
||||
) : isComposerCollapsedMobile && pendingUserInputs.length > 0 ? (
|
||||
<div
|
||||
className="rounded-t-[19px] border-b border-border/65 bg-muted/20"
|
||||
className="rounded-t-[11px] border-b border-border/65 bg-muted/20"
|
||||
data-chat-composer-collapsed-controls="true"
|
||||
>
|
||||
<ComposerPendingUserInputPanel
|
||||
|
||||
@@ -16,6 +16,7 @@ import ProjectScriptsControl, {
|
||||
} from "../ProjectScriptsControl";
|
||||
import { OpenInPicker } from "./OpenInPicker";
|
||||
import { usePrimaryEnvironmentId } from "../../state/environments";
|
||||
import { ProjectFavicon } from "../ProjectFavicon";
|
||||
import { cn } from "~/lib/utils";
|
||||
|
||||
interface ChatHeaderProps {
|
||||
@@ -24,6 +25,7 @@ interface ChatHeaderProps {
|
||||
draftId?: DraftId;
|
||||
activeThreadTitle: string;
|
||||
activeProjectName: string | undefined;
|
||||
activeProjectCwd: string | null;
|
||||
openInCwd: string | null;
|
||||
activeProjectScripts: ReadonlyArray<ProjectScript> | undefined;
|
||||
preferredScriptId: string | null;
|
||||
@@ -58,6 +60,7 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
draftId,
|
||||
activeThreadTitle,
|
||||
activeProjectName,
|
||||
activeProjectCwd,
|
||||
openInCwd,
|
||||
activeProjectScripts,
|
||||
preferredScriptId,
|
||||
@@ -79,6 +82,27 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
return (
|
||||
<div className="@container/header-actions flex min-w-0 flex-1 items-center gap-2 sm:gap-3">
|
||||
<div className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden sm:gap-3">
|
||||
{/* The project always leads the header: knowing which project a
|
||||
thread lives in is priority zero, and the thread title alone
|
||||
doesn't answer it. Mirrors the sidebar cards' title bar —
|
||||
favicon + mono uppercase name. */}
|
||||
{activeProjectName ? (
|
||||
<span className="inline-flex shrink-0 items-center gap-2">
|
||||
<span className="inline-flex items-center gap-1.5 border border-black/12 py-0.5 pl-1.5 pr-2 dark:border-white/12">
|
||||
<ProjectFavicon
|
||||
environmentId={activeThreadEnvironmentId}
|
||||
cwd={activeProjectCwd ?? ""}
|
||||
className="size-3"
|
||||
/>
|
||||
<span className="max-w-40 truncate font-mono text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">
|
||||
{activeProjectName}
|
||||
</span>
|
||||
</span>
|
||||
<span aria-hidden className="text-muted-foreground/40">
|
||||
/
|
||||
</span>
|
||||
</span>
|
||||
) : null}
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
|
||||
@@ -1055,9 +1055,9 @@ function WorkingTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "workin
|
||||
<div className="py-0.5 pl-1.5">
|
||||
<div className="flex items-center gap-2 pt-1 text-[11px] text-muted-foreground/70 tabular-nums">
|
||||
<span className="inline-flex items-center gap-[3px]">
|
||||
<span className="h-1 w-1 rounded-full bg-muted-foreground/30 animate-pulse" />
|
||||
<span className="h-1 w-1 rounded-full bg-muted-foreground/30 animate-pulse [animation-delay:200ms]" />
|
||||
<span className="h-1 w-1 rounded-full bg-muted-foreground/30 animate-pulse [animation-delay:400ms]" />
|
||||
<span className="h-1 w-1 rounded-full bg-muted-foreground/30 animate-status-pulse" />
|
||||
<span className="h-1 w-1 rounded-full bg-muted-foreground/30 animate-status-pulse [animation-delay:200ms]" />
|
||||
<span className="h-1 w-1 rounded-full bg-muted-foreground/30 animate-status-pulse [animation-delay:400ms]" />
|
||||
</span>
|
||||
<span>
|
||||
{row.createdAt ? (
|
||||
|
||||
@@ -66,7 +66,7 @@ function AgentBrowserCursorEvent(props: {
|
||||
{event.phase === "click" ? (
|
||||
<span
|
||||
key={event.sequence}
|
||||
className="absolute left-0.5 top-0.5 size-4 animate-ping rounded-full bg-primary/25 motion-reduce:animate-none"
|
||||
className="absolute left-0.5 top-0.5 size-4 animate-status-ping rounded-full bg-primary/25 motion-reduce:animate-none"
|
||||
/>
|
||||
) : null}
|
||||
<MousePointer2
|
||||
|
||||
@@ -266,7 +266,7 @@ export function PreviewChromeRow({
|
||||
>
|
||||
<Camera className={cn(recording && "text-destructive")} />
|
||||
{recording ? (
|
||||
<span className="absolute right-0.5 top-0.5 size-1.5 animate-pulse rounded-full bg-destructive" />
|
||||
<span className="absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive" />
|
||||
) : null}
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup>
|
||||
|
||||
@@ -36,7 +36,7 @@ function describeServer(server: PreviewableServer): string {
|
||||
function PulsingDot() {
|
||||
return (
|
||||
<span aria-label="Listening" className="relative inline-flex size-2 shrink-0">
|
||||
<span className="absolute inset-0 animate-ping rounded-full bg-success opacity-60" />
|
||||
<span className="absolute inset-0 animate-status-ping rounded-full bg-success opacity-60" />
|
||||
<span className="relative inline-flex size-2 rounded-full bg-success" />
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { useClientSettings, useUpdateClientSettings } from "../../hooks/useSettings";
|
||||
import { Input } from "../ui/input";
|
||||
import { Switch } from "../ui/switch";
|
||||
import { SettingsPageContainer, SettingsRow, SettingsSection } from "./settingsLayout";
|
||||
|
||||
const AUTO_SETTLE_MIN_DAYS = 1;
|
||||
const AUTO_SETTLE_MAX_DAYS = 90;
|
||||
const AUTO_SETTLE_DEFAULT_DAYS = 3;
|
||||
|
||||
function AutoSettleDaysInput({
|
||||
value,
|
||||
onCommit,
|
||||
}: {
|
||||
value: number;
|
||||
onCommit: (days: number) => void;
|
||||
}) {
|
||||
// Local draft so the field can be emptied mid-edit; the setting only moves
|
||||
// on valid input and snaps back to the persisted value on blur.
|
||||
const [draft, setDraft] = useState(String(value));
|
||||
useEffect(() => {
|
||||
setDraft(String(value));
|
||||
}, [value]);
|
||||
|
||||
return (
|
||||
<Input
|
||||
type="number"
|
||||
min={AUTO_SETTLE_MIN_DAYS}
|
||||
max={AUTO_SETTLE_MAX_DAYS}
|
||||
className="w-full sm:w-24"
|
||||
value={draft}
|
||||
onChange={(event) => {
|
||||
setDraft(event.target.value);
|
||||
const parsed = Number.parseInt(event.target.value, 10);
|
||||
if (
|
||||
Number.isFinite(parsed) &&
|
||||
parsed >= AUTO_SETTLE_MIN_DAYS &&
|
||||
parsed <= AUTO_SETTLE_MAX_DAYS
|
||||
) {
|
||||
onCommit(parsed);
|
||||
}
|
||||
}}
|
||||
onBlur={() => setDraft(String(value))}
|
||||
aria-label="Days of inactivity before auto-settle"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function BetaSettingsPanel() {
|
||||
const sidebarV2Enabled = useClientSettings((settings) => settings.sidebarV2Enabled);
|
||||
const sidebarAutoSettleAfterDays = useClientSettings(
|
||||
(settings) => settings.sidebarAutoSettleAfterDays,
|
||||
);
|
||||
const updateSettings = useUpdateClientSettings();
|
||||
|
||||
return (
|
||||
<SettingsPageContainer>
|
||||
<SettingsSection title="Beta features">
|
||||
<SettingsRow
|
||||
title="Sidebar v2"
|
||||
description="One flat, recency-sorted thread list. Active work renders as rich cards; settled threads collapse to compact rows. Switch back any time — no data changes either way."
|
||||
control={
|
||||
<Switch
|
||||
checked={sidebarV2Enabled}
|
||||
onCheckedChange={(checked) => updateSettings({ sidebarV2Enabled: Boolean(checked) })}
|
||||
aria-label="Enable the sidebar v2 beta"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{sidebarV2Enabled ? (
|
||||
<>
|
||||
<SettingsRow
|
||||
title="Auto-settle inactive threads"
|
||||
description="Threads with no activity for this long settle automatically. Threads on merged or closed PRs always settle."
|
||||
control={
|
||||
<Switch
|
||||
checked={sidebarAutoSettleAfterDays !== null}
|
||||
onCheckedChange={(checked) =>
|
||||
updateSettings({
|
||||
sidebarAutoSettleAfterDays: checked ? AUTO_SETTLE_DEFAULT_DAYS : null,
|
||||
})
|
||||
}
|
||||
aria-label="Auto-settle inactive threads"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{sidebarAutoSettleAfterDays !== null ? (
|
||||
<SettingsRow
|
||||
title="Days of inactivity before auto-settle"
|
||||
description="Any new activity un-settles a thread automatically."
|
||||
control={
|
||||
<AutoSettleDaysInput
|
||||
value={sidebarAutoSettleAfterDays}
|
||||
onCommit={(days) => updateSettings({ sidebarAutoSettleAfterDays: days })}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
) : null}
|
||||
</SettingsSection>
|
||||
</SettingsPageContainer>
|
||||
);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
ArchiveIcon,
|
||||
ArrowLeftIcon,
|
||||
BotIcon,
|
||||
FlaskConicalIcon,
|
||||
GitBranchIcon,
|
||||
KeyboardIcon,
|
||||
Link2Icon,
|
||||
@@ -28,6 +29,7 @@ export type SettingsSectionPath =
|
||||
| "/settings/providers"
|
||||
| "/settings/source-control"
|
||||
| "/settings/connections"
|
||||
| "/settings/beta"
|
||||
| "/settings/archived";
|
||||
|
||||
export const SETTINGS_NAV_ITEMS: ReadonlyArray<{
|
||||
@@ -40,6 +42,7 @@ export const SETTINGS_NAV_ITEMS: ReadonlyArray<{
|
||||
{ label: "Providers", to: "/settings/providers", icon: BotIcon },
|
||||
{ label: "Source Control", to: "/settings/source-control", icon: GitBranchIcon },
|
||||
{ label: "Connections", to: "/settings/connections", icon: Link2Icon },
|
||||
{ label: "Beta", to: "/settings/beta", icon: FlaskConicalIcon },
|
||||
{ label: "Archive", to: "/settings/archived", icon: ArchiveIcon },
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { SettingsIcon } from "lucide-react";
|
||||
import { memo, useCallback } from "react";
|
||||
import { Link, useNavigate } from "@tanstack/react-router";
|
||||
|
||||
import { APP_STAGE_LABEL } from "../../branding";
|
||||
import { primaryServerConfigAtom } from "../../state/server";
|
||||
import { resolveSidebarStageBadgeLabel } from "../Sidebar.logic";
|
||||
import {
|
||||
SidebarFooter,
|
||||
SidebarHeader,
|
||||
SidebarMenu,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
SidebarTrigger,
|
||||
useSidebar,
|
||||
} from "../ui/sidebar";
|
||||
import { SidebarProviderUpdatePill } from "./SidebarProviderUpdatePill";
|
||||
import { SidebarUpdatePill } from "./SidebarUpdatePill";
|
||||
|
||||
export const SidebarChromeHeader = memo(function SidebarChromeHeader({
|
||||
isElectron,
|
||||
}: {
|
||||
isElectron: boolean;
|
||||
}) {
|
||||
return isElectron ? (
|
||||
<SidebarHeader className="@container/sidebar-header drag-region h-[var(--workspace-topbar-height)] shrink-0 flex-row items-center px-3 py-0 md:px-0">
|
||||
<SidebarTrigger className="md:hidden" />
|
||||
<SidebarBrand />
|
||||
</SidebarHeader>
|
||||
) : (
|
||||
<SidebarHeader className="@container/sidebar-header h-[var(--workspace-topbar-height)] shrink-0 flex-row items-center px-3 py-0 md:px-0">
|
||||
<SidebarTrigger className="md:hidden" />
|
||||
<SidebarBrand />
|
||||
</SidebarHeader>
|
||||
);
|
||||
});
|
||||
|
||||
function SidebarBrand() {
|
||||
const stageLabel = useSidebarStageLabel();
|
||||
|
||||
return (
|
||||
<Link
|
||||
aria-label="Go to threads"
|
||||
className="sidebar-brand ml-[var(--workspace-titlebar-content-left)] h-7 w-fit min-w-0 shrink-0 items-center gap-1 overflow-hidden rounded-md text-foreground outline-hidden ring-ring focus-visible:ring-2"
|
||||
to="/"
|
||||
>
|
||||
<T3Wordmark />
|
||||
<span className="truncate text-sm font-medium tracking-tight text-muted-foreground">
|
||||
Code
|
||||
</span>
|
||||
<span className="sidebar-brand-stage shrink-0 items-center whitespace-nowrap rounded-full bg-muted/50 px-1.5 py-0.5 text-[8px] font-medium uppercase tracking-[0.18em] text-muted-foreground/60">
|
||||
{stageLabel}
|
||||
</span>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
function useSidebarStageLabel() {
|
||||
const primaryServerVersion =
|
||||
useAtomValue(primaryServerConfigAtom)?.environment.serverVersion ?? null;
|
||||
|
||||
return resolveSidebarStageBadgeLabel({
|
||||
primaryServerVersion,
|
||||
fallbackStageLabel: APP_STAGE_LABEL,
|
||||
});
|
||||
}
|
||||
|
||||
function T3Wordmark() {
|
||||
return (
|
||||
<svg
|
||||
aria-label="T3"
|
||||
className="h-2.5 w-auto shrink-0 text-foreground"
|
||||
viewBox="15.5309 37 94.3941 56.96"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M33.4509 93V47.56H15.5309V37H64.3309V47.56H46.4109V93H33.4509ZM86.7253 93.96C82.832 93.96 78.9653 93.4533 75.1253 92.44C71.2853 91.3733 68.032 89.88 65.3653 87.96L70.4053 78.04C72.5386 79.5867 75.0186 80.8133 77.8453 81.72C80.672 82.6267 83.5253 83.08 86.4053 83.08C89.6586 83.08 92.2186 82.44 94.0853 81.16C95.952 79.88 96.8853 78.12 96.8853 75.88C96.8853 73.7467 96.0586 72.0667 94.4053 70.84C92.752 69.6133 90.0853 69 86.4053 69H80.4853V60.44L96.0853 42.76L97.5253 47.4H68.1653V37H107.365V45.4L91.8453 63.08L85.2853 59.32H89.0453C95.9253 59.32 101.125 60.8667 104.645 63.96C108.165 67.0533 109.925 71.0267 109.925 75.88C109.925 79.0267 109.099 81.9867 107.445 84.76C105.792 87.48 103.259 89.6933 99.8453 91.4C96.432 93.1067 92.0586 93.96 86.7253 93.96Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export const SidebarChromeFooter = memo(function SidebarChromeFooter() {
|
||||
const navigate = useNavigate();
|
||||
const { isMobile, setOpenMobile } = useSidebar();
|
||||
const handleSettingsClick = useCallback(() => {
|
||||
if (isMobile) {
|
||||
setOpenMobile(false);
|
||||
}
|
||||
void navigate({ to: "/settings" });
|
||||
}, [isMobile, navigate, setOpenMobile]);
|
||||
|
||||
return (
|
||||
<SidebarFooter className="p-2">
|
||||
<SidebarProviderUpdatePill />
|
||||
<SidebarUpdatePill />
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton
|
||||
size="sm"
|
||||
className="gap-2 px-2 py-1.5 text-muted-foreground/70 hover:bg-accent hover:text-foreground"
|
||||
onClick={handleSettingsClick}
|
||||
>
|
||||
<SettingsIcon className="size-3.5" />
|
||||
<span className="text-xs">Settings</span>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
</SidebarFooter>
|
||||
);
|
||||
});
|
||||
@@ -216,7 +216,7 @@ function Sidebar({
|
||||
<SidebarInstanceContext value={instanceContextValue}>
|
||||
<div
|
||||
className={cn(
|
||||
"flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
|
||||
"flex h-full w-(--sidebar-width) flex-col bg-sidebar surface-grain text-sidebar-foreground",
|
||||
className,
|
||||
)}
|
||||
data-slot="sidebar"
|
||||
@@ -234,7 +234,7 @@ function Sidebar({
|
||||
<Sheet onOpenChange={setOpenMobile} open={openMobile} {...props}>
|
||||
<SheetPopup
|
||||
className={cn(
|
||||
"w-(--sidebar-width) max-w-none bg-sidebar p-0 text-sidebar-foreground",
|
||||
"w-(--sidebar-width) max-w-none bg-sidebar surface-grain p-0 text-sidebar-foreground",
|
||||
className,
|
||||
)}
|
||||
data-mobile="true"
|
||||
@@ -304,7 +304,7 @@ function Sidebar({
|
||||
{...props}
|
||||
>
|
||||
<div
|
||||
className="flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm/5"
|
||||
className="flex h-full w-full flex-col bg-sidebar surface-grain group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm/5"
|
||||
data-sidebar="sidebar"
|
||||
data-slot="sidebar-inner"
|
||||
>
|
||||
@@ -622,7 +622,7 @@ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
|
||||
return (
|
||||
<main
|
||||
className={cn(
|
||||
"relative flex min-w-0 w-full flex-1 flex-col bg-background",
|
||||
"relative flex min-w-0 w-full flex-1 flex-col bg-background surface-grain",
|
||||
"md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ms-2 md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ms-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm/5",
|
||||
className,
|
||||
)}
|
||||
|
||||
@@ -22,7 +22,11 @@ import { readLocalApi } from "../localApi";
|
||||
import { readEnvironmentThreadRefs, readProject, readThreadShell } from "../state/entities";
|
||||
import { useTerminalUiStateStore } from "../terminalUiStateStore";
|
||||
import { buildThreadRouteParams, resolveThreadRouteRef } from "../threadRoutes";
|
||||
import { formatWorktreePathForDisplay, getOrphanedWorktreePathForThread } from "../worktreeCleanup";
|
||||
import {
|
||||
canOfferWorktreeRemoval,
|
||||
formatWorktreePathForDisplay,
|
||||
getOrphanedWorktreePathForThread,
|
||||
} from "../worktreeCleanup";
|
||||
import { stackedThreadToast, toastManager } from "../components/ui/toast";
|
||||
import { useClientSettings } from "./useSettings";
|
||||
import { useAtomCommand } from "../state/use-atom-command";
|
||||
@@ -50,6 +54,12 @@ export function useThreadActions() {
|
||||
const deleteThreadMutation = useAtomCommand(threadEnvironment.delete, {
|
||||
reportFailure: false,
|
||||
});
|
||||
const settleThreadMutation = useAtomCommand(threadEnvironment.settle, {
|
||||
reportFailure: false,
|
||||
});
|
||||
const unsettleThreadMutation = useAtomCommand(threadEnvironment.unsettle, {
|
||||
reportFailure: false,
|
||||
});
|
||||
const stopThreadSession = useAtomCommand(threadEnvironment.stopSession);
|
||||
const removeWorktree = useAtomCommand(vcsEnvironment.removeWorktree, {
|
||||
reportFailure: false,
|
||||
@@ -345,6 +355,141 @@ export function useThreadActions() {
|
||||
],
|
||||
);
|
||||
|
||||
const settleThread = useCallback(
|
||||
async (target: ScopedThreadRef) => {
|
||||
const resolved = resolveThreadTarget(target);
|
||||
const settleResult = await settleThreadMutation({
|
||||
environmentId: target.environmentId,
|
||||
input: { threadId: target.threadId },
|
||||
});
|
||||
if (settleResult._tag === "Failure" || !resolved) {
|
||||
return settleResult;
|
||||
}
|
||||
|
||||
// Settling is the natural moment to reclaim disk: offer (never force) a
|
||||
// worktree removal when this thread is the only one using it and there is
|
||||
// no unsaved or unpushed work at stake.
|
||||
const { thread, threadRef } = resolved;
|
||||
if (thread.worktreePath === null) {
|
||||
return settleResult;
|
||||
}
|
||||
const threads = readEnvironmentThreadRefs(threadRef.environmentId).flatMap((ref) => {
|
||||
const shell = readThreadShell(ref);
|
||||
return shell === null ? [] : [shell];
|
||||
});
|
||||
const orphanedWorktreePath = getOrphanedWorktreePathForThread(threads, threadRef.threadId);
|
||||
const threadProject = readProject({
|
||||
environmentId: threadRef.environmentId,
|
||||
projectId: thread.projectId,
|
||||
});
|
||||
if (orphanedWorktreePath === null || threadProject === null) {
|
||||
return settleResult;
|
||||
}
|
||||
const statusResult = await refreshVcsStatus({
|
||||
environmentId: threadRef.environmentId,
|
||||
input: { cwd: orphanedWorktreePath },
|
||||
});
|
||||
// If status cannot be verified, keep the worktree and skip the prompt.
|
||||
if (statusResult._tag === "Failure" || !canOfferWorktreeRemoval(statusResult.value)) {
|
||||
return settleResult;
|
||||
}
|
||||
const displayWorktreePath = formatWorktreePathForDisplay(orphanedWorktreePath);
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "info",
|
||||
title: "Thread settled",
|
||||
description: `Worktree ${displayWorktreePath} is no longer used by any thread.`,
|
||||
actionProps: {
|
||||
children: "Remove worktree",
|
||||
onClick: () => {
|
||||
void (async () => {
|
||||
// Re-validate at click time: the toast may be stale — the
|
||||
// thread can have woken up or another thread adopted the
|
||||
// worktree since the settle happened.
|
||||
const currentShell = readThreadShell(threadRef);
|
||||
const currentThreads = readEnvironmentThreadRefs(threadRef.environmentId).flatMap(
|
||||
(ref) => {
|
||||
const shell = readThreadShell(ref);
|
||||
return shell === null ? [] : [shell];
|
||||
},
|
||||
);
|
||||
const stillOrphaned =
|
||||
getOrphanedWorktreePathForThread(currentThreads, threadRef.threadId) ===
|
||||
orphanedWorktreePath;
|
||||
const stillSettled = currentShell?.settledOverride === "settled";
|
||||
if (!stillOrphaned || !stillSettled) {
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "warning",
|
||||
title: "Worktree kept",
|
||||
description: "This worktree is in use again and was not removed.",
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
const currentStatusResult = await refreshVcsStatus({
|
||||
environmentId: threadRef.environmentId,
|
||||
input: { cwd: orphanedWorktreePath },
|
||||
});
|
||||
if (
|
||||
currentStatusResult._tag === "Failure" ||
|
||||
!canOfferWorktreeRemoval(currentStatusResult.value)
|
||||
) {
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "warning",
|
||||
title: "Worktree kept",
|
||||
description:
|
||||
"This worktree has uncommitted or unpushed changes, or its status could not be verified.",
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
// force stays false as an additional guard against changes
|
||||
// created between the status check and the removal request.
|
||||
const removeResult = await removeWorktree({
|
||||
environmentId: threadRef.environmentId,
|
||||
input: {
|
||||
cwd: threadProject.workspaceRoot,
|
||||
path: orphanedWorktreePath,
|
||||
force: false,
|
||||
},
|
||||
});
|
||||
if (removeResult._tag === "Failure") {
|
||||
const error = squashAtomCommandFailure(removeResult);
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: "Worktree removal failed",
|
||||
description:
|
||||
error instanceof Error ? error.message : "Could not remove the worktree.",
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
await refreshVcsStatus({
|
||||
environmentId: threadRef.environmentId,
|
||||
input: { cwd: threadProject.workspaceRoot },
|
||||
});
|
||||
})();
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
return settleResult;
|
||||
},
|
||||
[refreshVcsStatus, removeWorktree, resolveThreadTarget, settleThreadMutation],
|
||||
);
|
||||
|
||||
const unsettleThread = useCallback(
|
||||
(target: ScopedThreadRef) =>
|
||||
unsettleThreadMutation({
|
||||
environmentId: target.environmentId,
|
||||
input: { threadId: target.threadId, reason: "user" },
|
||||
}),
|
||||
[unsettleThreadMutation],
|
||||
);
|
||||
|
||||
const confirmAndDeleteThread = useCallback(
|
||||
async (target: ScopedThreadRef) => {
|
||||
const localApi = readLocalApi();
|
||||
@@ -379,7 +524,16 @@ export function useThreadActions() {
|
||||
unarchiveThread,
|
||||
deleteThread,
|
||||
confirmAndDeleteThread,
|
||||
settleThread,
|
||||
unsettleThread,
|
||||
}),
|
||||
[archiveThread, confirmAndDeleteThread, deleteThread, unarchiveThread],
|
||||
[
|
||||
archiveThread,
|
||||
confirmAndDeleteThread,
|
||||
deleteThread,
|
||||
settleThread,
|
||||
unarchiveThread,
|
||||
unsettleThread,
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -36,6 +36,11 @@
|
||||
|
||||
@theme inline {
|
||||
--animate-skeleton: skeleton 2s -1s infinite linear;
|
||||
/* Duty-cycled indicator animations: long opacity holds with short stepped
|
||||
ramps, so the compositor only produces frames while the value changes
|
||||
(~20% of the cycle) instead of every vsync. Keep flat holds dominant. */
|
||||
--animate-status-pulse: status-pulse 2s infinite;
|
||||
--animate-status-ping: status-ping 2s infinite;
|
||||
--font-sans:
|
||||
"DM Sans Variable", "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
|
||||
sans-serif;
|
||||
@@ -78,6 +83,36 @@
|
||||
background-position: -200% 0;
|
||||
}
|
||||
}
|
||||
@keyframes status-pulse {
|
||||
0%,
|
||||
40% {
|
||||
opacity: 1;
|
||||
animation-timing-function: steps(6);
|
||||
}
|
||||
50%,
|
||||
90% {
|
||||
opacity: 0.5;
|
||||
animation-timing-function: steps(6);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@keyframes status-ping {
|
||||
/* Burst first (immediate feedback for click ripples), then hold
|
||||
invisible for the rest of the cycle. Mirrors animate-ping's
|
||||
75%-scale start. */
|
||||
0% {
|
||||
opacity: 0.9;
|
||||
scale: 0.75;
|
||||
animation-timing-function: steps(8);
|
||||
}
|
||||
40%,
|
||||
100% {
|
||||
opacity: 0;
|
||||
scale: 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@layer base {
|
||||
@@ -151,11 +186,18 @@
|
||||
padding-inline-end: calc(env(safe-area-inset-right) + 0.75rem);
|
||||
}
|
||||
|
||||
.chat-composer-glass,
|
||||
.chat-composer-lower-chrome {
|
||||
.chat-composer-glass {
|
||||
background: color-mix(in srgb, var(--card) 20%, transparent);
|
||||
}
|
||||
|
||||
/* Mix from --background (not --card): the lower chrome is a full-width
|
||||
strip over the main view, and a card-tinted wash reads as a lighter
|
||||
seam against it when no content is scrolled underneath. The backdrop
|
||||
blur, not the tint, carries the frosted effect. */
|
||||
.chat-composer-lower-chrome {
|
||||
background: color-mix(in srgb, var(--background) 20%, transparent);
|
||||
}
|
||||
|
||||
.chat-composer-glass {
|
||||
box-shadow:
|
||||
0 18px 48px -20px rgb(0 0 0 / 28%),
|
||||
@@ -167,11 +209,14 @@
|
||||
backdrop-filter: blur(16px);
|
||||
}
|
||||
|
||||
.dark .chat-composer-glass,
|
||||
.dark .chat-composer-lower-chrome {
|
||||
.dark .chat-composer-glass {
|
||||
background: color-mix(in srgb, var(--card) 45%, transparent);
|
||||
}
|
||||
|
||||
.dark .chat-composer-lower-chrome {
|
||||
background: color-mix(in srgb, var(--background) 45%, transparent);
|
||||
}
|
||||
|
||||
.dark .chat-composer-glass {
|
||||
box-shadow:
|
||||
0 18px 48px -20px rgb(0 0 0 / 60%),
|
||||
@@ -192,10 +237,13 @@
|
||||
}
|
||||
|
||||
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
|
||||
.chat-composer-glass,
|
||||
.chat-composer-lower-chrome {
|
||||
.chat-composer-glass {
|
||||
background: var(--card);
|
||||
}
|
||||
|
||||
.chat-composer-lower-chrome {
|
||||
background: var(--background);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +263,15 @@
|
||||
padding-right: max(env(safe-area-inset-right), 0px);
|
||||
}
|
||||
|
||||
/* Grain texture for chrome surfaces that float above the body (see the
|
||||
--surface-grain note). Layered over the element's background-color, so it
|
||||
composes with bg-* utilities. */
|
||||
@utility surface-grain {
|
||||
background-image: var(--surface-grain);
|
||||
background-repeat: repeat;
|
||||
background-size: 256px 256px;
|
||||
}
|
||||
|
||||
/* Suppress all transitions during theme changes */
|
||||
.no-transitions,
|
||||
.no-transitions *,
|
||||
@@ -320,13 +377,19 @@ body {
|
||||
padding-top: max(env(safe-area-inset-top), 0px);
|
||||
}
|
||||
|
||||
body::after {
|
||||
content: "";
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
opacity: 0.035;
|
||||
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
|
||||
/* App-chrome grain. Baked into each surface's own background (behind
|
||||
content) rather than a fixed overlay on top: a full-viewport overlay
|
||||
forces the compositor to re-blend every frame any animation produces,
|
||||
which multiplied idle GPU cost. The overlay's 0.035 opacity lives in the
|
||||
SVG rect instead. Surfaces that float over the body (e.g. the inset main
|
||||
card) must opt in via the surface-grain utility, or they lose the
|
||||
grain's subtle brightening and stand out against the body. */
|
||||
:root {
|
||||
--surface-grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
body {
|
||||
background-image: var(--surface-grain);
|
||||
background-repeat: repeat;
|
||||
background-size: 256px 256px;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
resolveNewDraftStartFromOrigin,
|
||||
startNewLocalThreadFromContext,
|
||||
startNewThreadFromContext,
|
||||
startNewThreadInProjectFromContext,
|
||||
type ChatThreadActionContext,
|
||||
} from "./chatThreadActions";
|
||||
|
||||
@@ -117,6 +118,26 @@ describe("chatThreadActions", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("does not carry branch or worktree context into a different project", async () => {
|
||||
const handleNewThread = vi.fn<ChatThreadActionContext["handleNewThread"]>(async () => {});
|
||||
const targetProjectRef = scopeProjectRef(ENVIRONMENT_ID, FALLBACK_PROJECT_ID);
|
||||
|
||||
await startNewThreadInProjectFromContext(
|
||||
createContext({
|
||||
activeThread: {
|
||||
environmentId: ENVIRONMENT_ID,
|
||||
projectId: PROJECT_ID,
|
||||
branch: "feature/refactor",
|
||||
worktreePath: "/tmp/worktree",
|
||||
},
|
||||
handleNewThread,
|
||||
}),
|
||||
targetProjectRef,
|
||||
);
|
||||
|
||||
expect(handleNewThread).toHaveBeenCalledWith(targetProjectRef);
|
||||
});
|
||||
|
||||
it("delegates the target environment defaults to the new-thread handler", async () => {
|
||||
const handleNewThread = vi.fn<ChatThreadActionContext["handleNewThread"]>(async () => {});
|
||||
|
||||
|
||||
@@ -75,6 +75,14 @@ export async function startNewThreadInProjectFromContext(
|
||||
context: ChatThreadActionContext,
|
||||
projectRef: ScopedProjectRef,
|
||||
): Promise<void> {
|
||||
const contextualProjectRef = resolveThreadActionProjectRef(context);
|
||||
const matchesContext =
|
||||
contextualProjectRef?.environmentId === projectRef.environmentId &&
|
||||
contextualProjectRef.projectId === projectRef.projectId;
|
||||
if (!matchesContext) {
|
||||
await context.handleNewThread(projectRef);
|
||||
return;
|
||||
}
|
||||
await context.handleNewThread(projectRef, buildContextualThreadOptions(context));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
proposedPlans: [],
|
||||
createdAt: "2026-03-09T10:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
updatedAt: "2026-03-09T10:00:00.000Z",
|
||||
latestTurn: null,
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Tiny event bus connecting the global chat.new shortcut (handled in the
|
||||
// _chat route layout) to SidebarV2's project picker dialog. The route layer
|
||||
// can't render the picker itself — it lives with the sidebar — and the
|
||||
// sidebar can't own the window keydown handler without racing the layout's.
|
||||
const NEW_THREAD_PICKER_EVENT = "t3code:open-new-thread-picker";
|
||||
|
||||
export function openNewThreadPicker(): void {
|
||||
window.dispatchEvent(new CustomEvent(NEW_THREAD_PICKER_EVENT));
|
||||
}
|
||||
|
||||
export function onOpenNewThreadPicker(listener: () => void): () => void {
|
||||
window.addEventListener(NEW_THREAD_PICKER_EVENT, listener);
|
||||
return () => window.removeEventListener(NEW_THREAD_PICKER_EVENT, listener);
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import { Route as SettingsKeybindingsRouteImport } from './routes/settings.keybi
|
||||
import { Route as SettingsGeneralRouteImport } from './routes/settings.general'
|
||||
import { Route as SettingsDiagnosticsRouteImport } from './routes/settings.diagnostics'
|
||||
import { Route as SettingsConnectionsRouteImport } from './routes/settings.connections'
|
||||
import { Route as SettingsBetaRouteImport } from './routes/settings.beta'
|
||||
import { Route as SettingsArchivedRouteImport } from './routes/settings.archived'
|
||||
import { Route as ChatDraftDraftIdRouteImport } from './routes/_chat.draft.$draftId'
|
||||
import { Route as ChatEnvironmentIdThreadIdRouteImport } from './routes/_chat.$environmentId.$threadId'
|
||||
@@ -72,6 +73,11 @@ const SettingsConnectionsRoute = SettingsConnectionsRouteImport.update({
|
||||
path: '/connections',
|
||||
getParentRoute: () => SettingsRoute,
|
||||
} as any)
|
||||
const SettingsBetaRoute = SettingsBetaRouteImport.update({
|
||||
id: '/beta',
|
||||
path: '/beta',
|
||||
getParentRoute: () => SettingsRoute,
|
||||
} as any)
|
||||
const SettingsArchivedRoute = SettingsArchivedRouteImport.update({
|
||||
id: '/archived',
|
||||
path: '/archived',
|
||||
@@ -94,6 +100,7 @@ export interface FileRoutesByFullPath {
|
||||
'/pair': typeof PairRoute
|
||||
'/settings': typeof SettingsRouteWithChildren
|
||||
'/settings/archived': typeof SettingsArchivedRoute
|
||||
'/settings/beta': typeof SettingsBetaRoute
|
||||
'/settings/connections': typeof SettingsConnectionsRoute
|
||||
'/settings/diagnostics': typeof SettingsDiagnosticsRoute
|
||||
'/settings/general': typeof SettingsGeneralRoute
|
||||
@@ -107,6 +114,7 @@ export interface FileRoutesByTo {
|
||||
'/pair': typeof PairRoute
|
||||
'/settings': typeof SettingsRouteWithChildren
|
||||
'/settings/archived': typeof SettingsArchivedRoute
|
||||
'/settings/beta': typeof SettingsBetaRoute
|
||||
'/settings/connections': typeof SettingsConnectionsRoute
|
||||
'/settings/diagnostics': typeof SettingsDiagnosticsRoute
|
||||
'/settings/general': typeof SettingsGeneralRoute
|
||||
@@ -123,6 +131,7 @@ export interface FileRoutesById {
|
||||
'/pair': typeof PairRoute
|
||||
'/settings': typeof SettingsRouteWithChildren
|
||||
'/settings/archived': typeof SettingsArchivedRoute
|
||||
'/settings/beta': typeof SettingsBetaRoute
|
||||
'/settings/connections': typeof SettingsConnectionsRoute
|
||||
'/settings/diagnostics': typeof SettingsDiagnosticsRoute
|
||||
'/settings/general': typeof SettingsGeneralRoute
|
||||
@@ -140,6 +149,7 @@ export interface FileRouteTypes {
|
||||
| '/pair'
|
||||
| '/settings'
|
||||
| '/settings/archived'
|
||||
| '/settings/beta'
|
||||
| '/settings/connections'
|
||||
| '/settings/diagnostics'
|
||||
| '/settings/general'
|
||||
@@ -153,6 +163,7 @@ export interface FileRouteTypes {
|
||||
| '/pair'
|
||||
| '/settings'
|
||||
| '/settings/archived'
|
||||
| '/settings/beta'
|
||||
| '/settings/connections'
|
||||
| '/settings/diagnostics'
|
||||
| '/settings/general'
|
||||
@@ -168,6 +179,7 @@ export interface FileRouteTypes {
|
||||
| '/pair'
|
||||
| '/settings'
|
||||
| '/settings/archived'
|
||||
| '/settings/beta'
|
||||
| '/settings/connections'
|
||||
| '/settings/diagnostics'
|
||||
| '/settings/general'
|
||||
@@ -257,6 +269,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof SettingsConnectionsRouteImport
|
||||
parentRoute: typeof SettingsRoute
|
||||
}
|
||||
'/settings/beta': {
|
||||
id: '/settings/beta'
|
||||
path: '/beta'
|
||||
fullPath: '/settings/beta'
|
||||
preLoaderRoute: typeof SettingsBetaRouteImport
|
||||
parentRoute: typeof SettingsRoute
|
||||
}
|
||||
'/settings/archived': {
|
||||
id: '/settings/archived'
|
||||
path: '/archived'
|
||||
@@ -297,6 +316,7 @@ const ChatRouteWithChildren = ChatRoute._addFileChildren(ChatRouteChildren)
|
||||
|
||||
interface SettingsRouteChildren {
|
||||
SettingsArchivedRoute: typeof SettingsArchivedRoute
|
||||
SettingsBetaRoute: typeof SettingsBetaRoute
|
||||
SettingsConnectionsRoute: typeof SettingsConnectionsRoute
|
||||
SettingsDiagnosticsRoute: typeof SettingsDiagnosticsRoute
|
||||
SettingsGeneralRoute: typeof SettingsGeneralRoute
|
||||
@@ -307,6 +327,7 @@ interface SettingsRouteChildren {
|
||||
|
||||
const SettingsRouteChildren: SettingsRouteChildren = {
|
||||
SettingsArchivedRoute: SettingsArchivedRoute,
|
||||
SettingsBetaRoute: SettingsBetaRoute,
|
||||
SettingsConnectionsRoute: SettingsConnectionsRoute,
|
||||
SettingsDiagnosticsRoute: SettingsDiagnosticsRoute,
|
||||
SettingsGeneralRoute: SettingsGeneralRoute,
|
||||
|
||||
@@ -3,6 +3,9 @@ import { useAtomValue } from "@effect/atom-react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { isCommandPaletteOpen } from "../commandPaletteContext";
|
||||
import { useClientSettings } from "../hooks/useSettings";
|
||||
import { openNewThreadPicker } from "../newThreadPickerBus";
|
||||
import { useProjects } from "../state/entities";
|
||||
import { dispatchPreviewAction } from "../components/preview/previewActionBus";
|
||||
import { useHandleNewThread } from "../hooks/useHandleNewThread";
|
||||
import {
|
||||
@@ -25,6 +28,8 @@ function ChatRouteGlobalShortcuts() {
|
||||
const { activeDraftThread, activeThread, defaultProjectRef, handleNewThread, routeThreadRef } =
|
||||
useHandleNewThread();
|
||||
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
|
||||
const sidebarV2Enabled = useClientSettings((settings) => settings.sidebarV2Enabled);
|
||||
const projectCount = useProjects().length;
|
||||
const terminalOpen = useTerminalUiStateStore((state) =>
|
||||
routeThreadRef
|
||||
? selectThreadTerminalUiState(state.terminalUiStateByThreadKey, routeThreadRef).terminalOpen
|
||||
@@ -75,6 +80,13 @@ function ChatRouteGlobalShortcuts() {
|
||||
if (command === "chat.new") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
// Sidebar v2 routes creation through its project picker whenever
|
||||
// there is a real choice to make; v1 (and single-project setups)
|
||||
// keep the immediate contextual create.
|
||||
if (sidebarV2Enabled && projectCount > 1) {
|
||||
openNewThreadPicker();
|
||||
return;
|
||||
}
|
||||
void startNewThreadFromContext({
|
||||
activeDraftThread,
|
||||
activeThread: activeThread ?? undefined,
|
||||
@@ -140,8 +152,10 @@ function ChatRouteGlobalShortcuts() {
|
||||
keybindings,
|
||||
defaultProjectRef,
|
||||
previewOpen,
|
||||
projectCount,
|
||||
routeThreadRef,
|
||||
selectedThreadKeysSize,
|
||||
sidebarV2Enabled,
|
||||
terminalOpen,
|
||||
]);
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
import { BetaSettingsPanel } from "../components/settings/BetaSettingsPanel";
|
||||
|
||||
function SettingsBetaRoute() {
|
||||
return <BetaSettingsPanel />;
|
||||
}
|
||||
|
||||
export const Route = createFileRoute("/settings/beta")({
|
||||
component: SettingsBetaRoute,
|
||||
});
|
||||
@@ -2,7 +2,11 @@ import { EnvironmentId, ProjectId, ProviderInstanceId, ThreadId } from "@t3tools
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { DEFAULT_INTERACTION_MODE, DEFAULT_RUNTIME_MODE, type Thread } from "./types";
|
||||
import { formatWorktreePathForDisplay, getOrphanedWorktreePathForThread } from "./worktreeCleanup";
|
||||
import {
|
||||
canOfferWorktreeRemoval,
|
||||
formatWorktreePathForDisplay,
|
||||
getOrphanedWorktreePathForThread,
|
||||
} from "./worktreeCleanup";
|
||||
|
||||
const localEnvironmentId = EnvironmentId.make("environment-local");
|
||||
|
||||
@@ -26,6 +30,8 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
createdAt: "2026-02-13T00:00:00.000Z",
|
||||
updatedAt: "2026-02-13T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
latestTurn: null,
|
||||
branch: null,
|
||||
@@ -108,3 +114,11 @@ describe("formatWorktreePathForDisplay", () => {
|
||||
expect(result).toBe("my-worktree");
|
||||
});
|
||||
});
|
||||
|
||||
describe("canOfferWorktreeRemoval", () => {
|
||||
it("requires a clean worktree with no unpushed commits", () => {
|
||||
expect(canOfferWorktreeRemoval({ hasWorkingTreeChanges: false, aheadCount: 0 })).toBe(true);
|
||||
expect(canOfferWorktreeRemoval({ hasWorkingTreeChanges: true, aheadCount: 0 })).toBe(false);
|
||||
expect(canOfferWorktreeRemoval({ hasWorkingTreeChanges: false, aheadCount: 1 })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { VcsStatusResult } from "@t3tools/contracts";
|
||||
import type { ThreadShell } from "./types";
|
||||
|
||||
function normalizeWorktreePath(path: string | null): string | null {
|
||||
@@ -43,3 +44,9 @@ export function formatWorktreePathForDisplay(worktreePath: string): string {
|
||||
const lastPart = parts[parts.length - 1]?.trim() ?? "";
|
||||
return lastPart.length > 0 ? lastPart : trimmed;
|
||||
}
|
||||
|
||||
export function canOfferWorktreeRemoval(
|
||||
status: Pick<VcsStatusResult, "hasWorkingTreeChanges" | "aheadCount">,
|
||||
): boolean {
|
||||
return !status.hasWorkingTreeChanges && status.aheadCount === 0;
|
||||
}
|
||||
@@ -60,11 +60,11 @@ sequenceDiagram
|
||||
Transport-->>Browser: Hydrate initial state
|
||||
```
|
||||
|
||||
1. The browser boots [`WsTransport`][1] and registers typed listeners in [`wsNativeApi`][2].
|
||||
2. The server accepts the connection in [`wsServer`][3] and brings up the runtime graph defined in [`serverLayers`][7].
|
||||
3. [`ServerReadiness`][4] waits until the key startup barriers are complete.
|
||||
4. Once the server is ready, [`wsServer`][3] sends `server.welcome` from the contracts in [`ws.ts`][6] through [`ServerPushBus`][5].
|
||||
5. The browser receives that ordered push through [`WsTransport`][1], and [`wsNativeApi`][2] uses it to seed local client state.
|
||||
1. The browser boots `WsTransport` and registers typed listeners in `wsNativeApi`.
|
||||
2. The server accepts the connection in `wsServer` and brings up the runtime graph defined in `serverLayers`.
|
||||
3. `ServerReadiness` waits until the key startup barriers are complete.
|
||||
4. Once the server is ready, `wsServer` sends `server.welcome` from the contracts in `ws.ts` through `ServerPushBus`.
|
||||
5. The browser receives that ordered push through `WsTransport`, and `wsNativeApi` uses it to seed local client state.
|
||||
|
||||
### User turn flow
|
||||
|
||||
@@ -90,12 +90,12 @@ sequenceDiagram
|
||||
Push-->>Browser: Typed push
|
||||
```
|
||||
|
||||
1. A user action in the browser becomes a typed request through [`WsTransport`][1] and the browser API layer in [`nativeApi`][12].
|
||||
2. [`wsServer`][3] decodes that request using the shared WebSocket contracts in [`ws.ts`][6] and routes it to the right service.
|
||||
1. A user action in the browser becomes a typed request through `WsTransport` and the browser API layer in `nativeApi`.
|
||||
2. `wsServer` decodes that request using the shared WebSocket contracts in `ws.ts` and routes it to the right service.
|
||||
3. [`ProviderService`][8] starts or resumes a session and talks to `codex app-server` over JSON-RPC on stdio.
|
||||
4. Provider-native events are pulled back into the server by [`ProviderRuntimeIngestion`][9], which converts them into orchestration events.
|
||||
5. [`OrchestrationEngine`][10] persists those events, updates the read model, and exposes them as domain events.
|
||||
6. [`wsServer`][3] pushes those updates to the browser through [`ServerPushBus`][5] on channels defined in [`orchestration.ts`][11].
|
||||
6. `wsServer` pushes those updates to the browser through `ServerPushBus` on channels defined in [`orchestration.ts`][11].
|
||||
|
||||
### Async completion flow
|
||||
|
||||
@@ -123,21 +123,13 @@ sequenceDiagram
|
||||
2. These flows run as queue-backed workers using [`DrainableWorker`][16], which helps keep side effects ordered and test synchronization deterministic.
|
||||
3. When a milestone completes, the server emits a typed receipt on [`RuntimeReceiptBus`][15], such as checkpoint completion or turn quiescence.
|
||||
4. Tests and orchestration code wait on those receipts instead of polling git state, projections, or timers.
|
||||
5. Any user-visible state changes produced by that async work still go back through [`wsServer`][3] and [`ServerPushBus`][5].
|
||||
5. Any user-visible state changes produced by that async work still go back through `wsServer` and `ServerPushBus`.
|
||||
|
||||
[1]: ../apps/web/src/wsTransport.ts
|
||||
[2]: ../apps/web/src/wsNativeApi.ts
|
||||
[3]: ../apps/server/src/wsServer.ts
|
||||
[4]: ../apps/server/src/wsServer/readiness.ts
|
||||
[5]: ../apps/server/src/wsServer/pushBus.ts
|
||||
[6]: ../packages/contracts/src/ws.ts
|
||||
[7]: ../apps/server/src/serverLayers.ts
|
||||
[8]: ../apps/server/src/provider/Layers/ProviderService.ts
|
||||
[9]: ../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
|
||||
[10]: ../apps/server/src/orchestration/Layers/OrchestrationEngine.ts
|
||||
[11]: ../packages/contracts/src/orchestration.ts
|
||||
[12]: ../apps/web/src/nativeApi.ts
|
||||
[13]: ../apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
|
||||
[14]: ../apps/server/src/orchestration/Layers/CheckpointReactor.ts
|
||||
[15]: ../apps/server/src/orchestration/Layers/RuntimeReceiptBus.ts
|
||||
[16]: ../packages/shared/src/DrainableWorker.ts
|
||||
[8]: ../../apps/server/src/provider/Layers/ProviderService.ts
|
||||
[9]: ../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
|
||||
[10]: ../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts
|
||||
[11]: ../../packages/contracts/src/orchestration.ts
|
||||
[13]: ../../apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
|
||||
[14]: ../../apps/server/src/orchestration/Layers/CheckpointReactor.ts
|
||||
[15]: ../../apps/server/src/orchestration/Layers/RuntimeReceiptBus.ts
|
||||
[16]: ../../packages/shared/src/DrainableWorker.ts
|
||||
@@ -1,6 +1,6 @@
|
||||
# CI quality gates
|
||||
|
||||
- `.github/workflows/ci.yml` runs `bun run lint`, `bun run typecheck`, and `bun run test` on pull requests and pushes to `main`.
|
||||
- `.github/workflows/ci.yml` runs `vp check` (lint + typecheck), `vpr typecheck`, and `vp run test` on pull requests and pushes to `main`.
|
||||
- `.github/workflows/release.yml` builds macOS (`arm64` and `x64`), Linux (`x64`), and Windows (`x64`) desktop artifacts from a single `v*.*.*` tag and publishes one GitHub release.
|
||||
- The release workflow auto-enables signing only when platform credentials are present. macOS passkey builds additionally require `APPLE_TEAM_ID` and the `MACOS_PROVISIONING_PROFILE` secret; Windows uses Azure Trusted Signing. Without the core signing credentials, it still releases unsigned artifacts.
|
||||
- See [Release Checklist](./release.md) for the full release/signing setup checklist.
|
||||
@@ -56,43 +56,43 @@ Effect.fn("name")(
|
||||
|
||||
### `apps/server/src/provider/Layers/ClaudeAdapter.ts` (`62`)
|
||||
|
||||
- [x] [buildUserMessageEffect](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ClaudeAdapter.ts#L554)
|
||||
- [x] [makeClaudeAdapter](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ClaudeAdapter.ts#L913)
|
||||
- [x] [startSession](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ClaudeAdapter.ts#L2414)
|
||||
- [x] [sendTurn](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ClaudeAdapter.ts#L2887)
|
||||
- [x] [interruptTurn](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ClaudeAdapter.ts#L2975)
|
||||
- [x] [readThread](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ClaudeAdapter.ts#L2984)
|
||||
- [x] [rollbackThread](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ClaudeAdapter.ts#L2990)
|
||||
- [x] [stopSession](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ClaudeAdapter.ts#L3039)
|
||||
- [x] [buildUserMessageEffect](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L554)
|
||||
- [x] [makeClaudeAdapter](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L913)
|
||||
- [x] [startSession](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L2414)
|
||||
- [x] [sendTurn](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L2887)
|
||||
- [x] [interruptTurn](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L2975)
|
||||
- [x] [readThread](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L2984)
|
||||
- [x] [rollbackThread](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L2990)
|
||||
- [x] [stopSession](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L3039)
|
||||
- [x] Internal helpers and callback wrappers in this file
|
||||
|
||||
### `apps/server/src/git/Layers/GitCore.ts` (`58`)
|
||||
|
||||
- [x] [makeGitCore](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitCore.ts#L513)
|
||||
- [x] [handleTraceLine](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitCore.ts#L324)
|
||||
- [x] [emitCompleteLines](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitCore.ts#L455)
|
||||
- [x] [commit](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitCore.ts#L1190)
|
||||
- [x] [pushCurrentBranch](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitCore.ts#L1223)
|
||||
- [x] [pullCurrentBranch](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitCore.ts#L1323)
|
||||
- [x] [checkoutBranch](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitCore.ts#L1727)
|
||||
- [x] [makeGitCore](../../apps/server/src/git/Layers/GitCore.ts#L513)
|
||||
- [x] [handleTraceLine](../../apps/server/src/git/Layers/GitCore.ts#L324)
|
||||
- [x] [emitCompleteLines](../../apps/server/src/git/Layers/GitCore.ts#L455)
|
||||
- [x] [commit](../../apps/server/src/git/Layers/GitCore.ts#L1190)
|
||||
- [x] [pushCurrentBranch](../../apps/server/src/git/Layers/GitCore.ts#L1223)
|
||||
- [x] [pullCurrentBranch](../../apps/server/src/git/Layers/GitCore.ts#L1323)
|
||||
- [x] [checkoutBranch](../../apps/server/src/git/Layers/GitCore.ts#L1727)
|
||||
- [x] Service methods and callback wrappers in this file
|
||||
|
||||
### `apps/server/src/git/Layers/GitManager.ts` (`28`)
|
||||
|
||||
- [x] [configurePullRequestHeadUpstream](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitManager.ts#L387)
|
||||
- [x] [materializePullRequestHeadBranch](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitManager.ts#L428)
|
||||
- [x] [findOpenPr](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitManager.ts#L576)
|
||||
- [x] [findLatestPr](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitManager.ts#L602)
|
||||
- [x] [runCommitStep](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitManager.ts#L728)
|
||||
- [x] [runPrStep](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitManager.ts#L842)
|
||||
- [x] [runFeatureBranchStep](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/GitManager.ts#L1106)
|
||||
- [x] [configurePullRequestHeadUpstream](../../apps/server/src/git/Layers/GitManager.ts#L387)
|
||||
- [x] [materializePullRequestHeadBranch](../../apps/server/src/git/Layers/GitManager.ts#L428)
|
||||
- [x] [findOpenPr](../../apps/server/src/git/Layers/GitManager.ts#L576)
|
||||
- [x] [findLatestPr](../../apps/server/src/git/Layers/GitManager.ts#L602)
|
||||
- [x] [runCommitStep](../../apps/server/src/git/Layers/GitManager.ts#L728)
|
||||
- [x] [runPrStep](../../apps/server/src/git/Layers/GitManager.ts#L842)
|
||||
- [x] [runFeatureBranchStep](../../apps/server/src/git/Layers/GitManager.ts#L1106)
|
||||
- [x] Remaining helpers and nested callback wrappers in this file
|
||||
|
||||
### `apps/server/src/orchestration/Layers/ProjectionPipeline.ts` (`25`)
|
||||
|
||||
- [x] [runProjectorForEvent](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/ProjectionPipeline.ts#L1161)
|
||||
- [x] [applyProjectsProjection](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/ProjectionPipeline.ts#L357)
|
||||
- [x] [applyThreadsProjection](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/ProjectionPipeline.ts#L415)
|
||||
- [x] [runProjectorForEvent](../../apps/server/src/orchestration/Layers/ProjectionPipeline.ts#L1161)
|
||||
- [x] [applyProjectsProjection](../../apps/server/src/orchestration/Layers/ProjectionPipeline.ts#L357)
|
||||
- [x] [applyThreadsProjection](../../apps/server/src/orchestration/Layers/ProjectionPipeline.ts#L415)
|
||||
- [x] `Effect.forEach(..., threadId => Effect.gen(...))` callbacks around `L250`
|
||||
- [x] `Effect.forEach(..., entry => Effect.gen(...))` callbacks around `L264`
|
||||
- [x] `Effect.forEach(..., entry => Effect.gen(...))` callbacks around `L305`
|
||||
@@ -100,98 +100,98 @@ Effect.fn("name")(
|
||||
|
||||
### `apps/server/src/provider/Layers/ProviderService.ts` (`24`)
|
||||
|
||||
- [ ] [makeProviderService](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L134)
|
||||
- [ ] [recoverSessionForThread](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L196)
|
||||
- [ ] [resolveRoutableSession](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L255)
|
||||
- [ ] [startSession](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L284)
|
||||
- [ ] [sendTurn](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L347)
|
||||
- [ ] [interruptTurn](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L393)
|
||||
- [ ] [respondToRequest](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L411)
|
||||
- [ ] [respondToUserInput](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L430)
|
||||
- [ ] [stopSession](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L445)
|
||||
- [ ] [listSessions](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L466)
|
||||
- [ ] [rollbackConversation](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L516)
|
||||
- [ ] [runStopAll](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderService.ts#L538)
|
||||
- [ ] [makeProviderService](../../apps/server/src/provider/Layers/ProviderService.ts#L134)
|
||||
- [ ] [recoverSessionForThread](../../apps/server/src/provider/Layers/ProviderService.ts#L196)
|
||||
- [ ] [resolveRoutableSession](../../apps/server/src/provider/Layers/ProviderService.ts#L255)
|
||||
- [ ] [startSession](../../apps/server/src/provider/Layers/ProviderService.ts#L284)
|
||||
- [ ] [sendTurn](../../apps/server/src/provider/Layers/ProviderService.ts#L347)
|
||||
- [ ] [interruptTurn](../../apps/server/src/provider/Layers/ProviderService.ts#L393)
|
||||
- [ ] [respondToRequest](../../apps/server/src/provider/Layers/ProviderService.ts#L411)
|
||||
- [ ] [respondToUserInput](../../apps/server/src/provider/Layers/ProviderService.ts#L430)
|
||||
- [ ] [stopSession](../../apps/server/src/provider/Layers/ProviderService.ts#L445)
|
||||
- [ ] [listSessions](../../apps/server/src/provider/Layers/ProviderService.ts#L466)
|
||||
- [ ] [rollbackConversation](../../apps/server/src/provider/Layers/ProviderService.ts#L516)
|
||||
- [ ] [runStopAll](../../apps/server/src/provider/Layers/ProviderService.ts#L538)
|
||||
|
||||
### `apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts` (`14`)
|
||||
|
||||
- [x] [finalizeAssistantMessage](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L680)
|
||||
- [x] [upsertProposedPlan](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L722)
|
||||
- [x] [finalizeBufferedProposedPlan](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L761)
|
||||
- [x] [clearTurnStateForSession](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L800)
|
||||
- [x] [processRuntimeEvent](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L908)
|
||||
- [x] [finalizeAssistantMessage](../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L680)
|
||||
- [x] [upsertProposedPlan](../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L722)
|
||||
- [x] [finalizeBufferedProposedPlan](../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L761)
|
||||
- [x] [clearTurnStateForSession](../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L800)
|
||||
- [x] [processRuntimeEvent](../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L908)
|
||||
- [x] Nested callback wrappers in this file
|
||||
|
||||
### `apps/server/src/provider/Layers/CodexAdapter.ts` (`12`)
|
||||
|
||||
- [x] [makeCodexAdapter](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/CodexAdapter.ts#L1317)
|
||||
- [x] [sendTurn](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/CodexAdapter.ts#L1399)
|
||||
- [x] [writeNativeEvent](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/CodexAdapter.ts#L1546)
|
||||
- [x] [listener](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/CodexAdapter.ts#L1555)
|
||||
- [x] [makeCodexAdapter](../../apps/server/src/provider/Layers/CodexAdapter.ts#L1317)
|
||||
- [x] [sendTurn](../../apps/server/src/provider/Layers/CodexAdapter.ts#L1399)
|
||||
- [x] [writeNativeEvent](../../apps/server/src/provider/Layers/CodexAdapter.ts#L1546)
|
||||
- [x] [listener](../../apps/server/src/provider/Layers/CodexAdapter.ts#L1555)
|
||||
- [x] Remaining nested callback wrappers in this file
|
||||
|
||||
### `apps/server/src/checkpointing/CheckpointStore.ts` (`10`)
|
||||
|
||||
- [ ] [captureCheckpoint](/Users/julius/Development/Work/codething-mvp/apps/server/src/checkpointing/CheckpointStore.ts#L123)
|
||||
- [ ] [restoreCheckpoint](/Users/julius/Development/Work/codething-mvp/apps/server/src/checkpointing/CheckpointStore.ts#L137)
|
||||
- [ ] [diffCheckpoints](/Users/julius/Development/Work/codething-mvp/apps/server/src/checkpointing/CheckpointStore.ts#L144)
|
||||
- [ ] [deleteCheckpointRefs](/Users/julius/Development/Work/codething-mvp/apps/server/src/checkpointing/CheckpointStore.ts#L151)
|
||||
- [ ] [captureCheckpoint](../../apps/server/src/checkpointing/CheckpointStore.ts#L123)
|
||||
- [ ] [restoreCheckpoint](../../apps/server/src/checkpointing/CheckpointStore.ts#L137)
|
||||
- [ ] [diffCheckpoints](../../apps/server/src/checkpointing/CheckpointStore.ts#L144)
|
||||
- [ ] [deleteCheckpointRefs](../../apps/server/src/checkpointing/CheckpointStore.ts#L151)
|
||||
- [ ] Nested callback wrappers in this file
|
||||
|
||||
### `apps/server/src/provider/Layers/EventNdjsonLogger.ts` (`9`)
|
||||
|
||||
- [ ] [toLogMessage](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/EventNdjsonLogger.ts#L77)
|
||||
- [ ] [makeThreadWriter](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/EventNdjsonLogger.ts#L102)
|
||||
- [ ] [makeEventNdjsonLogger](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/EventNdjsonLogger.ts#L174)
|
||||
- [ ] [write](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/EventNdjsonLogger.ts#L231)
|
||||
- [ ] [close](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/EventNdjsonLogger.ts#L247)
|
||||
- [ ] [toLogMessage](../../apps/server/src/provider/Layers/EventNdjsonLogger.ts#L77)
|
||||
- [ ] [makeThreadWriter](../../apps/server/src/provider/Layers/EventNdjsonLogger.ts#L102)
|
||||
- [ ] [makeEventNdjsonLogger](../../apps/server/src/provider/Layers/EventNdjsonLogger.ts#L174)
|
||||
- [ ] [write](../../apps/server/src/provider/Layers/EventNdjsonLogger.ts#L231)
|
||||
- [ ] [close](../../apps/server/src/provider/Layers/EventNdjsonLogger.ts#L247)
|
||||
- [ ] Flush and writer-resolution callback wrappers in this file
|
||||
|
||||
### `apps/server/scripts/cli.ts` (`8`)
|
||||
|
||||
- [ ] Command handlers around [cli.ts](/Users/julius/Development/Work/codething-mvp/apps/server/scripts/cli.ts#L125)
|
||||
- [ ] Command handlers around [cli.ts](/Users/julius/Development/Work/codething-mvp/apps/server/scripts/cli.ts#L170)
|
||||
- [ ] Resource callbacks around [cli.ts](/Users/julius/Development/Work/codething-mvp/apps/server/scripts/cli.ts#L221)
|
||||
- [ ] Resource callbacks around [cli.ts](/Users/julius/Development/Work/codething-mvp/apps/server/scripts/cli.ts#L239)
|
||||
- [ ] Command handlers around [cli.ts](../../apps/server/scripts/cli.ts#L125)
|
||||
- [ ] Command handlers around [cli.ts](../../apps/server/scripts/cli.ts#L170)
|
||||
- [ ] Resource callbacks around [cli.ts](../../apps/server/scripts/cli.ts#L221)
|
||||
- [ ] Resource callbacks around [cli.ts](../../apps/server/scripts/cli.ts#L239)
|
||||
|
||||
### `apps/server/src/orchestration/Layers/OrchestrationEngine.ts` (`7`)
|
||||
|
||||
- [ ] [processEnvelope](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L64)
|
||||
- [ ] [dispatch](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L218)
|
||||
- [ ] Catch/stream callback wrappers around [OrchestrationEngine.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L162)
|
||||
- [ ] Catch/stream callback wrappers around [OrchestrationEngine.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L200)
|
||||
- [ ] [processEnvelope](../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L64)
|
||||
- [ ] [dispatch](../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L218)
|
||||
- [ ] Catch/stream callback wrappers around [OrchestrationEngine.ts](../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L162)
|
||||
- [ ] Catch/stream callback wrappers around [OrchestrationEngine.ts](../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L200)
|
||||
|
||||
### `apps/server/src/orchestration/projector.ts` (`5`)
|
||||
|
||||
- [ ] `switch` branch wrapper at [projector.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/projector.ts#L242)
|
||||
- [ ] `switch` branch wrapper at [projector.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/projector.ts#L336)
|
||||
- [ ] `switch` branch wrapper at [projector.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/projector.ts#L397)
|
||||
- [ ] `switch` branch wrapper at [projector.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/projector.ts#L446)
|
||||
- [ ] `switch` branch wrapper at [projector.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/projector.ts#L478)
|
||||
- [ ] `switch` branch wrapper at [projector.ts](../../apps/server/src/orchestration/projector.ts#L242)
|
||||
- [ ] `switch` branch wrapper at [projector.ts](../../apps/server/src/orchestration/projector.ts#L336)
|
||||
- [ ] `switch` branch wrapper at [projector.ts](../../apps/server/src/orchestration/projector.ts#L397)
|
||||
- [ ] `switch` branch wrapper at [projector.ts](../../apps/server/src/orchestration/projector.ts#L446)
|
||||
- [ ] `switch` branch wrapper at [projector.ts](../../apps/server/src/orchestration/projector.ts#L478)
|
||||
|
||||
### Smaller clusters
|
||||
|
||||
- [ ] [packages/shared/src/DrainableWorker.ts](/Users/julius/Development/Work/codething-mvp/packages/shared/src/DrainableWorker.ts) (`4`)
|
||||
- [ ] [apps/server/src/wsServer/pushBus.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/wsServer/pushBus.ts) (`4`)
|
||||
- [ ] [apps/server/src/wsServer.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/wsServer.ts) (`4`)
|
||||
- [ ] [apps/server/src/provider/Layers/ProviderRegistry.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderRegistry.ts) (`4`)
|
||||
- [ ] [apps/server/src/persistence/Layers/Sqlite.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/persistence/Layers/Sqlite.ts) (`4`)
|
||||
- [ ] [apps/server/src/orchestration/Layers/ProviderCommandReactor.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts) (`4`)
|
||||
- [ ] [apps/server/src/main.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/main.ts) (`4`)
|
||||
- [ ] [apps/server/src/keybindings.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/keybindings.ts) (`4`)
|
||||
- [ ] [apps/server/src/git/Layers/CodexTextGeneration.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/CodexTextGeneration.ts) (`4`)
|
||||
- [ ] [apps/server/src/serverLayers.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/serverLayers.ts) (`3`)
|
||||
- [ ] [apps/server/src/telemetry/Layers/AnalyticsService.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/telemetry/Layers/AnalyticsService.ts) (`2`)
|
||||
- [ ] [apps/server/src/telemetry/Identify.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/telemetry/Identify.ts) (`2`)
|
||||
- [ ] [apps/server/src/provider/Layers/ProviderAdapterRegistry.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ProviderAdapterRegistry.ts) (`2`)
|
||||
- [ ] [apps/server/src/provider/Layers/CodexProvider.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/CodexProvider.ts) (`2`)
|
||||
- [ ] [apps/server/src/provider/Layers/ClaudeProvider.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/Layers/ClaudeProvider.ts) (`2`)
|
||||
- [ ] [apps/server/src/persistence/NodeSqliteClient.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/persistence/NodeSqliteClient.ts) (`2`)
|
||||
- [ ] [apps/server/src/persistence/Migrations.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/persistence/Migrations.ts) (`2`)
|
||||
- [ ] [apps/server/src/open.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/open.ts) (`2`)
|
||||
- [ ] [apps/server/src/git/Layers/ClaudeTextGeneration.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/git/Layers/ClaudeTextGeneration.ts) (`2`)
|
||||
- [ ] [apps/server/src/checkpointing/CheckpointDiffQuery.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/checkpointing/CheckpointDiffQuery.ts) (`2`)
|
||||
- [ ] [apps/server/src/provider/makeManagedServerProvider.ts](/Users/julius/Development/Work/codething-mvp/apps/server/src/provider/makeManagedServerProvider.ts) (`1`)
|
||||
- [ ] [packages/shared/src/DrainableWorker.ts](../../packages/shared/src/DrainableWorker.ts) (`4`)
|
||||
- [ ] [apps/server/src/wsServer/pushBus.ts](../../apps/server/src/wsServer/pushBus.ts) (`4`)
|
||||
- [ ] [apps/server/src/wsServer.ts](../../apps/server/src/wsServer.ts) (`4`)
|
||||
- [ ] [apps/server/src/provider/Layers/ProviderRegistry.ts](../../apps/server/src/provider/Layers/ProviderRegistry.ts) (`4`)
|
||||
- [ ] [apps/server/src/persistence/Layers/Sqlite.ts](../../apps/server/src/persistence/Layers/Sqlite.ts) (`4`)
|
||||
- [ ] [apps/server/src/orchestration/Layers/ProviderCommandReactor.ts](../../apps/server/src/orchestration/Layers/ProviderCommandReactor.ts) (`4`)
|
||||
- [ ] [apps/server/src/main.ts](../../apps/server/src/main.ts) (`4`)
|
||||
- [ ] [apps/server/src/keybindings.ts](../../apps/server/src/keybindings.ts) (`4`)
|
||||
- [ ] [apps/server/src/git/Layers/CodexTextGeneration.ts](../../apps/server/src/git/Layers/CodexTextGeneration.ts) (`4`)
|
||||
- [ ] [apps/server/src/serverLayers.ts](../../apps/server/src/serverLayers.ts) (`3`)
|
||||
- [ ] [apps/server/src/telemetry/Layers/AnalyticsService.ts](../../apps/server/src/telemetry/Layers/AnalyticsService.ts) (`2`)
|
||||
- [ ] [apps/server/src/telemetry/Identify.ts](../../apps/server/src/telemetry/Identify.ts) (`2`)
|
||||
- [ ] [apps/server/src/provider/Layers/ProviderAdapterRegistry.ts](../../apps/server/src/provider/Layers/ProviderAdapterRegistry.ts) (`2`)
|
||||
- [ ] [apps/server/src/provider/Layers/CodexProvider.ts](../../apps/server/src/provider/Layers/CodexProvider.ts) (`2`)
|
||||
- [ ] [apps/server/src/provider/Layers/ClaudeProvider.ts](../../apps/server/src/provider/Layers/ClaudeProvider.ts) (`2`)
|
||||
- [ ] [apps/server/src/persistence/NodeSqliteClient.ts](../../apps/server/src/persistence/NodeSqliteClient.ts) (`2`)
|
||||
- [ ] [apps/server/src/persistence/Migrations.ts](../../apps/server/src/persistence/Migrations.ts) (`2`)
|
||||
- [ ] [apps/server/src/open.ts](../../apps/server/src/open.ts) (`2`)
|
||||
- [ ] [apps/server/src/git/Layers/ClaudeTextGeneration.ts](../../apps/server/src/git/Layers/ClaudeTextGeneration.ts) (`2`)
|
||||
- [ ] [apps/server/src/checkpointing/CheckpointDiffQuery.ts](../../apps/server/src/checkpointing/CheckpointDiffQuery.ts) (`2`)
|
||||
- [ ] [apps/server/src/provider/makeManagedServerProvider.ts](../../apps/server/src/provider/makeManagedServerProvider.ts) (`1`)
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -127,6 +127,10 @@
|
||||
"types": "./src/state/threadSort.ts",
|
||||
"default": "./src/state/threadSort.ts"
|
||||
},
|
||||
"./state/thread-settled": {
|
||||
"types": "./src/state/threadSettled.ts",
|
||||
"default": "./src/state/threadSettled.ts"
|
||||
},
|
||||
"./state/vcs": {
|
||||
"types": "./src/state/vcs.ts",
|
||||
"default": "./src/state/vcs.ts"
|
||||
|
||||
@@ -21,7 +21,13 @@ import {
|
||||
import * as EnvironmentSupervisor from "../connection/supervisor.ts";
|
||||
import * as RpcSession from "../rpc/session.ts";
|
||||
import type { WsRpcProtocolClient } from "../rpc/protocol.ts";
|
||||
import { archiveThread, createProject, stopThreadSession } from "./commands.ts";
|
||||
import {
|
||||
archiveThread,
|
||||
createProject,
|
||||
settleThread,
|
||||
stopThreadSession,
|
||||
unsettleThread,
|
||||
} from "./commands.ts";
|
||||
|
||||
const TEST_CRYPTO_LAYER = Layer.succeed(
|
||||
Crypto.Crypto,
|
||||
@@ -134,4 +140,35 @@ describe("environment commands", () => {
|
||||
]);
|
||||
}).pipe(Effect.provide(TEST_CRYPTO_LAYER)),
|
||||
);
|
||||
|
||||
it.effect("dispatches settle and unsettle commands without timestamps", () =>
|
||||
Effect.gen(function* () {
|
||||
const dispatched: ClientOrchestrationCommand[] = [];
|
||||
const supervisor = yield* makeSupervisor(dispatched);
|
||||
|
||||
yield* settleThread({
|
||||
commandId: CommandId.make("settle-command"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
}).pipe(Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor));
|
||||
yield* unsettleThread({
|
||||
commandId: CommandId.make("unsettle-command"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
reason: "user",
|
||||
}).pipe(Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor));
|
||||
|
||||
expect(dispatched).toEqual([
|
||||
{
|
||||
type: "thread.settle",
|
||||
commandId: "settle-command",
|
||||
threadId: "thread-1",
|
||||
},
|
||||
{
|
||||
type: "thread.unsettle",
|
||||
commandId: "unsettle-command",
|
||||
threadId: "thread-1",
|
||||
reason: "user",
|
||||
},
|
||||
]);
|
||||
}).pipe(Effect.provide(TEST_CRYPTO_LAYER)),
|
||||
);
|
||||
});
|
||||
@@ -35,6 +35,8 @@ export type CreateThreadInput = CommandInput<"thread.create">;
|
||||
export type DeleteThreadInput = CommandInput<"thread.delete">;
|
||||
export type ArchiveThreadInput = CommandInput<"thread.archive">;
|
||||
export type UnarchiveThreadInput = CommandInput<"thread.unarchive">;
|
||||
export type SettleThreadInput = CommandInput<"thread.settle">;
|
||||
export type UnsettleThreadInput = CommandInput<"thread.unsettle">;
|
||||
export type UpdateThreadMetadataInput = CommandInput<"thread.meta.update">;
|
||||
export type SetThreadRuntimeModeInput = CommandInput<"thread.runtime-mode.set">;
|
||||
export type SetThreadInteractionModeInput = CommandInput<"thread.interaction-mode.set">;
|
||||
@@ -153,6 +155,26 @@ export const unarchiveThread: (input: UnarchiveThreadInput) => CommandEffect = E
|
||||
});
|
||||
});
|
||||
|
||||
export const settleThread: (input: SettleThreadInput) => CommandEffect = Effect.fn(
|
||||
"EnvironmentCommands.settleThread",
|
||||
)(function* (input) {
|
||||
return yield* dispatch({
|
||||
...input,
|
||||
type: "thread.settle",
|
||||
commandId: yield* commandId(input),
|
||||
});
|
||||
});
|
||||
|
||||
export const unsettleThread: (input: UnsettleThreadInput) => CommandEffect = Effect.fn(
|
||||
"EnvironmentCommands.unsettleThread",
|
||||
)(function* (input) {
|
||||
return yield* dispatch({
|
||||
...input,
|
||||
type: "thread.unsettle",
|
||||
commandId: yield* commandId(input),
|
||||
});
|
||||
});
|
||||
|
||||
export const updateThreadMetadata: (input: UpdateThreadMetadataInput) => CommandEffect = Effect.fn(
|
||||
"EnvironmentCommands.updateThreadMetadata",
|
||||
)(function* (input) {
|
||||
|
||||
@@ -96,6 +96,8 @@ const THREAD_SHELL = {
|
||||
createdAt: "2026-06-01T00:00:00.000Z",
|
||||
updatedAt: "2026-06-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
session: null,
|
||||
latestUserMessageAt: null,
|
||||
hasPendingApprovals: false,
|
||||
|
||||
@@ -36,6 +36,8 @@ const stubThread = {
|
||||
createdAt: "2026-04-01T00:00:00.000Z",
|
||||
updatedAt: "2026-04-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
latestUserMessageAt: null,
|
||||
hasPendingApprovals: false,
|
||||
hasPendingUserInput: false,
|
||||
|
||||
@@ -12,9 +12,11 @@ import {
|
||||
type RevertThreadCheckpointInput,
|
||||
type SetThreadInteractionModeInput,
|
||||
type SetThreadRuntimeModeInput,
|
||||
type SettleThreadInput,
|
||||
type StartThreadTurnInput,
|
||||
type StopThreadSessionInput,
|
||||
type UnarchiveThreadInput,
|
||||
type UnsettleThreadInput,
|
||||
type UpdateThreadMetadataInput,
|
||||
archiveThread,
|
||||
createThread,
|
||||
@@ -25,9 +27,11 @@ import {
|
||||
revertThreadCheckpoint,
|
||||
setThreadInteractionMode,
|
||||
setThreadRuntimeMode,
|
||||
settleThread,
|
||||
startThreadTurn,
|
||||
stopThreadSession,
|
||||
unarchiveThread,
|
||||
unsettleThread,
|
||||
updateThreadMetadata,
|
||||
} from "../operations/commands.ts";
|
||||
import type { EnvironmentRegistry } from "../connection/registry.ts";
|
||||
@@ -42,9 +46,11 @@ export type {
|
||||
RevertThreadCheckpointInput,
|
||||
SetThreadInteractionModeInput,
|
||||
SetThreadRuntimeModeInput,
|
||||
SettleThreadInput,
|
||||
StartThreadTurnInput,
|
||||
StopThreadSessionInput,
|
||||
UnarchiveThreadInput,
|
||||
UnsettleThreadInput,
|
||||
UpdateThreadMetadataInput,
|
||||
} from "../operations/commands.ts";
|
||||
|
||||
@@ -82,6 +88,18 @@ export function createThreadEnvironmentAtoms<R, E>(
|
||||
scheduler,
|
||||
concurrency,
|
||||
}),
|
||||
settle: createEnvironmentCommand(runtime, {
|
||||
label: "environment-data:commands:thread:settle",
|
||||
execute: (input: SettleThreadInput) => settleThread(input),
|
||||
scheduler,
|
||||
concurrency,
|
||||
}),
|
||||
unsettle: createEnvironmentCommand(runtime, {
|
||||
label: "environment-data:commands:thread:unsettle",
|
||||
execute: (input: UnsettleThreadInput) => unsettleThread(input),
|
||||
scheduler,
|
||||
concurrency,
|
||||
}),
|
||||
updateMetadata: createEnvironmentCommand(runtime, {
|
||||
label: "environment-data:commands:thread:update-metadata",
|
||||
execute: (input: UpdateThreadMetadataInput) => updateThreadMetadata(input),
|
||||
|
||||
@@ -57,6 +57,8 @@ export function mergeEnvironmentThread(
|
||||
createdAt: shell.createdAt,
|
||||
updatedAt: shell.updatedAt,
|
||||
archivedAt: shell.archivedAt,
|
||||
settledOverride: shell.settledOverride,
|
||||
settledAt: shell.settledAt,
|
||||
session: shell.session,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ const baseThread: OrchestrationThread = {
|
||||
createdAt: "2026-04-01T00:00:00.000Z",
|
||||
updatedAt: "2026-04-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
@@ -164,6 +166,62 @@ describe("applyThreadDetailEvent", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("thread.settled / thread.unsettled", () => {
|
||||
it("sets the settled override and timestamp", () => {
|
||||
const settledAt = "2026-04-01T05:00:00.000Z";
|
||||
const result = applyThreadDetailEvent(baseThread, {
|
||||
...baseEventFields,
|
||||
sequence: 5,
|
||||
occurredAt: settledAt,
|
||||
aggregateKind: "thread",
|
||||
aggregateId: ThreadId.make("thread-1"),
|
||||
type: "thread.settled",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
settledAt,
|
||||
updatedAt: settledAt,
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.kind).toBe("updated");
|
||||
if (result.kind === "updated") {
|
||||
expect(result.thread.settledOverride).toBe("settled");
|
||||
expect(result.thread.settledAt).toBe(settledAt);
|
||||
}
|
||||
});
|
||||
|
||||
it.each([
|
||||
["user", "active"],
|
||||
["activity", null],
|
||||
] as const)("unsettles for %s with override %s", (reason, settledOverride) => {
|
||||
const settledThread: OrchestrationThread = {
|
||||
...baseThread,
|
||||
settledOverride: "settled",
|
||||
settledAt: "2026-04-01T05:00:00.000Z",
|
||||
};
|
||||
const updatedAt = "2026-04-01T06:00:00.000Z";
|
||||
const result = applyThreadDetailEvent(settledThread, {
|
||||
...baseEventFields,
|
||||
sequence: 6,
|
||||
occurredAt: updatedAt,
|
||||
aggregateKind: "thread",
|
||||
aggregateId: ThreadId.make("thread-1"),
|
||||
type: "thread.unsettled",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
reason,
|
||||
updatedAt,
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.kind).toBe("updated");
|
||||
if (result.kind === "updated") {
|
||||
expect(result.thread.settledOverride).toBe(settledOverride);
|
||||
expect(result.thread.settledAt).toBeNull();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("thread.meta-updated", () => {
|
||||
it("patches title and branch", () => {
|
||||
const result = applyThreadDetailEvent(baseThread, {
|
||||
|
||||
@@ -72,6 +72,8 @@ export function applyThreadDetailEvent(
|
||||
createdAt: event.payload.createdAt,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
@@ -100,6 +102,28 @@ export function applyThreadDetailEvent(
|
||||
thread: { ...thread, archivedAt: null, updatedAt: event.payload.updatedAt },
|
||||
};
|
||||
|
||||
case "thread.settled":
|
||||
return {
|
||||
kind: "updated",
|
||||
thread: {
|
||||
...thread,
|
||||
settledOverride: "settled",
|
||||
settledAt: event.payload.settledAt,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
},
|
||||
};
|
||||
|
||||
case "thread.unsettled":
|
||||
return {
|
||||
kind: "updated",
|
||||
thread: {
|
||||
...thread,
|
||||
settledOverride: event.payload.reason === "user" ? "active" : null,
|
||||
settledAt: null,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
},
|
||||
};
|
||||
|
||||
// ── Thread metadata ─────────────────────────────────────────────
|
||||
case "thread.meta-updated":
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
import {
|
||||
ProjectId,
|
||||
ProviderInstanceId,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
type OrchestrationThreadShell,
|
||||
} from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
effectiveSettled,
|
||||
threadLastActivityAt,
|
||||
type ChangeRequestStateLike,
|
||||
} from "./threadSettled.ts";
|
||||
|
||||
const NOW = "2026-04-10T00:00:00.000Z";
|
||||
const FRESH = "2026-04-09T00:00:00.000Z";
|
||||
const STALE = "2026-04-06T23:59:59.999Z";
|
||||
|
||||
function makeShell(input: {
|
||||
readonly settledOverride: OrchestrationThreadShell["settledOverride"];
|
||||
readonly activityAt: string | null;
|
||||
readonly sessionStatus?: "starting" | "running";
|
||||
readonly pending?: "approval" | "user-input";
|
||||
}): OrchestrationThreadShell {
|
||||
const threadId = ThreadId.make("thread-1");
|
||||
return {
|
||||
id: threadId,
|
||||
projectId: ProjectId.make("project-1"),
|
||||
title: "Thread",
|
||||
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
latestTurn:
|
||||
input.activityAt === null
|
||||
? null
|
||||
: {
|
||||
turnId: TurnId.make("turn-1"),
|
||||
state: "completed",
|
||||
requestedAt: input.activityAt,
|
||||
startedAt: null,
|
||||
completedAt: null,
|
||||
assistantMessageId: null,
|
||||
},
|
||||
createdAt: "2026-04-01T00:00:00.000Z",
|
||||
updatedAt: NOW,
|
||||
archivedAt: null,
|
||||
settledOverride: input.settledOverride,
|
||||
settledAt: input.settledOverride === "settled" ? NOW : null,
|
||||
session:
|
||||
input.sessionStatus === undefined
|
||||
? null
|
||||
: {
|
||||
threadId,
|
||||
status: input.sessionStatus,
|
||||
providerName: "Codex",
|
||||
runtimeMode: "full-access",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: NOW,
|
||||
},
|
||||
latestUserMessageAt: null,
|
||||
hasPendingApprovals: input.pending === "approval",
|
||||
hasPendingUserInput: input.pending === "user-input",
|
||||
hasActionableProposedPlan: false,
|
||||
};
|
||||
}
|
||||
|
||||
describe("threadLastActivityAt", () => {
|
||||
it("returns the latest real user or turn activity and ignores thread/session updates", () => {
|
||||
const shell = makeShell({ settledOverride: null, activityAt: null, sessionStatus: "running" });
|
||||
const withActivity: OrchestrationThreadShell = {
|
||||
...shell,
|
||||
latestUserMessageAt: "2026-04-04T00:00:00.000Z",
|
||||
latestTurn: {
|
||||
turnId: TurnId.make("turn-1"),
|
||||
state: "completed",
|
||||
requestedAt: "2026-04-03T00:00:00.000Z",
|
||||
startedAt: "2026-04-05T00:00:00.000Z",
|
||||
completedAt: "2026-04-06T00:00:00.000Z",
|
||||
assistantMessageId: null,
|
||||
},
|
||||
};
|
||||
|
||||
expect(threadLastActivityAt(withActivity)).toBe("2026-04-06T00:00:00.000Z");
|
||||
expect(threadLastActivityAt(shell)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("effectiveSettled", () => {
|
||||
const overrides = ["settled", "active", null] as const;
|
||||
const changeRequestStates = [undefined, "open", "merged"] as const;
|
||||
const inactivityCases = [
|
||||
["fresh", FRESH],
|
||||
["stale", STALE],
|
||||
["no-activity", null],
|
||||
] as const;
|
||||
const runningCases = [false, true] as const;
|
||||
const pendingCases = [undefined, "approval", "user-input"] as const;
|
||||
const truthTable = overrides.flatMap((settledOverride) =>
|
||||
changeRequestStates.flatMap((changeRequestState) =>
|
||||
inactivityCases.flatMap(([inactivity, activityAt]) =>
|
||||
runningCases.flatMap((running) =>
|
||||
pendingCases.map((pending) => ({
|
||||
settledOverride,
|
||||
changeRequestState,
|
||||
inactivity,
|
||||
activityAt,
|
||||
running,
|
||||
pending,
|
||||
expected:
|
||||
pending === undefined &&
|
||||
(settledOverride === "settled" ||
|
||||
(settledOverride === null &&
|
||||
!running &&
|
||||
(changeRequestState === "merged" || inactivity === "stale"))),
|
||||
})),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
it.each(truthTable)(
|
||||
"override=$settledOverride pr=$changeRequestState inactivity=$inactivity running=$running pending=$pending",
|
||||
({ settledOverride, changeRequestState, activityAt, running, pending, expected }) => {
|
||||
const shell = makeShell({
|
||||
settledOverride,
|
||||
activityAt,
|
||||
...(running ? { sessionStatus: "running" as const } : {}),
|
||||
...(pending === undefined ? {} : { pending }),
|
||||
});
|
||||
const changeRequestOptions =
|
||||
changeRequestState === undefined
|
||||
? {}
|
||||
: { changeRequestState: changeRequestState as ChangeRequestStateLike };
|
||||
|
||||
expect(
|
||||
effectiveSettled(shell, {
|
||||
now: NOW,
|
||||
autoSettleAfterDays: 3,
|
||||
...changeRequestOptions,
|
||||
}),
|
||||
).toBe(expected);
|
||||
},
|
||||
);
|
||||
|
||||
it("treats closed change requests like merged ones", () => {
|
||||
const shell = makeShell({ settledOverride: null, activityAt: null });
|
||||
expect(
|
||||
effectiveSettled(shell, {
|
||||
now: NOW,
|
||||
autoSettleAfterDays: null,
|
||||
changeRequestState: "closed",
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("never auto-settles a starting session", () => {
|
||||
const shell = makeShell({
|
||||
settledOverride: null,
|
||||
activityAt: STALE,
|
||||
sessionStatus: "starting",
|
||||
});
|
||||
expect(
|
||||
effectiveSettled(shell, {
|
||||
now: NOW,
|
||||
autoSettleAfterDays: 3,
|
||||
changeRequestState: "merged",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("uses a strict inactivity boundary and honors a null threshold", () => {
|
||||
const boundary = makeShell({
|
||||
settledOverride: null,
|
||||
activityAt: "2026-04-07T00:00:00.000Z",
|
||||
});
|
||||
const stale = makeShell({ settledOverride: null, activityAt: STALE });
|
||||
|
||||
expect(effectiveSettled(boundary, { now: NOW, autoSettleAfterDays: 3 })).toBe(false);
|
||||
expect(effectiveSettled(stale, { now: NOW, autoSettleAfterDays: null })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
import type { OrchestrationThreadShell } from "@t3tools/contracts";
|
||||
|
||||
export type ChangeRequestStateLike = "open" | "closed" | "merged";
|
||||
|
||||
const DAY_MS = 24 * 60 * 60 * 1_000;
|
||||
|
||||
export function threadLastActivityAt(shell: OrchestrationThreadShell): string | null {
|
||||
const candidates = [
|
||||
shell.latestUserMessageAt,
|
||||
shell.latestTurn?.requestedAt,
|
||||
shell.latestTurn?.startedAt,
|
||||
shell.latestTurn?.completedAt,
|
||||
];
|
||||
let latest: string | null = null;
|
||||
let latestTimestamp = Number.NEGATIVE_INFINITY;
|
||||
|
||||
for (const candidate of candidates) {
|
||||
if (candidate === null || candidate === undefined) continue;
|
||||
const timestamp = Date.parse(candidate);
|
||||
if (timestamp > latestTimestamp) {
|
||||
latest = candidate;
|
||||
latestTimestamp = timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
return latest;
|
||||
}
|
||||
|
||||
export function effectiveSettled(
|
||||
shell: OrchestrationThreadShell,
|
||||
options: {
|
||||
readonly now: string;
|
||||
readonly autoSettleAfterDays: number | null;
|
||||
readonly changeRequestState?: ChangeRequestStateLike | null;
|
||||
},
|
||||
): boolean {
|
||||
// Blocked work must remain visible even when a user explicitly settled it.
|
||||
if (shell.hasPendingApprovals || shell.hasPendingUserInput) return false;
|
||||
if (shell.settledOverride === "settled") return true;
|
||||
if (shell.settledOverride === "active") return false;
|
||||
if (shell.session?.status === "starting" || shell.session?.status === "running") return false;
|
||||
if (options.changeRequestState === "merged" || options.changeRequestState === "closed") {
|
||||
return true;
|
||||
}
|
||||
if (options.autoSettleAfterDays === null) return false;
|
||||
|
||||
const lastActivityAt = threadLastActivityAt(shell);
|
||||
if (lastActivityAt === null) return false;
|
||||
|
||||
return (
|
||||
Date.parse(lastActivityAt) < Date.parse(options.now) - options.autoSettleAfterDays * DAY_MS
|
||||
);
|
||||
}
|
||||
@@ -67,6 +67,8 @@ const BASE_THREAD: OrchestrationThread = {
|
||||
createdAt: "2026-04-01T00:00:00.000Z",
|
||||
updatedAt: "2026-04-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
ProjectMetaUpdatedPayload,
|
||||
OrchestrationProposedPlan,
|
||||
OrchestrationSession,
|
||||
OrchestrationThread,
|
||||
OrchestrationThreadShell,
|
||||
ProjectCreateCommand,
|
||||
ThreadMetaUpdatedPayload,
|
||||
ThreadTurnStartCommand,
|
||||
@@ -37,6 +39,8 @@ const decodeThreadTurnStartRequestedPayload = Schema.decodeUnknownEffect(
|
||||
const decodeOrchestrationLatestTurn = Schema.decodeUnknownEffect(OrchestrationLatestTurn);
|
||||
const decodeOrchestrationProposedPlan = Schema.decodeUnknownEffect(OrchestrationProposedPlan);
|
||||
const decodeOrchestrationSession = Schema.decodeUnknownEffect(OrchestrationSession);
|
||||
const decodeOrchestrationThread = Schema.decodeUnknownEffect(OrchestrationThread);
|
||||
const decodeOrchestrationThreadShell = Schema.decodeUnknownEffect(OrchestrationThreadShell);
|
||||
const encodeThreadCreatedPayload = Schema.encodeEffect(ThreadCreatedPayload);
|
||||
|
||||
function getOptionValue(
|
||||
@@ -344,6 +348,65 @@ it.effect("decodes thread archive and unarchive commands", () =>
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("decodes thread settle and unsettle commands", () =>
|
||||
Effect.gen(function* () {
|
||||
const settle = yield* decodeOrchestrationCommand({
|
||||
type: "thread.settle",
|
||||
commandId: "cmd-settle-1",
|
||||
threadId: "thread-1",
|
||||
});
|
||||
const unsettle = yield* decodeOrchestrationCommand({
|
||||
type: "thread.unsettle",
|
||||
commandId: "cmd-unsettle-1",
|
||||
threadId: "thread-1",
|
||||
reason: "activity",
|
||||
});
|
||||
|
||||
assert.strictEqual(settle.type, "thread.settle");
|
||||
assert.strictEqual(unsettle.type, "thread.unsettle");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("defaults settled fields when decoding historical thread data", () =>
|
||||
Effect.gen(function* () {
|
||||
const common = {
|
||||
id: "thread-1",
|
||||
projectId: "project-1",
|
||||
title: "Historical thread",
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
latestTurn: null,
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
updatedAt: "2026-01-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
session: null,
|
||||
};
|
||||
const thread = yield* decodeOrchestrationThread({
|
||||
...common,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
activities: [],
|
||||
checkpoints: [],
|
||||
});
|
||||
const shell = yield* decodeOrchestrationThreadShell({
|
||||
...common,
|
||||
latestUserMessageAt: null,
|
||||
hasPendingApprovals: false,
|
||||
hasPendingUserInput: false,
|
||||
hasActionableProposedPlan: false,
|
||||
});
|
||||
|
||||
assert.strictEqual(thread.settledOverride, null);
|
||||
assert.strictEqual(thread.settledAt, null);
|
||||
assert.strictEqual(shell.settledOverride, null);
|
||||
assert.strictEqual(shell.settledAt, null);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("decodes thread archived and unarchived events", () =>
|
||||
Effect.gen(function* () {
|
||||
const archived = yield* decodeOrchestrationEvent({
|
||||
@@ -388,6 +451,48 @@ it.effect("decodes thread archived and unarchived events", () =>
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("decodes thread settled and unsettled events", () =>
|
||||
Effect.gen(function* () {
|
||||
const settled = yield* decodeOrchestrationEvent({
|
||||
sequence: 1,
|
||||
eventId: "event-settle-1",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: "thread-1",
|
||||
type: "thread.settled",
|
||||
occurredAt: "2026-01-01T00:00:00.000Z",
|
||||
commandId: "cmd-settle-1",
|
||||
causationEventId: null,
|
||||
correlationId: "cmd-settle-1",
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
settledAt: "2026-01-01T00:00:00.000Z",
|
||||
updatedAt: "2026-01-01T00:00:00.000Z",
|
||||
},
|
||||
});
|
||||
const unsettled = yield* decodeOrchestrationEvent({
|
||||
sequence: 2,
|
||||
eventId: "event-unsettle-1",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: "thread-1",
|
||||
type: "thread.unsettled",
|
||||
occurredAt: "2026-01-02T00:00:00.000Z",
|
||||
commandId: "cmd-unsettle-1",
|
||||
causationEventId: null,
|
||||
correlationId: "cmd-unsettle-1",
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
reason: "user",
|
||||
updatedAt: "2026-01-02T00:00:00.000Z",
|
||||
},
|
||||
});
|
||||
|
||||
assert.strictEqual(settled.type, "thread.settled");
|
||||
assert.strictEqual(unsettled.type, "thread.unsettled");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("accepts provider-scoped model options in thread.turn.start", () =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decodeThreadTurnStartCommand({
|
||||
|
||||
@@ -356,6 +356,10 @@ export const OrchestrationThread = Schema.Struct({
|
||||
createdAt: IsoDateTime,
|
||||
updatedAt: IsoDateTime,
|
||||
archivedAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
|
||||
settledOverride: Schema.NullOr(Schema.Literals(["settled", "active"])).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(null)),
|
||||
),
|
||||
settledAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
|
||||
deletedAt: Schema.NullOr(IsoDateTime),
|
||||
messages: Schema.Array(OrchestrationMessage),
|
||||
proposedPlans: Schema.Array(OrchestrationProposedPlan).pipe(
|
||||
@@ -402,6 +406,10 @@ export const OrchestrationThreadShell = Schema.Struct({
|
||||
createdAt: IsoDateTime,
|
||||
updatedAt: IsoDateTime,
|
||||
archivedAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
|
||||
settledOverride: Schema.NullOr(Schema.Literals(["settled", "active"])).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(null)),
|
||||
),
|
||||
settledAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
|
||||
session: Schema.NullOr(OrchestrationSession),
|
||||
latestUserMessageAt: Schema.NullOr(IsoDateTime),
|
||||
hasPendingApprovals: Schema.Boolean,
|
||||
@@ -545,6 +553,19 @@ const ThreadUnarchiveCommand = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
});
|
||||
|
||||
const ThreadSettleCommand = Schema.Struct({
|
||||
type: Schema.Literal("thread.settle"),
|
||||
commandId: CommandId,
|
||||
threadId: ThreadId,
|
||||
});
|
||||
|
||||
const ThreadUnsettleCommand = Schema.Struct({
|
||||
type: Schema.Literal("thread.unsettle"),
|
||||
commandId: CommandId,
|
||||
threadId: ThreadId,
|
||||
reason: Schema.Literals(["user", "activity"]),
|
||||
});
|
||||
|
||||
const ThreadMetaUpdateCommand = Schema.Struct({
|
||||
type: Schema.Literal("thread.meta.update"),
|
||||
commandId: CommandId,
|
||||
@@ -687,6 +708,8 @@ const DispatchableClientOrchestrationCommand = Schema.Union([
|
||||
ThreadDeleteCommand,
|
||||
ThreadArchiveCommand,
|
||||
ThreadUnarchiveCommand,
|
||||
ThreadSettleCommand,
|
||||
ThreadUnsettleCommand,
|
||||
ThreadMetaUpdateCommand,
|
||||
ThreadRuntimeModeSetCommand,
|
||||
ThreadInteractionModeSetCommand,
|
||||
@@ -708,6 +731,8 @@ export const ClientOrchestrationCommand = Schema.Union([
|
||||
ThreadDeleteCommand,
|
||||
ThreadArchiveCommand,
|
||||
ThreadUnarchiveCommand,
|
||||
ThreadSettleCommand,
|
||||
ThreadUnsettleCommand,
|
||||
ThreadMetaUpdateCommand,
|
||||
ThreadRuntimeModeSetCommand,
|
||||
ThreadInteractionModeSetCommand,
|
||||
@@ -810,6 +835,8 @@ export const OrchestrationEventType = Schema.Literals([
|
||||
"thread.deleted",
|
||||
"thread.archived",
|
||||
"thread.unarchived",
|
||||
"thread.settled",
|
||||
"thread.unsettled",
|
||||
"thread.meta-updated",
|
||||
"thread.runtime-mode-set",
|
||||
"thread.interaction-mode-set",
|
||||
@@ -889,6 +916,18 @@ export const ThreadUnarchivedPayload = Schema.Struct({
|
||||
updatedAt: IsoDateTime,
|
||||
});
|
||||
|
||||
export const ThreadSettledPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
settledAt: IsoDateTime,
|
||||
updatedAt: IsoDateTime,
|
||||
});
|
||||
|
||||
export const ThreadUnsettledPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
reason: Schema.Literals(["user", "activity"]),
|
||||
updatedAt: IsoDateTime,
|
||||
});
|
||||
|
||||
export const ThreadMetaUpdatedPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
@@ -1056,6 +1095,16 @@ export const OrchestrationEvent = Schema.Union([
|
||||
type: Schema.Literal("thread.unarchived"),
|
||||
payload: ThreadUnarchivedPayload,
|
||||
}),
|
||||
Schema.Struct({
|
||||
...EventBaseFields,
|
||||
type: Schema.Literal("thread.settled"),
|
||||
payload: ThreadSettledPayload,
|
||||
}),
|
||||
Schema.Struct({
|
||||
...EventBaseFields,
|
||||
type: Schema.Literal("thread.unsettled"),
|
||||
payload: ThreadUnsettledPayload,
|
||||
}),
|
||||
Schema.Struct({
|
||||
...EventBaseFields,
|
||||
type: Schema.Literal("thread.meta-updated"),
|
||||
|
||||
@@ -4,12 +4,14 @@ import * as Schema from "effect/Schema";
|
||||
import { ProviderInstanceId } from "./providerInstance.ts";
|
||||
import {
|
||||
ClientSettingsSchema,
|
||||
ClientSettingsPatch,
|
||||
DEFAULT_SERVER_SETTINGS,
|
||||
ServerSettings,
|
||||
ServerSettingsPatch,
|
||||
} from "./settings.ts";
|
||||
|
||||
const decodeClientSettings = Schema.decodeUnknownSync(ClientSettingsSchema);
|
||||
const decodeClientSettingsPatch = Schema.decodeUnknownSync(ClientSettingsPatch);
|
||||
const decodeServerSettings = Schema.decodeUnknownSync(ServerSettings);
|
||||
const decodeServerSettingsPatch = Schema.decodeUnknownSync(ServerSettingsPatch);
|
||||
const encodeServerSettings = Schema.encodeSync(ServerSettings);
|
||||
@@ -31,6 +33,25 @@ describe("ClientSettings word wrap", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("ClientSettings sidebar v2", () => {
|
||||
it("defaults the beta off with a three-day auto-settle threshold", () => {
|
||||
const settings = decodeClientSettings({});
|
||||
expect(settings.sidebarV2Enabled).toBe(false);
|
||||
expect(settings.sidebarAutoSettleAfterDays).toBe(3);
|
||||
});
|
||||
|
||||
it("allows auto-settle by inactivity to be disabled", () => {
|
||||
expect(
|
||||
decodeClientSettings({ sidebarAutoSettleAfterDays: null }).sidebarAutoSettleAfterDays,
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it.each([-1, 0, 91])("rejects an auto-settle threshold outside 1..90: %s", (value) => {
|
||||
expect(() => decodeClientSettings({ sidebarAutoSettleAfterDays: value })).toThrow();
|
||||
expect(() => decodeClientSettingsPatch({ sidebarAutoSettleAfterDays: value })).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("ServerSettings.providerInstances (slice-2 invariant)", () => {
|
||||
it("defaults to an empty record so legacy configs without the key still decode", () => {
|
||||
expect(DEFAULT_SERVER_SETTINGS.providerInstances).toEqual({});
|
||||
|
||||
@@ -38,6 +38,16 @@ export const SidebarThreadPreviewCount = Schema.Int.check(
|
||||
);
|
||||
export type SidebarThreadPreviewCount = typeof SidebarThreadPreviewCount.Type;
|
||||
export const DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT: SidebarThreadPreviewCount = 6;
|
||||
export const MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS = 1;
|
||||
export const MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS = 90;
|
||||
export const SidebarAutoSettleAfterDays = Schema.Number.check(
|
||||
Schema.isBetween({
|
||||
minimum: MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
|
||||
maximum: MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
|
||||
}),
|
||||
);
|
||||
export type SidebarAutoSettleAfterDays = typeof SidebarAutoSettleAfterDays.Type;
|
||||
export const DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS: SidebarAutoSettleAfterDays = 3;
|
||||
|
||||
export const ClientSettingsSchema = Schema.Struct({
|
||||
autoOpenPlanSidebar: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
||||
@@ -72,6 +82,9 @@ export const ClientSettingsSchema = Schema.Struct({
|
||||
modelOrder: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
|
||||
}),
|
||||
).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
|
||||
sidebarAutoSettleAfterDays: Schema.NullOr(SidebarAutoSettleAfterDays).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS)),
|
||||
),
|
||||
sidebarProjectGroupingMode: SidebarProjectGroupingMode.pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE)),
|
||||
),
|
||||
@@ -88,6 +101,7 @@ export const ClientSettingsSchema = Schema.Struct({
|
||||
sidebarThreadPreviewCount: SidebarThreadPreviewCount.pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT)),
|
||||
),
|
||||
sidebarV2Enabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
||||
timestampFormat: TimestampFormat.pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(DEFAULT_TIMESTAMP_FORMAT)),
|
||||
),
|
||||
@@ -559,6 +573,7 @@ export const ClientSettingsPatch = Schema.Struct({
|
||||
}),
|
||||
),
|
||||
),
|
||||
sidebarAutoSettleAfterDays: Schema.optionalKey(Schema.NullOr(SidebarAutoSettleAfterDays)),
|
||||
sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),
|
||||
sidebarProjectGroupingOverrides: Schema.optionalKey(
|
||||
Schema.Record(TrimmedNonEmptyString, SidebarProjectGroupingMode),
|
||||
@@ -566,6 +581,7 @@ export const ClientSettingsPatch = Schema.Struct({
|
||||
sidebarProjectSortOrder: Schema.optionalKey(SidebarProjectSortOrder),
|
||||
sidebarThreadSortOrder: Schema.optionalKey(SidebarThreadSortOrder),
|
||||
sidebarThreadPreviewCount: Schema.optionalKey(SidebarThreadPreviewCount),
|
||||
sidebarV2Enabled: Schema.optionalKey(Schema.Boolean),
|
||||
timestampFormat: Schema.optionalKey(TimestampFormat),
|
||||
wordWrap: Schema.optionalKey(Schema.Boolean),
|
||||
});
|
||||
|
||||