diff --git a/api/config.py b/api/config.py index e99f69bb..8c2c71e3 100644 --- a/api/config.py +++ b/api/config.py @@ -7343,6 +7343,8 @@ _SETTINGS_DEFAULTS = { "font_size": "default", # small | default | large | xlarge "session_jump_buttons": False, # show Start/End transcript jump pills "render_user_markdown": False, # opt-in: render full markdown in user messages (#3870) + "structured_code_default_view": "auto", # JSON/YAML fenced-block default render: auto | on | off (#484 follow-up). auto => Tree when line count >= structured_code_auto_tree_lines, else Raw. + "structured_code_auto_tree_lines": 10, # in 'auto' mode, minimum line count to default a JSON/YAML block to Tree view (preserves the original hardcoded >=10 behavior) "session_endless_scroll": False, # auto-load older transcript pages while scrolling upward "chat_activity_display_mode": "compact_worklog", # compact_worklog | transparent_stream "auto_scroll_follow": True, # follow new output to the bottom while streaming (Codex/Claude-Code-style sticky bottom); the user scrolling up unpins and is respected @@ -7551,6 +7553,7 @@ _SETTINGS_ENUM_VALUES = { "auto_title_refresh_every": {"0", "5", "10", "20"}, "busy_input_mode": {"queue", "interrupt", "steer"}, "chat_activity_display_mode": {"compact_worklog", "transparent_stream"}, + "structured_code_default_view": {"auto", "on", "off"}, } _SETTINGS_INT_RANGES = { "pinned_sessions_limit": (1, 99), @@ -7559,6 +7562,7 @@ _SETTINGS_INT_RANGES = { "inflight_state_max_tool_calls": (1, 200), "inflight_state_max_string_chars": (1000, 500000), "inflight_state_max_json_chars": (100000, 4000000), + "structured_code_auto_tree_lines": (1, 1000), } _SETTINGS_BOOL_KEYS = { "onboarding_completed", diff --git a/static/boot.js b/static/boot.js index a04cd195..c80d319e 100644 --- a/static/boot.js +++ b/static/boot.js @@ -2158,6 +2158,11 @@ window._applyTitlebarProfileVisibility=_applyTitlebarProfileVisibility; } window._sessionJumpButtonsEnabled=!!s.session_jump_buttons; window._renderUserMarkdown=!!s.render_user_markdown; + // JSON/YAML structured code-block default view (#484): auto | on | off, + // plus the 'auto'-mode line threshold (sanitized int 1..1000, fallback 10). + window._structuredCodeDefaultView=['on','off','auto'].includes(s.structured_code_default_view)?s.structured_code_default_view:'auto'; + const _sctLines=parseInt(s.structured_code_auto_tree_lines,10); + window._structuredCodeAutoTreeLines=(Number.isFinite(_sctLines)&&_sctLines>=1&&_sctLines<=1000)?_sctLines:10; // Reconcile appearance: prefer localStorage (what the user last saw) over // the server. If they diverge (e.g. a previous autosave POST failed), // push the localStorage values back to the server so settings.json stays @@ -2227,6 +2232,8 @@ window._applyTitlebarProfileVisibility=_applyTitlebarProfileVisibility; window._workspaceTodosTab=false; if(typeof _applyWorkspaceTodosTabVisibility==='function') _applyWorkspaceTodosTabVisibility(); window._sessionJumpButtonsEnabled=false; + window._structuredCodeDefaultView='auto'; + window._structuredCodeAutoTreeLines=10; window._sidebarDensity='compact'; window._pinnedSessionsLimit=3; window._busyInputMode='queue'; diff --git a/static/i18n.js b/static/i18n.js index bbe6ec5d..316a170f 100644 --- a/static/i18n.js +++ b/static/i18n.js @@ -598,6 +598,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Open Worklog details automatically', settings_desc_worklog_details_expanded_default: 'When enabled, new Worklog details start expanded so tool, thinking, and progress cards are visible without an extra click. When off, Worklog details stay folded by default; per-turn manual collapse/expand choices still win.', settings_label_chat_activity_display_mode: 'Activity display', @@ -2171,6 +2177,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', // TODO: translate settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', // TODO: translate settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Open Worklog details automatically', settings_desc_worklog_details_expanded_default: 'When enabled, new Worklog details start expanded so tool, thinking, and progress cards are visible without an extra click. When off, Worklog details stay folded by default; per-turn manual collapse/expand choices still win.', settings_label_chat_activity_display_mode: 'Activity display', @@ -3735,6 +3747,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', // TODO: translate settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', // TODO: translate settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Worklog の詳細を自動的に開く', settings_desc_worklog_details_expanded_default: '有効にすると、新しい Worklog の詳細が展開された状態で始まり、ツール、Thinking、進捗カードをクリックなしで確認できます。無効の場合、Worklog の詳細はデフォルトで折りたたまれます。ターンごとの手動折りたたみ/展開は優先されます。', settings_label_chat_activity_display_mode: 'アクティビティ表示', @@ -6000,6 +6018,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', // TODO: translate settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', // TODO: translate settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Open Worklog details automatically', settings_desc_worklog_details_expanded_default: 'When enabled, new Worklog details start expanded so tool, thinking, and progress cards are visible without an extra click. When off, Worklog details stay folded by default; per-turn manual collapse/expand choices still win.', settings_label_chat_activity_display_mode: 'Activity display', @@ -7489,6 +7513,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', // TODO: translate settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', // TODO: translate settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Open Worklog details automatically', settings_desc_worklog_details_expanded_default: 'When enabled, new Worklog details start expanded so tool, thinking, and progress cards are visible without an extra click. When off, Worklog details stay folded by default; per-turn manual collapse/expand choices still win.', settings_label_chat_activity_display_mode: 'Activity display', @@ -8659,6 +8689,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', // TODO: translate settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', // TODO: translate settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Open Worklog details automatically', settings_desc_worklog_details_expanded_default: 'When enabled, new Worklog details start expanded so tool, thinking, and progress cards are visible without an extra click. When off, Worklog details stay folded by default; per-turn manual collapse/expand choices still win.', settings_label_chat_activity_display_mode: 'Activity display', @@ -10502,6 +10538,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', // TODO: translate settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', // TODO: translate settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Open Worklog details automatically', settings_desc_worklog_details_expanded_default: 'When enabled, new Worklog details start expanded so tool, thinking, and progress cards are visible without an extra click. When off, Worklog details stay folded by default; per-turn manual collapse/expand choices still win.', settings_label_chat_activity_display_mode: 'Activity display', @@ -11304,6 +11346,12 @@ const LOCALES = { settings_label_show_titlebar_profile: '在標題列顯示設定檔切換器', settings_desc_show_titlebar_profile: '啟用後,左上角的應用程式標題列會出現設定檔切換按鈕,讓你在任何分頁都能切換設定檔。預設關閉;無論此設定為何,輸入列底部一律保留設定檔切換器。', settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Open Worklog details automatically', settings_desc_worklog_details_expanded_default: 'When enabled, new Worklog details start expanded so tool, thinking, and progress cards are visible without an extra click. When off, Worklog details stay folded by default; per-turn manual collapse/expand choices still win.', settings_label_chat_activity_display_mode: 'Activity display', @@ -12764,6 +12812,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', // TODO: translate settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', // TODO: translate settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Open Worklog details automatically', settings_desc_worklog_details_expanded_default: 'When enabled, new Worklog details start expanded so tool, thinking, and progress cards are visible without an extra click. When off, Worklog details stay folded by default; per-turn manual collapse/expand choices still win.', settings_label_chat_activity_display_mode: 'Activity display', @@ -14230,6 +14284,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', // TODO: translate settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', // TODO: translate settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Open Worklog details automatically', settings_desc_worklog_details_expanded_default: 'When enabled, new Worklog details start expanded so tool, thinking, and progress cards are visible without an extra click. When off, Worklog details stay folded by default; per-turn manual collapse/expand choices still win.', settings_label_chat_activity_display_mode: 'Activity display', @@ -15718,6 +15778,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', // TODO: translate settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', // TODO: translate settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Open Worklog details automatically', settings_desc_worklog_details_expanded_default: 'When enabled, new Worklog details start expanded so tool, thinking, and progress cards are visible without an extra click. When off, Worklog details stay folded by default; per-turn manual collapse/expand choices still win.', settings_label_chat_activity_display_mode: 'Activity display', @@ -17300,6 +17366,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', // TODO: translate settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', // TODO: translate settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Open Worklog details automatically', settings_desc_worklog_details_expanded_default: 'When enabled, new Worklog details start expanded so tool, thinking, and progress cards are visible without an extra click. When off, Worklog details stay folded by default; per-turn manual collapse/expand choices still win.', settings_label_chat_activity_display_mode: 'Activity display', @@ -18878,6 +18950,12 @@ const LOCALES = { settings_label_show_titlebar_profile: 'Show profile switcher in titlebar', // TODO: translate settings_desc_show_titlebar_profile: 'When enabled, a profile switcher button appears in the top-left app titlebar so you can change profiles from any tab. Off by default; the composer footer always has a profile switcher regardless of this setting.', // TODO: translate settings_desc_render_user_markdown: 'When enabled, bold, italic, links, and other markdown in your own messages are rendered. Off by default; fenced code blocks and math always render regardless of this setting.', + settings_label_structured_code: 'JSON/YAML code blocks', + settings_option_structured_code_auto: 'Auto: Tree for long blocks', + settings_option_structured_code_on: 'Tree by default', + settings_option_structured_code_off: 'Raw by default', + settings_label_structured_code_auto_lines: 'Auto threshold lines', + settings_desc_structured_code: 'When Auto is selected, JSON/YAML blocks with at least this many lines open in Tree view. Tree always opens the structured viewer; Raw keeps the syntax-highlighted text. You can still switch Tree/Raw on each block.', settings_label_worklog_details_expanded_default: 'Otwieraj szczegóły Worklog automatycznie', settings_desc_worklog_details_expanded_default: 'Gdy ta opcja jest włączona, nowe szczegóły Worklog zaczynają rozwinięte, dzięki czemu karty narzędzi, Thinking i postępu są widoczne bez dodatkowego kliknięcia. Gdy jest wyłączona, szczegóły Worklog pozostają domyślnie zwinięte. Ręczne decyzje o zwinięciu/rozwinięciu w danej turze mają pierwszeństwo.', settings_label_chat_activity_display_mode: 'Activity display', diff --git a/static/index.html b/static/index.html index a213d508..c01e022f 100644 --- a/static/index.html +++ b/static/index.html @@ -1071,6 +1071,19 @@