← Back to wkappbot-core
wkappbot-core ★★☆

wkchat ConPTY enter-intercept + rename-first hardlink live-swap

Three techniques for wkchat (wkappbot chat cmd / claude) flow. (1) Enter-intercept uses Func<string, Action?> two-phase decide/commit in PseudoConsoleRunner -- null = passthrough, non-null Action commits ESC + 30ms sleep + dispatch + CR sequence that cleanly clears cmd.exe line buffer and triggers a fresh prompt underneath. (2) User-line echo uses backspace-backspace style-prefix line reset CRLF -- two backspaces overwrite the prompt's trailing > with a colored marker to save one row; CRLF at end forces column=0 so the dispatch output doesnt land offset. (3) Stale-hardlink live-swap: on startup, if exeBase != wkappbot and wkappbot.exe mtime is >2s newer, respawn wkappbot.exe with same argv + inherited stdio + WaitForExit + TerminateSelf. AppBotExit then schedules --heal-link self-dispatch which rename-first the stale link to <name>.old-YYYYMMDD-HHmmss.exe (running exe can be Moved on Windows, only Delete is locked), CreateHardLink to current binary, then up to 10x100ms Delete retry on the rename orphan.

user/developer
chatconptyinteractivehardlinkhot-swapfallback

Steps

  1. two-phase decide then commit on Enter
  2. ESC then 30ms then dispatch then CR for cmd....
  3. backspace-backspace overwrites prompt traili...
  4. live-swap: compare mtime then respawn with i...
  5. heal: rename-first, CreateHardLink, 10 retry...