ui: Refactor input buffer handling