@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
30 lines • 1.18 kB
JavaScript
const unobservedInput = new WeakMap();
/** Extension-supplied text updates the composer but is not terminal input. */
export function insertProgrammaticComposerInput(editor, data) {
const handleInput = unobservedInput.get(editor) ?? editor.handleInput.bind(editor);
handleInput(data);
}
/** Observe user edits, not setText calls that restore drafts during resume/reload. */
export function observeComposerActivity(editor, onActivity) {
const handleInput = editor.handleInput.bind(editor);
unobservedInput.set(editor, handleInput);
editor.handleInput = (data) => {
const previousText = editor.getText();
const onSubmit = editor.onSubmit;
let submitted = false;
editor.onSubmit = (...args) => {
submitted = true;
onSubmit?.(...args);
};
try {
handleInput(data);
// Submission clears the editor and is handled by prompt admission instead.
if (!submitted && editor.getText() !== previousText)
onActivity();
}
finally {
editor.onSubmit = onSubmit;
}
};
}
//# sourceMappingURL=composer-user-activity.js.map