MCPcopy Index your code
hub / github.com/OperationT00/T-Code / launch

Method launch

src/main/java/com/tcode/tui/TuiBootstrap.java:129–169  ·  view source on GitHub ↗

启动 TUI。 @param config 已加载的配置 @param llmClient LLM 客户端 @param reactAgent 复用 CLI 初始化出的 Agent 会话 @param hitlHandler 可切换 HITL 代理 @throws IOException 如果 Lanterna 初始化失败

(TCodeConfig config,
                              LlmClient llmClient,
                              Agent reactAgent,
                              SwitchableHitlHandler hitlHandler)

Source from the content-addressed store, hash-verified

127 * @throws IOException 如果 Lanterna 初始化失败
128 */
129 public static void launch(TCodeConfig config,
130 LlmClient llmClient,
131 Agent reactAgent,
132 SwitchableHitlHandler hitlHandler) throws IOException {
133 Objects.requireNonNull(config);
134 Objects.requireNonNull(llmClient);
135 Objects.requireNonNull(reactAgent);
136 Objects.requireNonNull(hitlHandler);
137
138 System.out.println(AnsiStyle.section("🖥️ 启动 TUI 界面..."));
139
140 try {
141 LanternaWindow window = new LanternaWindow(config, llmClient);
142 LanternaRenderer renderer = new LanternaRenderer(window);
143 reactAgent.setRenderer(renderer);
144 reactAgent.setHitlEnabledSupplier(hitlHandler::isEnabled);
145 reactAgent.getToolRegistry().setWriteFileObserver(
146 (path, ba) -> renderer.appendDiff(path, ba[0], ba[1]));
147 RendererHitlHandler rendererHitl = new RendererHitlHandler(renderer, hitlHandler.isEnabled());
148 hitlHandler.setDelegate(rendererHitl);
149 TuiSessionController controller = new TuiSessionController(
150 config,
151 llmClient,
152 reactAgent,
153 hitlHandler,
154 window.getRootPane().getCenterPane(),
155 window.getRootPane().getStatusPane(),
156 window::close,
157 () -> new TuiConfigPanel(config, window.getGui()).showConfigDialog(),
158 window::runOnGuiThread
159 );
160 window.getRootPane().setMessageHandler(controller::submit);
161 window.setCloseHook(controller::close);
162 window.start(); // 阻塞直到用户退出
163 System.out.println("\n👋 再见!");
164 } catch (Exception e) {
165 System.err.println("❌ TUI 启动失败,降级到 CLI 模式: " + e.getMessage());
166 e.printStackTrace();
167 throw new IOException("TUI 启动失败", e);
168 }
169 }
170}

Callers 1

mainMethod · 0.80

Calls 15

sectionMethod · 0.95
appendDiffMethod · 0.95
getRootPaneMethod · 0.95
getGuiMethod · 0.95
setCloseHookMethod · 0.95
startMethod · 0.95
setRendererMethod · 0.80
setWriteFileObserverMethod · 0.80
setDelegateMethod · 0.80
getCenterPaneMethod · 0.80
getStatusPaneMethod · 0.80

Tested by

no test coverage detected