summaryrefslogtreecommitdiffhomepage
path: root/js
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-05-23 16:51:53 -0400
committerDax Raad <[email protected]>2025-05-26 12:40:17 -0400
commit5c491758f57b4e5eaf8d15f3bcd02f775ab3edad (patch)
tree3f7df73c6d7e3ae39b1bef7ed145dd53712c137b /js
parent5f750b7368226ce455a6848f5f744d43179198e5 (diff)
downloadopencode-5c491758f57b4e5eaf8d15f3bcd02f775ab3edad.tar.gz
opencode-5c491758f57b4e5eaf8d15f3bcd02f775ab3edad.zip
sync
Diffstat (limited to 'js')
-rw-r--r--js/src/index.ts3
-rw-r--r--js/src/share/share.ts13
-rw-r--r--js/src/util/log.ts2
3 files changed, 9 insertions, 9 deletions
diff --git a/js/src/index.ts b/js/src/index.ts
index 16fa0e43e..100e2bd07 100644
--- a/js/src/index.ts
+++ b/js/src/index.ts
@@ -40,7 +40,8 @@ cli
await Share.init();
const session = await Session.create();
const shareID = await Session.share(session.id);
- if (shareID) console.log("Share ID:", shareID);
+ if (shareID)
+ console.log("Share ID: https://dev.opencode.ai/share/" + shareID);
const result = await Session.chat(session.id, {
type: "text",
text: message.join(" "),
diff --git a/js/src/share/share.ts b/js/src/share/share.ts
index 6c0573e91..6191da684 100644
--- a/js/src/share/share.ts
+++ b/js/src/share/share.ts
@@ -2,8 +2,11 @@ import { App } from "../app";
import { Bus } from "../bus";
import { Session } from "../session/session";
import { Storage } from "../storage/storage";
+import { Log } from "../util/log";
export namespace Share {
+ const log = Log.create({ service: "share" });
+
const state = App.state("share", async () => {
Bus.subscribe(Storage.Event.Write, async (payload) => {
const [root, ...splits] = payload.properties.key.split("/");
@@ -11,12 +14,6 @@ export namespace Share {
const [type, sessionID] = splits;
const session = await Session.get(sessionID);
if (!session.shareID) return;
- console.log({
- sessionID: sessionID,
- shareID: session.shareID,
- key: payload.properties.key,
- content: payload.properties.content,
- });
await fetch(`${URL}/share_sync`, {
method: "POST",
body: JSON.stringify({
@@ -25,7 +22,9 @@ export namespace Share {
key: payload.properties.key,
content: payload.properties.content,
}),
- }).then(console.log);
+ })
+ .then((x) => x.text())
+ .then(console.log);
});
});
diff --git a/js/src/util/log.ts b/js/src/util/log.ts
index dff97f962..2d51b0d24 100644
--- a/js/src/util/log.ts
+++ b/js/src/util/log.ts
@@ -39,7 +39,7 @@ export namespace Log {
})
.map(([key, value]) => `${key}=${value}`)
.join(" ");
- return [prefix, message].join(" ") + "\n";
+ return [new Date().toISOString(), prefix, message].join(" ") + "\n";
}
const result = {
info(message?: any, extra?: Record<string, any>) {