fix(input): fiabilise la livraison de délégation et journalise le submit
Durcit le portail d'écriture de délégation et son acheminement bout-en-bout (commande Tauri → orchestrateur → file d'entrée infrastructure → portail frontend), avec une journalisation du submit pour diagnostiquer les cas où la délégation n'était pas remise. Couvre le portail d'écriture côté front (useWritePortal) avec ses tests. QA : checks application/front/infrastructure/app-tauri verts. Les tests loopback socket Unix réels ne sont pas exécutables en sandbox (UnixListener::bind → PermissionDenied) ; alternatives avec skips vertes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -64,11 +64,13 @@ export function makeTerminalHandle(
|
||||
return {
|
||||
sessionId,
|
||||
write(data: Uint8Array): Promise<void> {
|
||||
const run = chain.then(() =>
|
||||
invoke<void>("write_terminal", {
|
||||
const run = chain.then(async () => {
|
||||
logTerminalWrite("start", sessionId, data);
|
||||
await invoke<void>("write_terminal", {
|
||||
request: { sessionId, data: Array.from(data) },
|
||||
}),
|
||||
);
|
||||
});
|
||||
logTerminalWrite("ok", sessionId, data);
|
||||
});
|
||||
// Keep the chain alive even if this write rejects: the next write must
|
||||
// still run. Swallow the error on the *chain* copy only — `run` keeps the
|
||||
// rejection so the caller can observe it.
|
||||
@ -91,6 +93,35 @@ export function makeTerminalHandle(
|
||||
};
|
||||
}
|
||||
|
||||
function logTerminalWrite(phase: "start" | "ok", sessionId: string, data: Uint8Array): void {
|
||||
if (data.length === 1 && data[0] >= 0x20 && data[0] !== 0x7f) return;
|
||||
console.info("[terminal-write]", phase, {
|
||||
sessionId,
|
||||
bytes: data.length,
|
||||
control: describeBytes(data),
|
||||
});
|
||||
}
|
||||
|
||||
function describeBytes(data: Uint8Array): string {
|
||||
if (data.length === 0) return "<empty>";
|
||||
if (data.length > 16) return "<bulk>";
|
||||
return Array.from(data)
|
||||
.map((byte) => {
|
||||
switch (byte) {
|
||||
case 0x0d:
|
||||
return "\\r";
|
||||
case 0x0a:
|
||||
return "\\n";
|
||||
case 0x7f:
|
||||
return "\\x7f";
|
||||
default:
|
||||
if (byte < 0x20) return `\\x${byte.toString(16).padStart(2, "0")}`;
|
||||
return String.fromCharCode(byte);
|
||||
}
|
||||
})
|
||||
.join("");
|
||||
}
|
||||
|
||||
export class TauriTerminalGateway implements TerminalGateway {
|
||||
async openTerminal(
|
||||
options: OpenTerminalOptions,
|
||||
|
||||
Reference in New Issue
Block a user