- Changed `addedCount > tailAppendCount` to `addedCount !== tailAppendCount` to also catch over-counted tails that scroll an extra row and duplicate the viewport-top line into scrollback.
- Restricted `appendFrom` in the offscreen-edit path to clean tail boundaries only; marks scrollback dirty otherwise.
- Added regression test covering the duplicate-line scenario with an offscreen edit plus mis-located tail append.