@leanandmean/coding-agent 0.74.1-scramjet.32 → 0.74.1-scramjet.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1910,11 +1910,14 @@ export class InteractiveMode {
1910
1910
  };
1911
1911
  return new Promise((resolve, reject) => {
1912
1912
  let component;
1913
+ let attachedTool;
1914
+ let committedContext;
1913
1915
  let closed = false;
1914
1916
  const close = (result) => {
1915
1917
  if (closed)
1916
1918
  return;
1917
1919
  closed = true;
1920
+ attachedTool?.detachCommittedContext();
1918
1921
  if (isOverlay)
1919
1922
  this.ui.hideOverlay();
1920
1923
  else
@@ -1929,10 +1932,41 @@ export class InteractiveMode {
1929
1932
  }
1930
1933
  };
1931
1934
  Promise.resolve(factory(this.ui, theme, this.keybindings, close))
1932
- .then((c) => {
1935
+ .then(async (c) => {
1933
1936
  if (closed)
1934
1937
  return;
1935
1938
  component = c;
1939
+ const attachment = options?.toolAttachedContext;
1940
+ if (attachment) {
1941
+ if (isOverlay)
1942
+ throw new Error("Tool-attached context cannot be shown as an overlay");
1943
+ const tool = this.pendingTools.get(attachment.toolCallId);
1944
+ const orderingBarrier = this.chatContainer.children.find((child) => this.mutableChatComponents.has(child));
1945
+ if (!tool || !this.chatContainer.children.includes(tool) || orderingBarrier !== tool) {
1946
+ throw new Error("Tool-attached context requires the current pending tool row");
1947
+ }
1948
+ attachedTool = tool;
1949
+ committedContext = attachment.render(this.ui, theme);
1950
+ this.committedChatContainer.addChild(committedContext);
1951
+ tool.attachCommittedContext(component);
1952
+ this.ui.setFocus(null);
1953
+ this.editorContainer.clear();
1954
+ try {
1955
+ await this.ui.commitNow({ requireFlush: true });
1956
+ }
1957
+ catch (error) {
1958
+ tool.cancelCommittedContext();
1959
+ this.committedChatContainer.removeChild(committedContext);
1960
+ committedContext = undefined;
1961
+ this.ui.rebuild();
1962
+ throw error;
1963
+ }
1964
+ if (closed)
1965
+ return;
1966
+ this.ui.setFocus(tool);
1967
+ this.ui.requestRender();
1968
+ return;
1969
+ }
1936
1970
  if (isOverlay) {
1937
1971
  // Resolve overlay options - can be static or dynamic function
1938
1972
  const resolveOptions = () => {
@@ -1960,6 +1994,17 @@ export class InteractiveMode {
1960
1994
  .catch((err) => {
1961
1995
  if (closed)
1962
1996
  return;
1997
+ attachedTool?.cancelCommittedContext();
1998
+ if (committedContext) {
1999
+ this.committedChatContainer.removeChild(committedContext);
2000
+ this.ui.rebuild();
2001
+ }
2002
+ try {
2003
+ component?.dispose?.();
2004
+ }
2005
+ catch {
2006
+ /* ignore dispose errors */
2007
+ }
1963
2008
  if (!isOverlay)
1964
2009
  restoreEditor();
1965
2010
  reject(err);