Skip to content

Commit 4a008f8

Browse files
committed
fix: address review findings on the pi dock PR
Catch rejections from the Shift-Tab effort cycle, make latex script normalization linear, and use the fork package name in pi-tui README examples.
1 parent 94f4e62 commit 4a008f8

4 files changed

Lines changed: 33 additions & 4 deletions

File tree

‎apps/pythinker-code/src/tui/pythinker-tui.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,9 @@ export class PythinkerTUI {
12061206
// =========================================================================
12071207

12081208
cycleThinkingEffort(): void {
1209-
void cycleThinkingEffort(this);
1209+
void cycleThinkingEffort(this).catch((error: unknown) => {
1210+
this.showError(`Failed to cycle thinking effort: ${formatErrorMessage(error)}`);
1211+
});
12101212
}
12111213

12121214
handleInputModeChange(mode: 'prompt' | 'bash'): void {

‎apps/pythinker-code/test/tui/pythinker-tui-message-flow.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,30 @@ describe('PythinkerTUI message flow', () => {
15561556
expect(stripSgr(renderTranscript(driver))).not.toContain('Thinking set to');
15571557
});
15581558

1559+
it('shows an error instead of an unhandled rejection when the Shift-Tab effort cycle fails', async () => {
1560+
const session = makeSession();
1561+
const startupInput: PythinkerTUIStartupInput = {
1562+
...makeStartupInput(),
1563+
cliOptions: { ...makeStartupInput().cliOptions, model: 'k2' },
1564+
};
1565+
const { driver } = await makeDriver(
1566+
session,
1567+
{ getConfig: vi.fn(async () => thinkingModelsConfig()) },
1568+
startupInput,
1569+
);
1570+
expect(driver.session).toBeUndefined();
1571+
vi.spyOn(driver, 'waitForLazyCreation').mockRejectedValueOnce(new Error('create failed'));
1572+
1573+
driver.state.editor.onShiftTab?.();
1574+
1575+
await vi.waitFor(() => {
1576+
expect(stripSgr(renderTranscript(driver))).toContain(
1577+
'Failed to cycle thinking effort: create failed',
1578+
);
1579+
});
1580+
expect(driver.state.appState.thinkingEffort).toBe('high');
1581+
});
1582+
15591583
it('blocks an effort switch once the waited-out first prompt starts a turn (v2 engine)', async () => {
15601584
const lazySession = makeSession({ id: 'ses-lazy' });
15611585
const startupInput: PythinkerTUIStartupInput = {

‎packages/pi-tui/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ import {
8181
parseColor,
8282
rgbColor,
8383
styleText,
84-
} from "@earendil-works/pi-tui";
84+
} from "@pymodel/pi-tui";
8585

8686
const accent = parseColor("oklch(70% 0.12 220)");
8787
const background = parseColor("#20242a");
@@ -117,7 +117,7 @@ import {
117117
ScrollView,
118118
Text,
119119
VStack,
120-
} from "@earendil-works/pi-tui";
120+
} from "@pymodel/pi-tui";
121121

122122
const transcript = new Container();
123123
transcript.addChild(new Text("History"));

‎packages/pi-tui/src/latex.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,10 @@ function replaceCharacters(value: string, replacements: Readonly<Record<string,
612612
}
613613

614614
function normalizeScriptValue(value: string): string {
615-
return value.trim().replace(/\s*([=+-])\s*/g, "$1");
615+
return value
616+
.split(/([=+-])/)
617+
.map((part) => part.trim())
618+
.join("");
616619
}
617620

618621
function formatUnicodeScript(value: string, kind: "sub" | "sup"): string | undefined {

0 commit comments

Comments
 (0)