Skip to content

Commit

Permalink
Merge pull request #83 from devoxx/issue-82
Browse files Browse the repository at this point in the history
Fix #82: Set max width for streaming editorPane
  • Loading branch information
stephanj authored May 28, 2024
2 parents c6c45ea + fd23ba6 commit 13222bd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "com.devoxx.genie"
version = "0.1.14"
version = "0.1.15"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.awt.*;
import java.util.concurrent.atomic.AtomicReference;

import static com.devoxx.genie.ui.util.DevoxxGenieFonts.SourceCodeProFontPlan14;
Expand All @@ -32,8 +33,14 @@ public ChatStreamingResponsePanel(@NotNull ChatMessageContext chatMessageContext
add(new ResponseHeaderPanel(chatMessageContext));
add(editorPane);

setMaxWidth();

parser = Parser.builder().build();
renderer = HtmlRenderer
renderer = createHTMLRenderer(chatMessageContext);
}

private static HtmlRenderer createHTMLRenderer(@NotNull ChatMessageContext chatMessageContext) {
return HtmlRenderer
.builder()
.nodeRendererFactory(context -> {
AtomicReference<CodeBlockNodeRenderer> codeBlockRenderer = new AtomicReference<>();
Expand All @@ -46,6 +53,12 @@ public ChatStreamingResponsePanel(@NotNull ChatMessageContext chatMessageContext
.build();
}

private void setMaxWidth() {
Dimension maximumSize = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
editorPane.setMaximumSize(maximumSize);
editorPane.setMinimumSize(new Dimension(editorPane.getPreferredSize().width, editorPane.getPreferredSize().height));
}

/**
* Insert token into document stream
* @param token the LLM string token
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
]]></description>

<change-notes><![CDATA[
<h2>v0.1.15</h2>
<UL>
<LI>Fix #82: Wrap text to new line for streaming output.</LI>
</UL>
<h2>v0.1.14</h2>
<UL>
<LI>Feat #78: Set chat memory size in Settings page.</LI>
Expand Down

0 comments on commit 13222bd

Please sign in to comment.