Skip to content

feat(config,tui): expose system_prompt + fix VSCode keyboard layout (#55)#189

Open
quangdang46 wants to merge 1 commit into
masterfrom
feat/system-prompt-config-and-vscode-fix
Open

feat(config,tui): expose system_prompt + fix VSCode keyboard layout (#55)#189
quangdang46 wants to merge 1 commit into
masterfrom
feat/system-prompt-config-and-vscode-fix

Conversation

@quangdang46
Copy link
Copy Markdown
Owner

What

Two unrelated quality-of-life fixes upstream PR #55 bundled together:

1. Config — provider.system_prompt = Option<String>

Add a new system_prompt field on ProviderConfig so users can pin a custom default system prompt in ~/.jcode/config.toml (or a project-local config). When set, every new agent session is initialized with this string as system_prompt_override.

2. TUI — disable keyboard enhancement on VSCode-family terminals

Crossterm's keyboard enhancement reconstructs shifted characters using a hardcoded US layout. Non-US keyboards (e.g. Finnish Shift+7 = /) end up rendering as the wrong character (&) inside the VSCode integrated terminal because xterm.js has already done the layout translation upstream.

This addresses issue #55: #55

Changes

  • crates/jcode-config-types/src/lib.rs: add system_prompt: Option<String> to ProviderConfig, plus default None.
  • src/agent.rs: Agent::new initializes system_prompt_override from the new config field instead of always None.
  • src/perf.rs: add SystemProfile::is_vscode_terminal(). In tui_policy_for, force enable_keyboard_enhancement = false when host is VSCode (covers VSCode, VSCodium, Cursor, Windsurf integrated terminals — they all identify as "vscode" via TERM_PROGRAM).
  • src/perf.rs (tests): test_tui_policy_disables_keyboard_enhancement_on_vscode_terminal asserts the policy flips for a vscode-typed SystemProfile and that unrelated knobs are not globally crippled.

Tests

$ cargo test -p jcode --lib perf::tests::
test result: ok. 16 passed; 0 failed

Notes

Ports upstream PR 1jehuang#55.

Two unrelated quality-of-life fixes upstream PR #55 bundled together:

1. **Config: provider.system_prompt = Option<String>**
   - Add a new `system_prompt` field on ProviderConfig (in
     crates/jcode-config-types) so users can pin a custom default
     system prompt in ~/.jcode/config.toml or a project-local config.
   - In Agent::new, initialize `system_prompt_override` from
     `crate::config::config().provider.system_prompt.clone()` instead
     of unconditionally `None`. Existing /system overrides still take
     precedence within a session.

2. **TUI: disable keyboard enhancement on VSCode-family terminals**
   - Add SystemProfile::is_vscode_terminal() returning true when the
     detected terminal is "vscode" (covers VSCode, VSCodium, Cursor,
     Windsurf integrated terminals — they all identify as "vscode"
     via TERM_PROGRAM).
   - In tui_policy_for(), force enable_keyboard_enhancement = false
     when the host is VSCode. Crossterm's enhancement layer
     reconstructs shifted characters using a hardcoded US layout, so
     non-US layouts (e.g. Finnish Shift+7 = '/' was rendered as '&')
     were broken inside the VSCode integrated terminal.

Test `test_tui_policy_disables_keyboard_enhancement_on_vscode_terminal`
asserts the policy flips for a vscode-typed SystemProfile and that
unrelated knobs (enable_focus_change) are not globally crippled.

Ports upstream PR 1jehuang#55.
Closes #55
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.

1 participant