f6a552d855
vue-tui hid the terminal cursor EAGERLY at mount regardless of content, so an interactive app whose root renders nothing emitted `\x1b[?25l` and hid the user's cursor. Ink hides LAZILY (log-update, on the first render that writes) and skips log-update entirely for an empty frame, so an empty app emits zero cursor escapes. Remove the eager mount-time hide and rely on log-update's lazy hide. That alone was insufficient: an empty frame becomes "\n", and the old commit gate `willRender(outputToRender) || isCursorDirty()` was true for "\n", so log-update (and its lazy hide) was still reached. Align the outer commit gate to Ink's exact condition (ink.tsx:1094) `output !== frameState.lastOutput || isCursorDirty()`, comparing the RAW frame; on an empty first commit both are "" so log-update is never reached. `willRender` is retained only for the inner BSU/ESU wrap gate. Verified via PTY: empty app = 0 hides; non-empty = 1 lazy hide; useCursor = hide-then-show within one render (SHOW last, cursor positioned). alt-screen, screen-reader, and non-TTY cursor behavior unchanged. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import process from "node:process";
|
|
import { Box, Text, createApp, useApp, useCursor } from "@vue-tui/runtime";
|
|
import { defineComponent, h, onMounted } from "vue";
|
|
|
|
// A useCursor app. log-update hides-then-shows the cursor within a single
|
|
// render(): it lazily hides at the top, then emits the cursor SHOW + cursorTo
|
|
// suffix for the active position. So the LAST cursor visibility change on the
|
|
// first frame must be a SHOW (cursor visible at the requested position), with no
|
|
// trailing re-hide — exactly Ink's ordering, and unchanged by removing the eager
|
|
// mount-time hide.
|
|
const App = defineComponent(() => {
|
|
const { exit } = useApp();
|
|
const { setCursorPosition } = useCursor();
|
|
onMounted(() => {
|
|
process.stdout.write("__READY__");
|
|
setTimeout(() => exit(), 100);
|
|
});
|
|
return () => {
|
|
setCursorPosition({ x: 2, y: 0 });
|
|
return h(Box, null, () => h(Text, null, () => "> "));
|
|
};
|
|
});
|
|
|
|
const app = createApp(App);
|
|
app.mount({ rawMode: "auto", exitOnCtrlC: false });
|
|
await app.waitUntilExit();
|
|
console.log("exited");
|