GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(tui): put the diff side panel behind an experiment (#55456) · matglas/opencode@fe1717b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/tui
    • src
      • component
        • dialog-experiments.tsx
      • feature-plugins/system
        • diff-viewer.tsx
    • test
      • cli/tui
        • diff-viewer.test.tsx
      • session-panel.test.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/tui/src/component/dialog-experiments.tsx‎

Copy file name to clipboardExpand all lines: packages/tui/src/component/dialog-experiments.tsx
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ type Experiment = {
1313
// In-flight features anyone can opt into. Each entry is temporary: an
1414
// experiment either graduates (delete the entry, make the behavior
1515
// unconditional) or dies (delete the entry and the branch it gated).
16-
export const experiments: Experiment[] = []
16+
export const experiments: Experiment[] = [
17+
{
18+
id: "diff-panel",
19+
title: "Diff side panel",
20+
description: "Open /diff in a panel beside the session instead of full screen",
21+
},
22+
]
1723

1824
export function DialogExperiments() {
1925
const config = useConfig()
Collapse file

‎packages/tui/src/feature-plugins/system/diff-viewer.tsx‎

Copy file name to clipboardExpand all lines: packages/tui/src/feature-plugins/system/diff-viewer.tsx
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,9 @@ export function DiffViewerContent(props: {
840840
id="diff-source-header"
841841
paddingLeft={2}
842842
paddingRight={2}
843-
paddingTop={1}
844-
paddingBottom={1}
845-
height={3}
843+
paddingTop={docked() ? 1 : 0}
844+
paddingBottom={docked() ? 1 : 0}
845+
height={docked() ? 3 : 1}
846846
flexShrink={0}
847847
flexDirection="row"
848848
gap={1}
@@ -1134,7 +1134,7 @@ export function DiffViewerContent(props: {
11341134
</box>
11351135
</Show>
11361136
<Show when={!showFileTree() && !docked()}>
1137-
<box position="absolute" top={1} right={0} width={1} height={1}>
1137+
<box position="absolute" top={0} right={0} width={1} height={1}>
11381138
<HelpShortcut compact />
11391139
</box>
11401140
</Show>
@@ -1276,6 +1276,7 @@ function DiffViewerHelpDialog(props: { context: Plugin.Context; single: boolean;
12761276
}
12771277

12781278
function Commands(props: { context: Plugin.Context }) {
1279+
const config = useConfig()
12791280
props.context.keymap.layer(() => ({
12801281
mode: "global",
12811282
commands: [
@@ -1293,7 +1294,7 @@ function Commands(props: { context: Plugin.Context }) {
12931294
props.context.ui.panel.close()
12941295
return
12951296
}
1296-
if (props.context.ui.panel.open(ROUTE)) return
1297+
if (config.data.experimental?.["diff-panel"] === true && props.context.ui.panel.open(ROUTE)) return
12971298
const returnRoute: Route =
12981299
route.type === "home"
12991300
? { type: "home" }
Collapse file

‎packages/tui/test/cli/tui/diff-viewer.test.tsx‎

Copy file name to clipboardExpand all lines: packages/tui/test/cli/tui/diff-viewer.test.tsx
+15-20Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,10 @@ test.each([50, 80, 160])(
322322
const header = viewer.app.renderer.root.findDescendantById("diff-source-header")!
323323
const source = viewer.app.renderer.root.findDescendantById("diff-source-switch")!
324324
const count = viewer.app.renderer.root.findDescendantById("diff-review-count")!
325-
// Without the file tree, the header has one row of padding above and below its title.
326-
const padded = width < 100
327-
expect(header.height).toBe(padded ? 3 : 1)
328-
const title = header.y + (padded ? 1 : 0)
329-
expect(source.y).toBe(title)
330-
expect(count.y).toBe(title)
331-
expect(viewer.app.captureCharFrame().split("\n")[title]).toMatch(/All · vs release\s+0\/1/)
325+
expect(header.height).toBe(1)
326+
expect(source.y).toBe(header.y)
327+
expect(count.y).toBe(header.y)
328+
expect(viewer.app.captureCharFrame().split("\n")[header.y]).toMatch(/All · vs release\s+0\/1/)
332329
expect(viewer.app.captureCharFrame()).not.toContain("reviewed")
333330
expect(viewer.vcsDiffInput()).toMatchObject({ base: "refs/remotes/origin/release" })
334331
await viewer.app.mockMouse.click(source.x, source.y)
@@ -348,7 +345,7 @@ test.each([50, 80, 160])(
348345
await viewer.app.waitForFrame((frame) => !frame.includes("Diff source"))
349346
viewer.commands.get("diff.mark_reviewed")!.run()
350347
await viewer.app.flush()
351-
expect(viewer.app.captureCharFrame().split("\n")[title]).toMatch(/All · vs release\s+1\/1/)
348+
expect(viewer.app.captureCharFrame().split("\n")[header.y]).toMatch(/All · vs release\s+1\/1/)
352349
await chooseSource(viewer, 2)
353350
await viewer.app.waitForFrame((frame) => frame.includes("Uncommitted · vs HEAD"))
354351
viewer.app.mockInput.pressKey("d")
@@ -373,20 +370,18 @@ test.each([50, 80, 100, 160])(
373370
try {
374371
const header = viewer.app.renderer.root.findDescendantById("diff-source-header")!
375372
const count = viewer.app.renderer.root.findDescendantById("diff-review-count")!
376-
const padded = width < 100
377-
const title = header.y + (padded ? 1 : 0)
378-
const row = viewer.app.captureCharFrame().split("\n")[title]
379-
expect(header.height).toBe(padded ? 3 : 1)
373+
const row = viewer.app.captureCharFrame().split("\n")[header.y]
374+
expect(header.height).toBe(1)
380375
expect(row).toContain("Committed · vs")
381376
expect(row).toContain("0/1")
382377
expect(row).not.toContain("release/very-long-comparison-branch-name-that-does-not-fit-in-the-header")
383-
expect(count.y).toBe(title)
378+
expect(count.y).toBe(header.y)
384379
expect(count.x + count.width).toBeLessThanOrEqual(header.x + header.width)
385380
const hint = viewer.app.renderer.root.findDescendantById("diff-help-shortcut")!
386381
if (width < 90) {
387-
expect(hint.y).toBe(title)
382+
expect(hint.y).toBe(header.y)
388383
expect(hint.x).toBeGreaterThan(count.x + count.width)
389-
expect(findScrollBox(viewer.app.renderer.root)!.viewport.y).toBeGreaterThan(header.y + header.height - 1)
384+
expect(findScrollBox(viewer.app.renderer.root)!.viewport.y).toBeGreaterThan(header.y)
390385
}
391386
} finally {
392387
viewer.app.renderer.destroy()
@@ -1042,7 +1037,7 @@ test.each([100, 160])("shared pane edges align headings and stay fixed at %i col
10421037
await viewer.app.flush()
10431038
expect(viewer.app.renderer.root.findDescendantById("diff-tree-top-edge")).toBeUndefined()
10441039
expect(viewer.app.renderer.root.findDescendantById("diff-patch-top-edge")).toBeDefined()
1045-
expect(viewer.app.captureCharFrame().split("\n")[title + 3]).toContain("file01.txt")
1040+
expect(viewer.app.captureCharFrame().split("\n")[title + 1]).toContain("file01.txt")
10461041
} finally {
10471042
viewer.app.renderer.destroy()
10481043
}
@@ -1167,9 +1162,9 @@ test("compact gutter help leaves the full patch viewport available when the side
11671162
await viewer.app.flush()
11681163
const scroll = findScrollBox(viewer.app.renderer.root)!
11691164
const hint = viewer.app.renderer.root.findDescendantById("diff-help-shortcut")!
1170-
expect(hint.y).toBe(1)
1165+
expect(hint.y).toBe(0)
11711166
expect(hint.x).toBe(159)
1172-
expect(scroll.viewport.y).toBe(4)
1167+
expect(scroll.viewport.y).toBe(2)
11731168
expect(scroll.viewport.y + scroll.viewport.height).toBe(24)
11741169
await viewer.app.mockMouse.click(hint.x, hint.y)
11751170
await viewer.app.waitForFrame((frame) => frame.includes("Diff shortcuts"))
@@ -1182,11 +1177,11 @@ test("compact gutter help leaves the full patch viewport available when the side
11821177
expect(viewer.app.renderer.root.findDescendantById("diff-help-shortcut")!.y).toBe(21)
11831178
viewer.app.resize(80, 24)
11841179
await viewer.app.flush()
1185-
expect(viewer.app.renderer.root.findDescendantById("diff-help-shortcut")!.y).toBe(1)
1180+
expect(viewer.app.renderer.root.findDescendantById("diff-help-shortcut")!.y).toBe(0)
11861181
expect(viewer.app.renderer.root.findDescendantById("diff-help-shortcut")!.x).toBe(79)
11871182
expect(scroll.viewport.y + scroll.viewport.height).toBe(24)
11881183
expect(viewer.app.captureCharFrame()).not.toContain("? help")
1189-
expect(viewer.app.captureCharFrame().split("\n")[1].at(-1)).toBe("?")
1184+
expect(viewer.app.captureCharFrame().split("\n")[0].at(-1)).toBe("?")
11901185
viewer.app.mockInput.pressKey("d")
11911186
await viewer.app.waitForFrame((frame) => frame.includes("Diff source"))
11921187
viewer.app.mockInput.pressEscape()
Collapse file

‎packages/tui/test/session-panel.test.tsx‎

Copy file name to clipboardExpand all lines: packages/tui/test/session-panel.test.tsx
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ import { createAppFixture } from "./fixture/app"
1313
import { directory, json } from "./fixture/tui-client"
1414
import { tmpdir } from "./fixture/fixture"
1515

16+
test("/diff opens the full-screen diff when the side panel experiment is off", async () => {
17+
await using state = await tmpdir()
18+
await using setup = await createSessionFixture(state.path, { panel: false })
19+
await ready(setup)
20+
await setup.mockInput.typeText("/diff")
21+
await setup.waitForFrame((frame) => frame.includes("Open diff viewer"))
22+
setup.mockInput.pressEnter()
23+
await setup.waitForFrame((frame) => frame.includes("file00.txt"), { maxPasses: 120 })
24+
expect(setup.renderer.root.findDescendantById("session-panel")).toBeUndefined()
25+
expect(setup.renderer.root.findDescendantById("diff-footer")).toBeUndefined()
26+
expect(setup.captureCharFrame()).not.toContain("Transcript item 11")
27+
setup.mockInput.pressKey("q")
28+
await setup.waitForFrame((frame) => frame.includes("Transcript item 11") && !frame.includes("file00.txt"))
29+
expect(setup.renderer.root.findDescendantById("session-panel")).toBeUndefined()
30+
})
31+
1632
test("/diff focuses the production session panel without sending typing to the prompt", async () => {
1733
await using state = await tmpdir()
1834
await using setup = await createSessionFixture(state.path)
@@ -458,6 +474,7 @@ async function createSessionFixture(
458474
keybinds?: Config.Info["keybinds"]
459475
permission?: boolean
460476
form?: boolean
477+
panel?: boolean
461478
} = {},
462479
) {
463480
// Drafts survive app disposal in memory, so each production app needs its own session identity.
@@ -512,6 +529,7 @@ async function createSessionFixture(
512529
session: { sidebar: "hide" },
513530
// Keep patch geometry stable while testing host presentation changes, not split/unified diff layout.
514531
diffs: { tree: false, view: "unified", ...input.diffs },
532+
experimental: { "diff-panel": input.panel ?? true },
515533
keybinds: { "diff.open": "f6", ...input.keybinds },
516534
},
517535
fetch: async (url, request) => {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.