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
21 changes: 11 additions & 10 deletions demo/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@

<script setup lang="ts">
import { ref, computed, onMounted } from "vue";
import { plugin } from "../src/vue";
import { plugin, executeMarkdown } from "../src/vue";
import { isMarkdownArgs } from "./markdownArgs";
import type { ToolResult, ToolSample, ToolPlugin } from "gui-chat-protocol/vue";

// Plugin configuration - cast to base ToolPlugin for generic demo usage
const currentPlugin = plugin as unknown as ToolPlugin;

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (22.x, windows-latest)

Do not use any type assertions

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (22.x, windows-latest)

Do not use any type assertions

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (24.x, ubuntu-latest)

Do not use any type assertions

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (24.x, ubuntu-latest)

Do not use any type assertions

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (24.x, macos-latest)

Do not use any type assertions

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (24.x, macos-latest)

Do not use any type assertions

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (22.x, ubuntu-latest)

Do not use any type assertions

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (22.x, ubuntu-latest)

Do not use any type assertions

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (24.x, windows-latest)

Do not use any type assertions

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (24.x, windows-latest)

Do not use any type assertions

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (22.x, macos-latest)

Do not use any type assertions

Check warning on line 75 in demo/App.vue

View workflow job for this annotation

GitHub Actions / lint_test (22.x, macos-latest)

Do not use any type assertions

// Computed properties from plugin
const pluginName = computed(() => currentPlugin.toolDefinition.name);
Expand All @@ -96,18 +97,18 @@
const loadSample = (sample: ToolSample) => {
jsonInput.value = JSON.stringify(sample.args, null, 2);
jsonError.value = "";
applyJson();
void applyJson();
};

const applyJson = () => {
// Runs the plugin's own execute, as a host does, so View gets the result shape it reads (data.markdown).
const applyJson = async () => {
try {
const data = JSON.parse(jsonInput.value);
result.value = {
toolName: toolName.value,
message: "Data applied",
title: data.title || "",
jsonData: data,
};
const args: unknown = JSON.parse(jsonInput.value);
if (!isMarkdownArgs(args)) {
jsonError.value = "JSON must have string fields: title, markdown";
return;
}
result.value = { ...(await executeMarkdown(null, args)), toolName: toolName.value };
jsonError.value = "";
lastSentMessage.value = "";
} catch (e) {
Expand Down
10 changes: 10 additions & 0 deletions demo/markdownArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { MarkdownArgs } from "../src/core/types";

const isRecord = (value: unknown): value is Record<string, unknown> =>
typeof value === "object" && value !== null && !Array.isArray(value);

export const isMarkdownArgs = (value: unknown): value is MarkdownArgs =>
isRecord(value) &&
typeof value.title === "string" &&
typeof value.markdown === "string" &&
(value.filenameHint === undefined || typeof value.filenameHint === "string");
10 changes: 10 additions & 0 deletions plans/fix-demo-view-markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# demo の View に markdown が出ない問題を直す

## 原因
- gui-chat-protocol では `data` が View に渡る描画用のデータ、`jsonData` は LLM に返す JSON
- プラグインの `execute`(`presentDocument`)は `data: { markdown, filenameHint }` を返し、View は `data.markdown` を読む。ホストは `execute` の結果をそのまま View に渡す
- demo だけが `execute` を通さずに結果を手で組み立て、入力した引数を `jsonData` に入れていた。`data` が無いので View は常に空

## 修正
- 直すのは demo 側(src は protocol どおり)
- demo は入力 JSON を `isMarkdownArgs`(`demo/markdownArgs.ts`)で確かめてから `executeMarkdown(null, args)` を呼び、その結果を View / Preview に渡す
Loading