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: catch empty tests reponse by britter · Pull Request #10 · testlens-app/cli

fix: catch empty tests reponse #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
britter merged 3 commits into main from issues/4
Oct 2, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix: catch empty tests reponse #10

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
2959a77
fix: catch empty tests reponse
britter Oct 2, 2026
d69a1ef
refactor: show no tests message as a modal dialog on top
britter Oct 2, 2026
830f3d1
docs: fix typos
britter Oct 2, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

7 changes: 6 additions & 1 deletion 7 build.gradle.kts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ application {
mainModule = "app.testlens.cli"
mainClass = "app.testlens.cli.Testlens"
applicationName = "testlens"
applicationDefaultJvmArgs = listOf("--enable-native-access=dev.tamboui.panama.backend")
// tamboui 0.5.0 DialogElement uses dev.tamboui.widgets.Clear, which the widgets module does not export to toolkit
applicationDefaultJvmArgs =
listOf(
"--enable-native-access=dev.tamboui.panama.backend",
"--add-exports=dev.tamboui.widgets/dev.tamboui.widgets=dev.tamboui.toolkit",
)
}

tasks.test {
Expand Down
33 changes: 33 additions & 0 deletions 33 docs/debugging.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Debugging the TUI

## Why the IntelliJ run dialog doesn't work

Starting the program from the IntelliJ run dialog forces `--mode=cli`, because
Gradle executes `java` without a TTY. The TUI needs a terminal, so bugs
cannot be reproduced that way. Instead, start the app in a real terminal with a
debugger agent attached, and connect IntelliJ to it.

## How to debug

Build the distribution, then start the launcher with the JDWP agent:

```sh
./gradlew installDist

JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005" \
build/install/testlens/bin/testlens pr <num> --repo <org>/<repo> --token $(gh auth token)
```

- suspend=y halts the JVM before main runs, so you can attach and set
breakpoints before anything executes.
- The JVM listens on port 5005.

Then in IntelliJ: Run → Attach to Process (or a Remote JVM Debug run
configuration pointing at localhost:5005), and debug the TUI as usual.

## Moving from debugging to testing

It's best to try to use debugging only to capture the response from the server that caused
the failure if possible. Once the shape of the problematic response is known, it should be
added as a new test case in `app.testlens.cli.tui`. Using tests, it's possible to debug
the TUI code.
12 changes: 8 additions & 4 deletions 12 src/main/java/app/testlens/cli/tui/PrDetailsController.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ void onSelectedExecution(Consumer<Execution> onSelectedExecution) {
updateDetailsArea();
}

@Nullable
ExecutedTest selectedTest() {
return requireNonNull(selectedTest);
return selectedTest;
}

int selectedExecutionIndex() {
Expand All @@ -53,7 +54,7 @@ boolean isFocused() {
}

Execution selectedExecution() {
return selectedTest().getExecutions().get(selectedExecutionIndex());
return requireNonNull(selectedTest).getExecutions().get(selectedExecutionIndex());
}

void selectTest(ExecutedTest test) {
Expand All @@ -63,11 +64,14 @@ void selectTest(ExecutedTest test) {
}

EventResult handleKey(KeyEvent event) {
if (selectedTest == null) {
return keyHandler.apply(event).isHandled() ? EventResult.HANDLED : EventResult.UNHANDLED;
}
if (keyHandler.apply(event).isHandled()) {
return EventResult.HANDLED;
}
// handled regardless of focus, so executions can be switched while browsing tests
var executionCount = selectedTest().getExecutions().size();
var executionCount = requireNonNull(selectedTest).getExecutions().size();
if (event.isLeft()) {
var previousExecution = selectedExecutionIndex();
tabsState.select(Math.max(0, previousExecution - 1));
Expand All @@ -88,7 +92,7 @@ EventResult handleKey(KeyEvent event) {
}

private void updateDetailsArea() {
if (onSelectedExecution != null) {
if (onSelectedExecution != null && selectedTest != null) {
onSelectedExecution.accept(selectedExecution());
}
}
Expand Down
3 changes: 3 additions & 0 deletions 3 src/main/java/app/testlens/cli/tui/PrDetailsView.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ final class PrDetailsView {

Element render() {
var test = controller.selectedTest();
if (test == null) {
return panel(detailsArea.fill()).rounded().borderColor(Color.DARK_GRAY).fill();
}
var executionIndex = controller.selectedExecutionIndex();
var executions = test.getExecutions();

Expand Down
3 changes: 3 additions & 0 deletions 3 src/main/java/app/testlens/cli/tui/PrTestsTableController.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ void selectTest(int index) {
}

EventResult handleKey(KeyEvent event) {
if (tests.isEmpty()) {
return keyHandler.apply(event).isHandled() ? EventResult.HANDLED : EventResult.UNHANDLED;
}
if (keyHandler.apply(event).isHandled()) {
return EventResult.HANDLED;
}
Expand Down
6 changes: 3 additions & 3 deletions 6 src/main/java/app/testlens/cli/tui/PrTestsTableView.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ final class PrTestsTableView {
Element render() {
table.borderColor(controller.isFocused() ? Color.CYAN : Color.DARK_GRAY);
var tests = controller.tests();
return testTableWithScrollbar(
Constraint.length(Math.min(tests.size(), MAX_VISIBLE_TESTS) + TABLE_CHROME_HEIGHT)
);
// reserve space for a full table even when empty, so the popup has a natural backdrop
var rowCount = tests.isEmpty() ? MAX_VISIBLE_TESTS : tests.size();
return testTableWithScrollbar(Constraint.length(Math.min(rowCount, MAX_VISIBLE_TESTS) + TABLE_CHROME_HEIGHT));
}

private Element testTableWithScrollbar(Constraint constraint) {
Expand Down
11 changes: 11 additions & 0 deletions 11 src/main/java/app/testlens/cli/tui/PrTui.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@
import app.testlens.cli.client.model.PullRequestResponse;
import app.testlens.cli.client.model.PullRequestTestsResponse;
import dev.tamboui.toolkit.app.ToolkitRunner;
import dev.tamboui.toolkit.event.EventResult;
import dev.tamboui.tui.event.KeyEvent;

public final class PrTui {

public static void run(PullRequestResponse prResponse, PullRequestTestsResponse testsResponse) throws Exception {
try (var runner = ToolkitRunner.create()) {
var controller = new PrTuiController(prResponse, testsResponse, runner.focusManager());
var view = new PrTuiView(controller);
// the modal "no tests" dialog consumes all keys before unfocused-element routing,
// so quit has to be handled globally, ahead of the dialog
runner.eventRouter().addGlobalHandler(event -> {
if (event instanceof KeyEvent keyEvent && keyEvent.isQuit()) {
runner.quit();
return EventResult.HANDLED;
}
return EventResult.UNHANDLED;
});
runner.run(view::render);
}
}
Expand Down
15 changes: 11 additions & 4 deletions 15 src/main/java/app/testlens/cli/tui/PrTuiView.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// SPDX-License-Identifier: Apache-2.0
package app.testlens.cli.tui;

import static dev.tamboui.style.Color.YELLOW;
import static dev.tamboui.toolkit.Toolkit.column;
import static dev.tamboui.toolkit.Toolkit.dialog;
import static dev.tamboui.toolkit.Toolkit.stack;
import static dev.tamboui.toolkit.Toolkit.text;

import dev.tamboui.toolkit.element.Element;
Expand All @@ -24,10 +27,14 @@ final class PrTuiView {
}

Element render() {
if (!controller.hasTests()) {
return column(header.render(), text("No failed or flaky tests.").fill());
var content = column(header.render(), testTable.render(), details.render(), footer.render());
if (controller.hasTests()) {
return content;
}
return column(header.render(), testTable.render(), details.render(), footer.render());
var message = "No failing tests detected on pull request #" + controller.prResponse().getNumber();
return stack(
content,
dialog(text(message)).rounded().borderColor(YELLOW).width(message.length() + 4)
);
}

}
86 changes: 59 additions & 27 deletions 86 src/test/java/app/testlens/cli/tui/PrTuiTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,65 @@ void abbreviates_test_names_keeping_the_outermost_segment() {
assertThat(PrTuiUtils.abbreviatedTestName(List.of("JUnit Jupiter", "FooTests"), 5)).isEqualTo("FooT…");
}

@Test
void colors_execution_tabs_by_outcome() {
var controller = new PrTuiController(
new PullRequestResponse().number(42).title("Some PR"),
new PullRequestTestsResponse().sha("SHA")
.addTestsItem(
executedTest(
"foo()",
execution(OutcomeEnum.SUCCESSFUL).htmlUrl(JOB_URL),
execution(OutcomeEnum.FAILED).htmlUrl(JOB_URL)
)
),
new FocusManager()
);
var view = new PrTuiView(controller);
var buffer = renderBuffer(view, 120);
var screen = render(view).lines().toList();
var row = screen.stream().filter(line -> line.contains("#1 SUCCESSFUL")).findFirst().orElseThrow();
assertThat(row).startsWith("╭ #1 SUCCESSFUL ─ #2 FAILED");
var y = screen.indexOf(row);
assertThat(buffer.get(row.indexOf("#1"), y).style().fg()).contains(Color.GREEN);
assertThat(buffer.get(row.indexOf("#1") - 1, y).style().fg()).contains(Color.GREEN);
assertThat(buffer.get(row.indexOf("#2"), y).style().fg()).contains(Color.RED);
var selectedPadding = buffer.get(row.indexOf("#2") - 1, y).style();
assertThat(selectedPadding.fg()).contains(Color.RED);
assertThat(selectedPadding.effectiveModifiers()).contains(Modifier.REVERSED);
}

@Test
void doesnt_crash_for_PRs_without_tests() {
var controller = new PrTuiController(
new PullRequestResponse().number(3).title("PR without Tests"),
new PullRequestTestsResponse().sha("SHA"),
new FocusManager()
);
var view = new PrTuiView(controller);

assertThat(render(view)).contains("No failing tests detected on pull request #3");
}

@Test
void keys_are_handled_without_crashing_for_PRs_without_tests() {
var focusManager = new FocusManager();
var controller = new PrTuiController(
new PullRequestResponse().number(3).title("PR without Tests"),
new PullRequestTestsResponse().sha("SHA"),
focusManager
);
var view = new PrTuiView(controller);

assertThat(controller.testTableController().handleKey(new KeyEvent(KeyCode.DOWN, KeyModifiers.NONE, 0)))
.isEqualTo(EventResult.UNHANDLED);
assertThat(controller.detailsController().handleKey(new KeyEvent(KeyCode.RIGHT, KeyModifiers.NONE, 0)))
.isEqualTo(EventResult.UNHANDLED);

focusManager.setFocus(PrDetailsController.VIEW_ID);
assertThat(render(view)).contains("No failing tests detected on pull request #3");
}

private static Execution execution(OutcomeEnum outcome) {
return new Execution().outcome(outcome).startTime(START_TIME).durationMillis(1500L);
}
Expand Down Expand Up @@ -256,31 +315,4 @@ private static Buffer renderFrame(
return renderBuffer(view, width, context);
}

@Test
void colors_execution_tabs_by_outcome() {
var controller = new PrTuiController(
new PullRequestResponse().number(42).title("Some PR"),
new PullRequestTestsResponse().sha("SHA")
.addTestsItem(
executedTest(
"foo()",
execution(OutcomeEnum.SUCCESSFUL).htmlUrl(JOB_URL),
execution(OutcomeEnum.FAILED).htmlUrl(JOB_URL)
)
),
new FocusManager()
);
var view = new PrTuiView(controller);
var buffer = renderBuffer(view, 120);
var screen = render(view).lines().toList();
var row = screen.stream().filter(line -> line.contains("#1 SUCCESSFUL")).findFirst().orElseThrow();
assertThat(row).startsWith("╭ #1 SUCCESSFUL ─ #2 FAILED");
var y = screen.indexOf(row);
assertThat(buffer.get(row.indexOf("#1"), y).style().fg()).contains(Color.GREEN);
assertThat(buffer.get(row.indexOf("#1") - 1, y).style().fg()).contains(Color.GREEN);
assertThat(buffer.get(row.indexOf("#2"), y).style().fg()).contains(Color.RED);
var selectedPadding = buffer.get(row.indexOf("#2") - 1, y).style();
assertThat(selectedPadding.fg()).contains(Color.RED);
assertThat(selectedPadding.effectiveModifiers()).contains(Modifier.REVERSED);
}
}
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — 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.