Skip to content

refactor: replace channel-based AsciiTransportServer with io.ReadWriteCloser ServerSession#82

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/refactor-asciitransport-interface
Draft

refactor: replace channel-based AsciiTransportServer with io.ReadWriteCloser ServerSession#82
Copilot wants to merge 3 commits intomasterfrom
copilot/refactor-asciitransport-interface

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 25, 2026

Remove channels from the pkg/asciitransport public server interface. The old AsciiTransportServer leaked implementation details via ResizeEvent() <-chan *ResizeEvent and InputEvent() <-chan *InputEvent.

New interface

type ServerSession interface {
    io.Reader      // reads client InputMsg data
    io.Writer      // writes OutputMsg data to client
    io.Closer
    NextResize() (*ResizeMsg, error)
}

Channels remain internal. The session behaves like a standard file/pipe.

Changes

  • pkg/asciitransport/server.go — Replace AsciiTransportServer with ServerSession; implement serverSession struct with Read/Write/Close/NextResize
  • pkg/asciitransport/event.go — Add type ResizeMsg = ResizeEvent
  • pkg/agent/server/plugin_terminalserver.go — Use io.Copy + NextResize() instead of channel reads and ApplyOpts(WithReader, WithWriter)
  • third_party/cmd/ameniicsav1/main.go — Same migration
  • pkg/asciitransport/server_test.go — Tests for Read, Write, NextResize, Close, and post-Close behavior

Consumer migration

Before:

server := asciitransport.Server(conn)
go func() {
    for {
        re := <-server.ResizeEvent()
        term.Resize(int(re.Width), int(re.Height))
    }
}()
server.ApplyOpts(asciitransport.WithReader(term), asciitransport.WithWriter(term))
<-server.Done()

After:

session := asciitransport.Server(conn)
go func() {
    for {
        re, err := session.NextResize()
        if err != nil { break }
        term.Resize(int(re.Width), int(re.Height))
    }
}()
go io.Copy(term, session)
go io.Copy(session, term)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 25, 2026 19:20
…er with ServerSession interface

Replace AsciiTransportServer (which exposed channels like ResizeEvent(),
InputEvent()) with a ServerSession interface implementing io.ReadWriteCloser
plus NextResize() method. This makes the server session usable like a local
file or pipe.

- Add ServerSession interface with io.Reader, io.Writer, io.Closer, NextResize()
- Add ResizeMsg type alias for ResizeEvent
- Implement serverSession struct wrapping AsciiTransport internals
- Update plugin_terminalserver.go to use new interface (direct io.Copy instead of WithReader/WithWriter opts)
- Update third_party/cmd/ameniicsav1 to use new interface
- Add unit tests for ServerSession

Co-authored-by: btwiuse <54848194+btwiuse@users.noreply.github.com>
Co-authored-by: btwiuse <54848194+btwiuse@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor pkg/asciitransport to remove channels from public interface refactor: replace channel-based AsciiTransportServer with io.ReadWriteCloser ServerSession Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants