Pin notes to a chat, and import notes from files

Two additions to the shared notes, both about getting content in and out of
the prompt.

Per-chat pinning. Notes normally reach the model as a title list only, and
the body arrives just if the model decides to call read_note. A 📌 on the tab
now puts a page's full body in the system prompt for the chat that is open,
every turn, no tool round trip. The selection is per session (new table
session_note_pages, unique on session_id + page_id), so different
conversations carry different pages. The title list marks pinned pages so the
model does not read them twice, and bodies are capped per page by
SESSION_NOTES_CONTENT_LIMIT.

A new chat has no session row until its first message, so the front end
cannot PUT the selection yet. POST /chat/stream therefore accepts
note_page_ids and applies it before building the context, which makes the
pins count from the very first turn.

File import. Dropping .md/.txt on the editor - or picking them with the new
⬆ button - creates pages, and a .zip is unpacked into one page per text
entry with the first path component as the section. That is exactly the
shape the export writes, so a downloaded zip round-trips back in. Titles that
collide get a " (2)" suffix rather than overwriting, since restoring a backup
into a live workspace should not destroy anything. UploadFile needs
python-multipart, added to the lockfile.

Toasts grew a kind: the import success message was rendering in the red error
toast, as was the existing session-import message. Both are green now.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-23 16:04:41 +09:00
co-authored by Claude Opus 5
parent 216d38c7bd
commit 0e58a07af4
18 changed files with 629 additions and 33 deletions
+46 -1
View File
@@ -18,12 +18,57 @@ API 仕様は `docs/api.md` の「共有ノート」節を参照。
| タイトルを変更 | タブを**ダブルクリック**すると入力欄になるので書き換えて Enter(または欄外をクリック) |
| ページを削除 | タブ内の **×** をクリック(確認ダイアログあり) |
| 本文を編集 | ページを開いた状態で下の編集エリアに直接入力 |
| ファイルを取り込む | 本文エリアにファイルをドロップ、またはパネル下部の **⬆ 取り込み** から選択 |
| チャットに紐付ける | タブ内の **📌** をクリック(もう一度押すと解除) |
| ページを1つ保存 | パネル下部の **⬇ このページ (.md)** をクリック |
| 全ページを保存 | パネル下部の **⬇ すべて (.zip)** をクリック |
本文は入力を止めてから少し待つと自動保存される。保存待ちの間はタブに **●**(未保存マーク)が付く。
ページが1つも無い場合は「+ 最初のページを作成」から始められる。
## ファイルを取り込む
手元のファイルをページとして取り込める。本文エリアに**ドラッグ&ドロップ**するか、
パネル下部の **⬆ 取り込み** からファイルを選ぶ(複数まとめて可)。
| ファイル | どうなるか |
|---|---|
| `.md` / `.txt` | 1 ファイルが 1 ページになる。ファイル名がタイトル |
| `.zip` | 中のテキストファイルが 1 つずつページになる。フォルダ名がセクションになる |
**⬇ すべて (.zip) で出した ZIP をそのまま戻せる**ので、バックアップや別環境への引っ越しに使える。
ファイル名の `01_` のような通し番号は取り込み時に落とされる。
既存のページと同じタイトルだった場合は上書きせず、`設計メモ (2)` のように連番を足して別ページを作る。
要らない方はタブの × で消せばよい。
取り込めない拡張子(PDF や画像など)や大きすぎるファイル(1 ファイル 2MB 超)は飛ばされる。
1 つも取り込めなかったときだけエラーが表示される。
## チャットに紐付けて必ず読ませる
普段、AIに渡っているのは**ページのタイトル一覧だけ**で、本文はAIが必要だと判断したときに
`read_note` で読みに行く。つまり「読みに行ってくれないと参照されない」。
タブの **📌** を押すと、そのページの本文が**今開いているチャット**のプロンプトに毎回そのまま載る。
AIの判断を待たずに確実に参照させたい資料(仕様書、設定、前提条件など)に使う。
📌 が付いたタブは上端に黄色い線が入る。もう一度押すと解除。
**チャットごとの設定**であることに注意。
| チャット | 📌 を付けたページ |
|---|---|
| 「新機能の相談」 | 設計メモ / APIメモ |
| 「夕飯どうする」 | 買い物リスト |
チャットを切り替えると 📌 の状態もそのチャットのものに切り替わる。新規チャットでは
📌 を付けてから最初のメッセージを送れば、その1通目からちゃんと反映される。
長いページは 1 ページ 8000 文字(`SESSION_NOTES_CONTENT_LIMIT`)で打ち切られ、
残りが必要ならAIが `read_note` で読み足せる。あれもこれも 📌 すると毎回のリクエストが
その分重くなるので、本当に読ませたいページだけに絞るのがよい。
## 手元にダウンロードする
パネル下部の ⬇ ボタンでノートをファイルとして保存できる。未保存の編集があっても、
@@ -69,7 +114,7 @@ ZIP の中のファイル名には `01_`, `02_` … と通し番号が付く。
## AIとの連携
- 全ページの**タイトル一覧**は、会話のたびに自動でAIに渡される(セクションがあれば見出し付きで)。
ただし本文はここには含まれない。
ただし本文はここには含まれない(📌 を付けたページを除く)。
- AIは `read_note` ツールでページ本文を読み、`write_note` ツールで追記・置き換え・新規ページ作成ができる。
「ノートに書いておいて」「〇〇について記録して」のように頼むと、AIが該当ページを判断して書き込む。
- AIがノートを書き換えると、開いているノートパネルは自動的に最新の内容へ更新される。