Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.simiacryptus.cognotik.plan.AbstractTask.TaskState
import com.simiacryptus.cognotik.plan.OrchestrationConfig
import com.simiacryptus.cognotik.plan.tools.file.IllustrateDocumentTask
import com.simiacryptus.cognotik.platform.ApplicationServices
import com.simiacryptus.cognotik.platform.ApplicationServices.fileApplicationServices
import com.simiacryptus.cognotik.platform.Session
import com.simiacryptus.cognotik.platform.file.DataStorage
import com.simiacryptus.cognotik.platform.file.UserSettingsManager
Expand Down Expand Up @@ -50,7 +51,7 @@ class IllustrateDocumentAction : BaseAction() {
return fileName.endsWith(".md") || fileName.endsWith(".html")
}

override fun handle(e: AnActionEvent) {
override fun handle(e: AnActionEvent) {
val root = getProjectRoot(e) ?: return
val selectedFile = e.getSelectedFile() ?: return

Expand All @@ -63,8 +64,11 @@ class IllustrateDocumentAction : BaseAction() {
val taskConfig = dialog.getTaskConfig()
val orchestrationConfig = dialog.getOrchestrationConfig()

val session = Session.newGlobalID()
DataStorage.sessionPaths[session] = root

UITools.runAsync(e.project, "Initializing Document Illustration Task", true) { progress ->
initializeTask(progress, orchestrationConfig, taskConfig, root)
initializeTask(progress, orchestrationConfig, taskConfig, session)
}
} catch (ex: Exception) {
log.error("Failed to initialize document illustration task", ex)
Expand All @@ -77,26 +81,22 @@ class IllustrateDocumentAction : BaseAction() {
progress: ProgressIndicator,
orchestrationConfig: OrchestrationConfig,
taskConfig: IllustrateDocumentTask.IllustrateDocumentTaskExecutionConfigData,
root: File
session: Session
) {
progress.text = "Setting up session..."
val session = Session.newGlobalID()

DataStorage.sessionPaths[session] = root

progress.text = "Starting server..."
setupTaskSession(session, orchestrationConfig, taskConfig)

Thread {
progress.text = "Opening browser..."
try {
Thread.sleep(500)
try {
val uri = CognotikAppServer.getServer().server.uri.resolve("/#$session")
log.info("Opening browser to $uri")
browse(uri)
} catch (e: Throwable) {
log.warn("Error opening browser", e)
}
}.start()
val uri = CognotikAppServer.getServer().server.uri.resolve("/#$session")
log.info("Opening browser to $uri")
browse(uri)
} catch (e: Throwable) {
log.warn("Error opening browser", e)
}
}

private fun setupTaskSession(
Expand Down Expand Up @@ -358,7 +358,7 @@ class IllustrateDocumentAction : BaseAction() {
imageChatModel = imageModel ?: AppSettingsState.instance.imageChatModel
?: throw IllegalStateException("No image model configured"),
temperature = temperatureSlider.value / 100.0,
autoFix = false,
autoFix = true,
workingDir = root.absolutePath,
shellCmd = listOf(
if (System.getProperty("os.name").lowercase().contains("win")) "powershell" else "bash"
Expand All @@ -367,11 +367,9 @@ class IllustrateDocumentAction : BaseAction() {
}

private fun getVisibleModels() =
ApplicationServices.fileApplicationServices().userSettingsManager.getUserSettings().apis.flatMap { apiData ->
fileApplicationServices().userSettingsManager.getUserSettings().apis.flatMap { apiData ->
apiData.provider?.getChatModels(apiData.key!!, apiData.baseUrl)?.filter { model ->
model.provider == apiData.provider &&
model.modelName?.isNotBlank() == true &&
PlanConfigDialog.isVisible(model)
model.provider == apiData.provider && model.modelName.isNotBlank() && PlanConfigDialog.isVisible(model)
} ?: listOf()
}.distinctBy { it.modelName }.sortedBy { "${it.provider?.name} - ${it.modelName}" }
}
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const ModalContent = styled.div`
}

border-radius: ${({theme}) => theme.sizing.borderRadius.md};
min-width: 300px;
min-width: 50vw;
max-width: 80vw;
max-height: 80vh;
min-height: 200px;
min-height: 50vh;
overflow: auto;
box-shadow: 0 4px 16px ${({theme}) => `${theme.colors.primary}20`};

Expand Down
2 changes: 1 addition & 1 deletion webapp/src/hooks/useModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const useModal = () => {
logger.debug('Creating iframe modal for fileIndex with URL:', iframeSrc);
// Use requestAnimationFrame to ensure the loading message is rendered before setting iframe
requestAnimationFrame(() => {
const iframeContent = `<iframe src="${iframeSrc}" style="width:100%; height:100%; border:none; min-height: 450px;" title="File Index"></iframe>`;
const iframeContent = `<iframe src="${iframeSrc}" style="width:90vw; height:80vh; border:none;" title="File Index"></iframe>`;
dispatch(setModalContent(iframeContent));
// highlightCode() is not called here as content is sandboxed in an iframe
});
Expand Down
Loading
Loading