Suggest a solution to the issue
- User
Suggest a solution to the issue
- Assistant
The issue described is that input in the TUI mode of the
modsapplication is truncated to 400 characters, regardless of themax-input-charssetting. This likely stems from the input handling logic in the TUI mode or an explicit hard-coded limit.Identifying the Issue
From the provided codebase, the primary handling for input in TUI mode resides in the
Modsstruct and its methods. Here's a breakdown of the relevant areas:-
Input Handling in TUI:
- The input is processed in the
completionInputstruct and related logic in theMods.Update()method. - The
Modsstruct usesremoveWhitespace()to sanitize input (m.Input) passed to it.
- The input is processed in the
-
Truncation or Limitation:
- The
max-input-charssetting (m.Config.MaxInputChars) is intended to cap input size. However, the issue indicates this limit isn't being respected, and instead, a hard-coded limit of 400 characters is being applied.
- The
-
Potential Limit in TUI Input:
- A manual review of the code doesn't directly reveal a hardcoded limit of 400 characters, but there could be hidden logic elsewhere (e.g., related to viewport size or input sanitization) that imposes this restriction.
Solution
To resolve the issue, we need to ensure the input length respects
max-input-charsand remove any unintended hard-coded limitations.
1. Fix Input Truncation in TUI
The truncation issue can be resolved by explicitly checking
max-input-charsin the relevant input handling logic. Update theMods.Update()method to enforce the correct maximum character limit based onm.Config.MaxInputChars.In
./repos/mods/mods.go, modify thecompletionInputhandling inMods.Update():gocase completionInput: if msg.content != "" { m.Input = removeWhitespace(msg.content) // Enforce max-input-chars limit if len(m.Input) > m.Config.MaxInputChars { m.Input = m.Input[:m.Config.MaxInputChars] } } if m.Input == "" && m.Config.Prefix == "" && m.Config.Show == "" && !m.Config.ShowLast { return m, m.quit } -
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.