refactor: drop mode from frontend types; react to settings changes
This commit is contained in:
@@ -64,7 +64,6 @@ function mockResponse(overrides: {
|
||||
}
|
||||
|
||||
const sampleRequest: OpenCodeRequest = {
|
||||
mode: 'edit',
|
||||
prompt: 'add type hints',
|
||||
context: {
|
||||
notebookPath: 'foo.ipynb',
|
||||
@@ -86,7 +85,6 @@ describe('callOpenCodeEdit', () => {
|
||||
it('POSTs to /opencode-bridge/edit with JSON body', async () => {
|
||||
const respBody = {
|
||||
ok: true,
|
||||
mode: 'edit',
|
||||
finalSource: 'def foo(x: int) -> int: return x',
|
||||
sessionId: 'sid',
|
||||
notebookPath: 'foo.ipynb',
|
||||
|
||||
+14
-10
@@ -49,17 +49,21 @@ const plugin: JupyterFrontEndPlugin<void> = {
|
||||
|
||||
// Load settings + push into the actions module.
|
||||
if (settingRegistry) {
|
||||
void settingRegistry
|
||||
.load(plugin.id)
|
||||
.then(settings => {
|
||||
const bridge = readOpenCodeSettings(settings.composite);
|
||||
setOpenCodeRuntime({
|
||||
settings: bridge,
|
||||
serverSettings: app.serviceManager.serverSettings
|
||||
});
|
||||
console.log('opencode_bridge settings loaded:', bridge);
|
||||
void settingRegistry
|
||||
.load(plugin.id)
|
||||
.then(settings => {
|
||||
const apply = () => {
|
||||
const bridge = readOpenCodeSettings(settings.composite);
|
||||
setOpenCodeRuntime({
|
||||
settings: bridge,
|
||||
serverSettings: app.serviceManager.serverSettings
|
||||
});
|
||||
console.log('opencode_bridge settings applied:', bridge);
|
||||
};
|
||||
apply();
|
||||
settings.changed.connect(apply);
|
||||
|
||||
void callOpenCodeProviders(app.serviceManager.serverSettings)
|
||||
void callOpenCodeProviders(app.serviceManager.serverSettings)
|
||||
.then(data => {
|
||||
const lines: string[] = [
|
||||
'[opencode_bridge] Available OpenCode providers:'
|
||||
|
||||
@@ -22,10 +22,7 @@ export interface CellContext {
|
||||
error: ErrorOutput | null;
|
||||
}
|
||||
|
||||
export type OpenCodeMode = 'optimize' | 'fix' | 'edit';
|
||||
|
||||
export interface OpenCodeRequest {
|
||||
mode: OpenCodeMode;
|
||||
prompt: string;
|
||||
context: CellContext;
|
||||
providerId?: string;
|
||||
@@ -34,7 +31,6 @@ export interface OpenCodeRequest {
|
||||
|
||||
export interface OpenCodeSuccess {
|
||||
ok: true;
|
||||
mode: OpenCodeMode;
|
||||
finalSource: string;
|
||||
sessionId: string;
|
||||
notebookPath: string;
|
||||
|
||||
Reference in New Issue
Block a user